Search in sources :

Example 16 with Key

use of com.artipie.asto.Key in project maven-adapter by artipie.

the class AstoValidUploadTest method returnsFalseWhenNoArtifactsFound.

@Test
void returnsFalseWhenNoArtifactsFound() {
    final Key upload = new Key.From(".upload/com/test/logger");
    this.addMetadata(upload);
    MatcherAssert.assertThat(this.validupload.validate(upload, upload).toCompletableFuture().join(), new IsEqual<>(false));
}
Also used : Key(com.artipie.asto.Key) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 17 with Key

use of com.artipie.asto.Key in project maven-adapter by artipie.

the class RepositoryChecksumsTest method generatesChecksums.

@Test
void generatesChecksums() {
    final Storage storage = new InMemoryStorage();
    final Key key = new Key.From("my-artifact.jar");
    final byte[] content = "my artifact content".getBytes();
    storage.save(key, new Content.From(content));
    new RepositoryChecksums(storage).generate(key).toCompletableFuture().join();
    MatcherAssert.assertThat("Generates sha1", new PublisherAs(storage.value(new Key.From(String.format("%s.sha1", key.string()))).join()).asciiString().toCompletableFuture().join(), new IsEqual<>(DigestUtils.sha1Hex(content)));
    MatcherAssert.assertThat("Generates sha256", new PublisherAs(storage.value(new Key.From(String.format("%s.sha256", key.string()))).join()).asciiString().toCompletableFuture().join(), new IsEqual<>(DigestUtils.sha256Hex(content)));
    MatcherAssert.assertThat("Generates sha512", new PublisherAs(storage.value(new Key.From(String.format("%s.sha512", key.string()))).join()).asciiString().toCompletableFuture().join(), new IsEqual<>(DigestUtils.sha512Hex(content)));
    MatcherAssert.assertThat("Generates md5", new PublisherAs(storage.value(new Key.From(String.format("%s.md5", key.string()))).join()).asciiString().toCompletableFuture().join(), new IsEqual<>(DigestUtils.md5Hex(content)));
}
Also used : InMemoryStorage(com.artipie.asto.memory.InMemoryStorage) PublisherAs(com.artipie.asto.ext.PublisherAs) Storage(com.artipie.asto.Storage) InMemoryStorage(com.artipie.asto.memory.InMemoryStorage) BlockingStorage(com.artipie.asto.blocking.BlockingStorage) Content(com.artipie.asto.Content) Key(com.artipie.asto.Key) Test(org.junit.jupiter.api.Test)

Example 18 with Key

use of com.artipie.asto.Key in project maven-adapter by artipie.

the class ArtifactGetResponseTest method okIfArtifactExists.

@Test
void okIfArtifactExists() throws Exception {
    final Storage storage = new InMemoryStorage();
    final Key key = new Key.From("repo/artifact.jar");
    new BlockingStorage(storage).save(key, "something".getBytes());
    MatcherAssert.assertThat(new ArtifactGetResponse(storage, key), new RsHasStatus(RsStatus.OK));
}
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) RsHasStatus(com.artipie.http.hm.RsHasStatus) Key(com.artipie.asto.Key) Test(org.junit.jupiter.api.Test)

Example 19 with Key

use of com.artipie.asto.Key in project maven-adapter by artipie.

the class ArtifactGetResponseTest method hasBodyIfExists.

@Test
void hasBodyIfExists() throws Exception {
    final Storage storage = new InMemoryStorage();
    final Key key = new Key.From("repo/artifact2.jar");
    final byte[] data = "data".getBytes(StandardCharsets.UTF_8);
    new BlockingStorage(storage).save(key, data);
    MatcherAssert.assertThat(new ArtifactGetResponse(storage, key), new RsHasBody(data));
}
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 20 with Key

use of com.artipie.asto.Key in project maven-adapter by artipie.

the class ArtifactHeadResponseTest method okIfArtifactExists.

@Test
void okIfArtifactExists() throws Exception {
    final Storage storage = new InMemoryStorage();
    final Key key = new Key.From("repo/artifact.jar");
    new BlockingStorage(storage).save(key, "something".getBytes());
    MatcherAssert.assertThat(new ArtifactHeadResponse(storage, key), new RsHasStatus(RsStatus.OK));
}
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) RsHasStatus(com.artipie.http.hm.RsHasStatus) Key(com.artipie.asto.Key) Test(org.junit.jupiter.api.Test)

Aggregations

Key (com.artipie.asto.Key)37 Test (org.junit.jupiter.api.Test)17 Storage (com.artipie.asto.Storage)16 BlockingStorage (com.artipie.asto.blocking.BlockingStorage)13 InMemoryStorage (com.artipie.asto.memory.InMemoryStorage)9 Content (com.artipie.asto.Content)8 Optional (java.util.Optional)8 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)7 YamlMapping (com.amihaiemil.eoyaml.YamlMapping)6 PublisherAs (com.artipie.asto.ext.PublisherAs)6 CompletableFuture (java.util.concurrent.CompletableFuture)6 Matcher (java.util.regex.Matcher)6 Pattern (java.util.regex.Pattern)6 Collectors (java.util.stream.Collectors)5 TestResource (com.artipie.asto.test.TestResource)4 Response (com.artipie.http.Response)4 Slice (com.artipie.http.Slice)4 AsyncResponse (com.artipie.http.async.AsyncResponse)4 RequestLineFrom (com.artipie.http.rq.RequestLineFrom)4 CompletionStage (java.util.concurrent.CompletionStage)4