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));
}
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)));
}
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));
}
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));
}
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));
}
Aggregations