Search in sources :

Example 16 with RsHasStatus

use of com.artipie.http.hm.RsHasStatus in project maven-adapter by artipie.

the class PutMetadataChecksumSliceTest method returnsBadRequestIfSuitableMetadataFileNotFound.

@Test
void returnsBadRequestIfSuitableMetadataFileNotFound() {
    this.asto.save(new Key.From(UploadSlice.TEMP, "com/example/xyz/0.1/meta/maven-metadata.xml"), new Content.From("xml".getBytes())).join();
    final Maven.Fake mvn = new Maven.Fake();
    MatcherAssert.assertThat("Incorrect response status, BAD REQUEST is expected", new PutMetadataChecksumSlice(this.asto, new ValidUpload.Dummy(), mvn), new SliceHasResponse(new RsHasStatus(RsStatus.BAD_REQUEST), new RequestLine(RqMethod.PUT, "/com/example/xyz/maven-metadata.xml.sha1"), Headers.EMPTY, new Content.From("any".getBytes())));
    MatcherAssert.assertThat("Repository update was started when it does not supposed to", mvn.wasUpdated(), new IsEqual<>(false));
}
Also used : Maven(com.artipie.maven.Maven) RequestLine(com.artipie.http.rq.RequestLine) SliceHasResponse(com.artipie.http.hm.SliceHasResponse) RsHasStatus(com.artipie.http.hm.RsHasStatus) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 17 with RsHasStatus

use of com.artipie.http.hm.RsHasStatus in project maven-adapter by artipie.

the class PutMetadataSliceTest method returnsCreatedAndSavesSnapshotMetadata.

@Test
void returnsCreatedAndSavesSnapshotMetadata() {
    final byte[] xml = new MetadataXml("com.example", "abc").get(new MetadataXml.VersionTags("0.1-SNAPSHOT", "0.2-SNAPSHOT")).getBytes(StandardCharsets.UTF_8);
    this.asto.save(new Key.From(UploadSlice.TEMP, "com/example/abc/0.2-SNAPSHOT/abc.jar"), Content.EMPTY).join();
    MatcherAssert.assertThat("Incorrect response status, CREATED is expected", this.pms, new SliceHasResponse(new RsHasStatus(RsStatus.CREATED), new RequestLine(RqMethod.PUT, "/com/example/abc/maven-metadata.xml"), new Headers.From(new ContentLength(xml.length)), new Content.OneTime(new Content.From(xml))));
    MatcherAssert.assertThat("Metadata file was not saved to storage", this.asto.value(new Key.From(".upload/com/example/abc/0.2-SNAPSHOT/meta/maven-metadata.xml")).join(), new ContentIs(xml));
}
Also used : SliceHasResponse(com.artipie.http.hm.SliceHasResponse) RsHasStatus(com.artipie.http.hm.RsHasStatus) ContentIs(com.artipie.asto.test.ContentIs) RequestLine(com.artipie.http.rq.RequestLine) MetadataXml(com.artipie.maven.MetadataXml) Content(com.artipie.asto.Content) ContentLength(com.artipie.http.headers.ContentLength) Key(com.artipie.asto.Key) Test(org.junit.jupiter.api.Test)

Example 18 with RsHasStatus

use of com.artipie.http.hm.RsHasStatus in project maven-adapter by artipie.

the class PutMetadataSliceTest method returnsCreatedAndSavesSnapshotMetadataWhenReleaseIsPresent.

@Test
void returnsCreatedAndSavesSnapshotMetadataWhenReleaseIsPresent() {
    final byte[] xml = new MetadataXml("com.example", "any").get(new MetadataXml.VersionTags(Optional.empty(), Optional.of("0.2"), new ListOf<String>("0.1", "0.2", "0.3-SNAPSHOT"))).getBytes(StandardCharsets.UTF_8);
    this.asto.save(new Key.From(UploadSlice.TEMP, "com/example/any/0.3-SNAPSHOT/any.jar"), Content.EMPTY).join();
    MatcherAssert.assertThat("Incorrect response status, CREATED is expected", this.pms, new SliceHasResponse(new RsHasStatus(RsStatus.CREATED), new RequestLine(RqMethod.PUT, "/com/example/any/maven-metadata.xml"), new Headers.From(new ContentLength(xml.length)), new Content.OneTime(new Content.From(xml))));
    MatcherAssert.assertThat("Metadata file was not saved to storage", this.asto.value(new Key.From(".upload/com/example/any/0.3-SNAPSHOT/meta/maven-metadata.xml")).join(), new ContentIs(xml));
}
Also used : SliceHasResponse(com.artipie.http.hm.SliceHasResponse) RsHasStatus(com.artipie.http.hm.RsHasStatus) ContentIs(com.artipie.asto.test.ContentIs) RequestLine(com.artipie.http.rq.RequestLine) MetadataXml(com.artipie.maven.MetadataXml) Content(com.artipie.asto.Content) ContentLength(com.artipie.http.headers.ContentLength) Key(com.artipie.asto.Key) Test(org.junit.jupiter.api.Test)

Example 19 with RsHasStatus

use of com.artipie.http.hm.RsHasStatus in project maven-adapter by artipie.

the class UploadSliceTest method savesDataToTempUpload.

@Test
void savesDataToTempUpload() {
    final byte[] data = "jar content".getBytes();
    MatcherAssert.assertThat("Wrong response status, CREATED is expected", this.ums, new SliceHasResponse(new RsHasStatus(RsStatus.CREATED), new RequestLine(RqMethod.PUT, "/com/artipie/asto/0.1/asto-0.1.jar"), new Headers.From(new ContentLength(data.length)), new Content.From(data)));
    MatcherAssert.assertThat("Uploaded data were not saved to storage", this.asto.value(new Key.From(".upload/com/artipie/asto/0.1/asto-0.1.jar")).join(), new ContentIs(data));
}
Also used : RequestLine(com.artipie.http.rq.RequestLine) SliceHasResponse(com.artipie.http.hm.SliceHasResponse) RsHasStatus(com.artipie.http.hm.RsHasStatus) ContentLength(com.artipie.http.headers.ContentLength) ContentIs(com.artipie.asto.test.ContentIs) Key(com.artipie.asto.Key) Test(org.junit.jupiter.api.Test)

Example 20 with RsHasStatus

use of com.artipie.http.hm.RsHasStatus 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)

Aggregations

RsHasStatus (com.artipie.http.hm.RsHasStatus)27 Test (org.junit.jupiter.api.Test)23 RequestLine (com.artipie.http.rq.RequestLine)20 SliceHasResponse (com.artipie.http.hm.SliceHasResponse)15 RsWithStatus (com.artipie.http.rs.RsWithStatus)10 Content (com.artipie.asto.Content)9 Key (com.artipie.asto.Key)9 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)9 RsStatus (com.artipie.http.rs.RsStatus)8 SliceSimple (com.artipie.http.slice.SliceSimple)7 Storage (com.artipie.asto.Storage)6 ContentIs (com.artipie.asto.test.ContentIs)6 MetadataXml (com.artipie.maven.MetadataXml)6 InMemoryStorage (com.artipie.asto.memory.InMemoryStorage)5 RsHasBody (com.artipie.http.hm.RsHasBody)5 BlockingStorage (com.artipie.asto.blocking.BlockingStorage)4 Slice (com.artipie.http.Slice)4 BasicAuthSlice (com.artipie.http.auth.BasicAuthSlice)4 Permission (com.artipie.http.auth.Permission)4 Authorization (com.artipie.http.headers.Authorization)4