use of com.artipie.asto.test.TestResource in project maven-adapter by artipie.
the class AstoMavenTest method addsMetadataChecksums.
@Test
void addsMetadataChecksums() {
final String version = "0.1";
new TestResource("maven-metadata.xml.example").saveTo(this.storage, new Key.From(AstoMavenTest.LGR_UPLOAD, version, PutMetadataSlice.SUB_META, "maven-metadata.xml"));
new AstoMaven(this.storage).update(new Key.From(AstoMavenTest.LGR_UPLOAD, version), AstoMavenTest.LGR).toCompletableFuture().join();
MatcherAssert.assertThat(this.storage.list(AstoMavenTest.LGR).join().stream().map(key -> new KeyLastPart(key).get()).filter(key -> key.contains("maven-metadata.xml")).toArray(String[]::new), Matchers.arrayContainingInAnyOrder("maven-metadata.xml", "maven-metadata.xml.sha1", "maven-metadata.xml.sha256", "maven-metadata.xml.sha512", "maven-metadata.xml.md5"));
}
use of com.artipie.asto.test.TestResource in project maven-adapter by artipie.
the class MavenProxySliceITCase method downloadsJarFromCache.
@Test
void downloadsJarFromCache() throws Exception {
new TestResource("com/artipie/helloworld").addFilesTo(this.storage, new Key.From("com", "artipie", "helloworld"));
final HttpURLConnection con = (HttpURLConnection) new URL(String.format("http://localhost:%s/com/artipie/helloworld/0.1/helloworld-0.1.jar", this.port)).openConnection();
con.setRequestMethod("GET");
MatcherAssert.assertThat("Response status is 200", con.getResponseCode(), new IsEqual<>(Integer.parseInt(RsStatus.OK.code())));
con.disconnect();
}
use of com.artipie.asto.test.TestResource in project front by artipie.
the class GetRepositoryTest method returnsRepositorySettings.
@ParameterizedTest
@CsvSource({ "yaml,my-maven", "yml,my-npm-proxy" })
void returnsRepositorySettings(final String ext, final String name) throws Exception {
final BlockingStorage blsto = new BlockingStorage(new InMemoryStorage());
final String file = String.format("%s.%s", name, ext);
blsto.save(new Key.From(file), new TestResource(String.format("GetRepositoryTest/%s", file)).asBytes());
final var resp = Mockito.mock(Response.class);
final var rqs = Mockito.mock(Request.class);
Mockito.when(rqs.params(GetRepository.NAME_PARAM.toString())).thenReturn(name);
Mockito.when(rqs.attribute(RequestAttr.Standard.USER_ID.attrName())).thenReturn("any");
JSONAssert.assertEquals(new GetRepository(new RepoSettings("flat", blsto)).handle(rqs, resp), new String(new TestResource(String.format("GetRepositoryTest/%s.json", name)).asBytes(), StandardCharsets.UTF_8), true);
Mockito.verify(resp).type("application/json");
}
use of com.artipie.asto.test.TestResource in project maven-adapter by artipie.
the class MavenProxySliceAuthIT method setUp.
@BeforeEach
void setUp() throws Exception {
final Storage storage = new InMemoryStorage();
new TestResource("com/artipie/helloworld").addFilesTo(storage, new Key.From("com", "artipie", "helloworld"));
final String username = "alice";
final String password = "qwerty";
this.server = new VertxSliceServer(MavenProxySliceAuthIT.VERTX, new LoggingSlice(new MavenSlice(storage, (user, action) -> user.name().equals(username), new Authentication.Single(username, password))));
final int port = this.server.start();
this.client.start();
this.proxy = new LoggingSlice(new MavenProxySlice(this.client, URI.create(String.format("http://localhost:%d", port)), new BasicAuthenticator(username, password), Cache.NOP));
}
use of com.artipie.asto.test.TestResource in project artipie by artipie.
the class GemITCase method gemPushAndInstallWorks.
@Test
void gemPushAndInstallWorks() throws IOException {
this.containers.assertExec("Packages was not pushed", new ContainerResultMatcher(new IsEqual<>(0), new StringContainsInOrder(new ListOf<String>("POST http://artipie:8080/my-gem/api/v1/gems", "201 Created"))), "env", String.format("GEM_HOST_API_KEY=%s", new Base64Encoded("any:any").asString()), "gem", "push", "-v", "/w/rails-6.0.2.2.gem", "--host", "http://artipie:8080/my-gem");
this.containers.assertArtipieContent("Package was not added to storage", String.format("/var/artipie/data/my-gem/gems/%s", GemITCase.RAILS), new IsEqual<>(new TestResource(String.format("gem/%s", GemITCase.RAILS)).asBytes()));
this.containers.assertExec("rubygems.org was not removed from sources", new ContainerResultMatcher(), "gem", "sources", "--remove", "https://rubygems.org/");
this.containers.assertExec("Package was not installed", new ContainerResultMatcher(new IsEqual<>(0), new StringContainsInOrder(new ListOf<String>(String.format("GET http://artipie:8080/my-gem/quick/Marshal.4.8/%sspec.rz", GemITCase.RAILS), "200 OK", "Successfully installed rails-6.0.2.2", "1 gem installed"))), "gem", "install", GemITCase.RAILS, "--source", "http://artipie:8080/my-gem", "--ignore-dependencies", "-V");
}
Aggregations