use of com.artipie.asto.Storage 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.Storage in project maven-adapter by artipie.
the class ArtifactGetResponseTest method notFoundIfDoesnExist.
@Test
void notFoundIfDoesnExist() {
final Storage storage = new InMemoryStorage();
MatcherAssert.assertThat(new ArtifactGetResponse(storage, new Key.From("none")), new RsHasStatus(RsStatus.NOT_FOUND));
}
use of com.artipie.asto.Storage in project maven-adapter by artipie.
the class ArtifactHeadResponseTest method notFoundIfDoesnExist.
@Test
void notFoundIfDoesnExist() {
final Storage storage = new InMemoryStorage();
MatcherAssert.assertThat(new ArtifactHeadResponse(storage, new Key.From("none")), new RsHasStatus(RsStatus.NOT_FOUND));
}
use of com.artipie.asto.Storage in project maven-adapter by artipie.
the class ArtifactHeadResponseTest method noBodyIfExists.
@Test
void noBodyIfExists() throws Exception {
final Storage storage = new InMemoryStorage();
final Key key = new Key.From("repo/artifact2.jar");
new BlockingStorage(storage).save(key, "data".getBytes(StandardCharsets.UTF_8));
MatcherAssert.assertThat(new ArtifactHeadResponse(storage, key), new RsHasBody(new byte[0]));
}
use of com.artipie.asto.Storage in project maven-adapter by artipie.
the class AstoMaven method moveToTheRepository.
/**
* Moves artifacts from temp location to repository.
* @param upload Upload temp location
* @param target Repository
* @param artifact Artifact repository location
* @return Completion action
*/
private CompletableFuture<Void> moveToTheRepository(final Key upload, final Storage target, final Key artifact) {
final Storage sub = new SubStorage(new Key.From(upload, PutMetadataSlice.SUB_META), this.storage);
final Storage subversion = new SubStorage(upload.parent().get(), this.storage);
return sub.list(Key.ROOT).thenCompose(list -> new Copy(sub, list.stream().filter(key -> key.string().contains(AstoMaven.MAVEN_META)).collect(Collectors.toList())).copy(new SubStorage(artifact, target))).thenCompose(nothing -> subversion.list(Key.ROOT).thenCompose(list -> new Copy(subversion, list.stream().filter(key -> !key.string().contains(String.format("/%s/", PutMetadataSlice.SUB_META))).collect(Collectors.toList())).copy(new SubStorage(artifact, target))));
}
Aggregations