Search in sources :

Example 6 with Storage

use of com.artipie.asto.Storage 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 7 with Storage

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

the class RepositoryChecksumsTest method findsArtifactChecksums.

@Test
void findsArtifactChecksums() throws Exception {
    // @checkstyle LocalFinalVariableNameCheck (20 lines)
    final Storage storage = new InMemoryStorage();
    final BlockingStorage bsto = new BlockingStorage(storage);
    final Key.From artifact = new Key.From("com/test/1.0/my-package.jar");
    bsto.save(artifact, "artifact".getBytes());
    final String sha1 = "c71de136f9377eca14b4218cc7001c8060c6974f";
    bsto.save(new Key.From("com/test/1.0/my-package.jar.sha1"), sha1.getBytes(StandardCharsets.UTF_8));
    final String sha256 = "62090f2241986a8361242e47cf541657099fdccc0c08e34cd694922bdcf31893";
    bsto.save(new Key.From("com/test/1.0/my-package.jar.sha256"), sha256.getBytes(StandardCharsets.UTF_8));
    // @checkstyle LineLengthCheck (1 line)
    final String sha512 = "cf713dd3f077719375e646a23dee1375725652f5f275b0bf25d326062b3a64535575acde6d27b547fcd735c870cf94badc4b2215aba9c3af5085567b4561ac28";
    bsto.save(new Key.From("com/test/1.0/my-package.jar.sha512"), sha512.getBytes(StandardCharsets.UTF_8));
    final String mdfive = "dc829bf0d79e690c59cee708b527e6b7";
    bsto.save(new Key.From("com/test/1.0/my-package.jar.md5"), mdfive.getBytes(StandardCharsets.UTF_8));
    MatcherAssert.assertThat(new RepositoryChecksums(storage).checksums(artifact).toCompletableFuture().get(), Matchers.allOf(Matchers.hasEntry("sha1", sha1), Matchers.hasEntry("sha256", sha256), Matchers.hasEntry("sha512", sha512), Matchers.hasEntry("md5", mdfive)));
}
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) Key(com.artipie.asto.Key) Test(org.junit.jupiter.api.Test)

Example 8 with Storage

use of com.artipie.asto.Storage 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 9 with Storage

use of com.artipie.asto.Storage 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 10 with Storage

use of com.artipie.asto.Storage 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

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