Search in sources :

Example 11 with Storage

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));
}
Also used : RqMethod(com.artipie.http.rq.RqMethod) BeforeEach(org.junit.jupiter.api.BeforeEach) Headers(com.artipie.http.Headers) InMemoryStorage(com.artipie.asto.memory.InMemoryStorage) Slice(com.artipie.http.Slice) LoggingSlice(com.artipie.http.slice.LoggingSlice) RsStatus(com.artipie.http.rs.RsStatus) Content(com.artipie.asto.Content) Key(com.artipie.asto.Key) Disabled(org.junit.jupiter.api.Disabled) RsHasStatus(com.artipie.http.hm.RsHasStatus) Test(org.junit.jupiter.api.Test) RequestLine(com.artipie.http.rq.RequestLine) Vertx(io.vertx.reactivex.core.Vertx) AfterEach(org.junit.jupiter.api.AfterEach) MatcherAssert(org.hamcrest.MatcherAssert) Storage(com.artipie.asto.Storage) JettyClientSlices(com.artipie.http.client.jetty.JettyClientSlices) VertxSliceServer(com.artipie.vertx.VertxSliceServer) BasicAuthenticator(com.artipie.http.client.auth.BasicAuthenticator) Cache(com.artipie.asto.cache.Cache) URI(java.net.URI) Authentication(com.artipie.http.auth.Authentication) TestResource(com.artipie.asto.test.TestResource) TestResource(com.artipie.asto.test.TestResource) InMemoryStorage(com.artipie.asto.memory.InMemoryStorage) InMemoryStorage(com.artipie.asto.memory.InMemoryStorage) Storage(com.artipie.asto.Storage) VertxSliceServer(com.artipie.vertx.VertxSliceServer) BasicAuthenticator(com.artipie.http.client.auth.BasicAuthenticator) Key(com.artipie.asto.Key) LoggingSlice(com.artipie.http.slice.LoggingSlice) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 12 with Storage

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));
}
Also used : InMemoryStorage(com.artipie.asto.memory.InMemoryStorage) Storage(com.artipie.asto.Storage) InMemoryStorage(com.artipie.asto.memory.InMemoryStorage) BlockingStorage(com.artipie.asto.blocking.BlockingStorage) RsHasStatus(com.artipie.http.hm.RsHasStatus) Test(org.junit.jupiter.api.Test)

Example 13 with Storage

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));
}
Also used : InMemoryStorage(com.artipie.asto.memory.InMemoryStorage) Storage(com.artipie.asto.Storage) InMemoryStorage(com.artipie.asto.memory.InMemoryStorage) BlockingStorage(com.artipie.asto.blocking.BlockingStorage) RsHasStatus(com.artipie.http.hm.RsHasStatus) Test(org.junit.jupiter.api.Test)

Example 14 with Storage

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]));
}
Also used : InMemoryStorage(com.artipie.asto.memory.InMemoryStorage) BlockingStorage(com.artipie.asto.blocking.BlockingStorage) Storage(com.artipie.asto.Storage) InMemoryStorage(com.artipie.asto.memory.InMemoryStorage) BlockingStorage(com.artipie.asto.blocking.BlockingStorage) RsHasBody(com.artipie.http.hm.RsHasBody) Key(com.artipie.asto.Key) Test(org.junit.jupiter.api.Test)

Example 15 with Storage

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))));
}
Also used : Copy(com.artipie.asto.Copy) Maven(com.artipie.maven.Maven) SubStorage(com.artipie.asto.SubStorage) XMLDocument(com.jcabi.xml.XMLDocument) Collection(java.util.Collection) KeyLastPart(com.artipie.asto.ext.KeyLastPart) Directives(org.xembly.Directives) PutMetadataSlice(com.artipie.maven.http.PutMetadataSlice) CompletableFuture(java.util.concurrent.CompletableFuture) Key(com.artipie.asto.Key) Collectors(java.util.stream.Collectors) PublisherAs(com.artipie.asto.ext.PublisherAs) CompletionStage(java.util.concurrent.CompletionStage) Storage(com.artipie.asto.Storage) MavenMetadata(com.artipie.maven.metadata.MavenMetadata) SubStorage(com.artipie.asto.SubStorage) Storage(com.artipie.asto.Storage) Copy(com.artipie.asto.Copy) SubStorage(com.artipie.asto.SubStorage) Key(com.artipie.asto.Key)

Aggregations

Storage (com.artipie.asto.Storage)24 Key (com.artipie.asto.Key)17 InMemoryStorage (com.artipie.asto.memory.InMemoryStorage)15 Test (org.junit.jupiter.api.Test)15 BlockingStorage (com.artipie.asto.blocking.BlockingStorage)10 RsHasStatus (com.artipie.http.hm.RsHasStatus)6 Content (com.artipie.asto.Content)4 PublisherAs (com.artipie.asto.ext.PublisherAs)4 FileStorage (com.artipie.asto.fs.FileStorage)4 YamlMapping (com.amihaiemil.eoyaml.YamlMapping)3 TestResource (com.artipie.asto.test.TestResource)3 RsHasBody (com.artipie.http.hm.RsHasBody)3 Optional (java.util.Optional)3 CompletableFuture (java.util.concurrent.CompletableFuture)3 CompletionStage (java.util.concurrent.CompletionStage)3 StrictYamlMapping (com.amihaiemil.eoyaml.StrictYamlMapping)2 SubStorage (com.artipie.asto.SubStorage)2 EtcdStorage (com.artipie.asto.etcd.EtcdStorage)2 S3Storage (com.artipie.asto.s3.S3Storage)2 Slice (com.artipie.http.Slice)2