use of com.artipie.asto.test.TestResource in project front by artipie.
the class PutRepositoryTest method addsNewRepo.
@Test
void addsNewRepo() {
final var resp = Mockito.mock(Response.class);
final var rqs = Mockito.mock(Request.class);
Mockito.when(rqs.params(GetRepository.NAME_PARAM.toString())).thenReturn("my-rpm");
Mockito.when(rqs.attribute(RequestAttr.Standard.USER_ID.attrName())).thenReturn("any");
Mockito.when(rqs.body()).thenReturn(new String(new TestResource("PutRepositoryTest/request.json").asBytes(), StandardCharsets.UTF_8));
MatcherAssert.assertThat("Failed to return empty response", new PutRepository(new RepoSettings("flat", this.blsto)).handle(rqs, resp), new IsAnything<>());
Mockito.verify(resp).status(HttpStatus.CREATED_201);
MatcherAssert.assertThat(new String(this.blsto.value(new Key.From("my-rpm.yml")), StandardCharsets.UTF_8), new IsEqual<>(String.join(System.lineSeparator(), "repo:", " type: rpm", " storage:", " type: fs", " path: /var/artipie/data/", " settings:", " digest: sha1", " filelists: false", " permissions:", " alice:", " - read", " - write", " bob:", " - read")));
}
use of com.artipie.asto.test.TestResource in project artipie by artipie.
the class NugetITCase method shouldPushAndInstallPackage.
@Test
void shouldPushAndInstallPackage() throws Exception {
final String pckgname = UUID.randomUUID().toString();
this.containers.putBinaryToClient(new TestResource("nuget/newtonsoft.json/12.0.3/newtonsoft.json.12.0.3.nupkg").asBytes(), String.format("/w/%s", pckgname));
this.containers.assertExec("Package was not pushed", new ContainerResultMatcher(new IsEqual<>(0), new StringContains("Your package was pushed.")), "dotnet", "nuget", "push", pckgname, "-s", "http://artipie:8080/my-nuget/index.json");
this.containers.assertExec("New project was not created", new ContainerResultMatcher(), "dotnet", "new", "console", "-n", "TestProj");
this.containers.assertExec("Package was not added", new ContainerResultMatcher(new IsEqual<>(0), new StringContainsInOrder(Arrays.asList(// @checkstyle LineLengthCheck (1 line)
"PackageReference for package 'newtonsoft.json' version '12.0.3' added to file '/w/TestProj/TestProj.csproj'", "Restored /w/TestProj/TestProj.csproj"))), "dotnet", "add", "TestProj", "package", "newtonsoft.json", "--version", "12.0.3", "-s", "http://artipie:8080/my-nuget/index.json");
}
use of com.artipie.asto.test.TestResource in project artipie by artipie.
the class MavenITCase method deploysArtifact.
@ParameterizedTest
@CsvSource({ "helloworld,0.1,0.1", "snapshot,1.0-SNAPSHOT" })
void deploysArtifact(final String type, final String vers) throws Exception {
this.containers.putBinaryToClient(new TestResource(String.format("%s-src/pom.xml", type)).asBytes(), "/w/pom.xml");
this.containers.assertExec("Deploy failed", new ContainerResultMatcher(ContainerResultMatcher.SUCCESS), "mvn", "-B", "-q", "-s", "settings.xml", "deploy", "-Dmaven.install.skip=true");
this.containers.assertExec("Download failed", new ContainerResultMatcher(ContainerResultMatcher.SUCCESS), "mvn", "-B", "-q", "-s", "settings.xml", "-U", "dependency:get", String.format("-Dartifact=com.artipie:%s:%s", type, vers));
}
use of com.artipie.asto.test.TestResource in project artipie by artipie.
the class CachedCredsTest method getsOriginForSameConfigurationButDifferentStorages.
@Test
void getsOriginForSameConfigurationButDifferentStorages() {
final String path = "_credentials.yaml";
final Key key = new Key.From(path);
final CredsConfigCache configs = new CachedCreds(this.cache);
final Storage another = new InMemoryStorage();
new TestResource(path).saveTo(this.storage);
new BlockingStorage(another).save(key, "credentials: another val".getBytes(StandardCharsets.UTF_8));
final YamlMapping frst = configs.credentials(this.storage, key).toCompletableFuture().join();
final YamlMapping scnd = configs.credentials(another, key).toCompletableFuture().join();
MatcherAssert.assertThat("Obtained configurations were the same", frst.equals(scnd), new IsEqual<>(false));
MatcherAssert.assertThat("Credentials configuration was not cached", this.cache.size(), new IsEqual<>(2L));
}
use of com.artipie.asto.test.TestResource in project artipie by artipie.
the class UsersFromStorageYamlTest method readsCredentialsFromCache.
@Test
void readsCredentialsFromCache() {
final CachedCreds cache = new CachedCreds();
new TestResource("_credentials.yaml").saveTo(this.storage, this.key);
final UsersFromStorageYaml creds = new UsersFromStorageYaml(this.storage, this.key, cache);
creds.yaml().toCompletableFuture().join();
this.saveCreds(Users.PasswordFormat.PLAIN, Pair.of(new Users.User("pol"), "newpswd"));
MatcherAssert.assertThat(creds.yaml().toCompletableFuture().join().yamlMapping("credentials").keys().stream().map(YamlNode::asScalar).map(Scalar::value).toList(), Matchers.containsInAnyOrder("bob", "alice"));
}
Aggregations