Search in sources :

Example 6 with RsHasStatus

use of com.artipie.http.hm.RsHasStatus in project artipie by artipie.

the class ContentLengthRestrictionTest method shouldNotPassRequestsAboveLimit.

@Test
public void shouldNotPassRequestsAboveLimit() {
    final int limit = 10;
    final Slice slice = new ContentLengthRestriction((line, headers, body) -> new RsWithStatus(RsStatus.OK), limit);
    final Response response = slice.response("", this.headers("11"), Flowable.empty());
    MatcherAssert.assertThat(response, new RsHasStatus(RsStatus.PAYLOAD_TOO_LARGE));
}
Also used : Response(com.artipie.http.Response) RsWithStatus(com.artipie.http.rs.RsWithStatus) RsHasStatus(com.artipie.http.hm.RsHasStatus) Slice(com.artipie.http.Slice) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 7 with RsHasStatus

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

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

Example 9 with RsHasStatus

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

the class CachedProxySliceTest method loadsOriginIfCacheNotFound.

@Test
void loadsOriginIfCacheNotFound() {
    final byte[] data = "remote".getBytes();
    MatcherAssert.assertThat(new CachedProxySlice((line, headers, body) -> new RsWithBody(ByteBuffer.wrap(data)), (key, supplier, control) -> supplier.get()), new SliceHasResponse(Matchers.allOf(new RsHasStatus(RsStatus.OK), new RsHasBody(data)), new RequestLine(RqMethod.GET, "/bar")));
}
Also used : RqMethod(com.artipie.http.rq.RqMethod) RsWithStatus(com.artipie.http.rs.RsWithStatus) SliceHasResponse(com.artipie.http.hm.SliceHasResponse) RsHasBody(com.artipie.http.hm.RsHasBody) RsStatus(com.artipie.http.rs.RsStatus) Matchers(org.hamcrest.Matchers) CompletableFuture(java.util.concurrent.CompletableFuture) Content(com.artipie.asto.Content) RsHasStatus(com.artipie.http.hm.RsHasStatus) RsWithBody(com.artipie.http.rs.RsWithBody) FailedCompletionStage(com.artipie.asto.FailedCompletionStage) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.jupiter.api.Test) RequestLine(com.artipie.http.rq.RequestLine) MatcherAssert(org.hamcrest.MatcherAssert) SliceSimple(com.artipie.http.slice.SliceSimple) Optional(java.util.Optional) RequestLine(com.artipie.http.rq.RequestLine) SliceHasResponse(com.artipie.http.hm.SliceHasResponse) RsHasStatus(com.artipie.http.hm.RsHasStatus) RsHasBody(com.artipie.http.hm.RsHasBody) RsWithBody(com.artipie.http.rs.RsWithBody) Test(org.junit.jupiter.api.Test)

Example 10 with RsHasStatus

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

the class HeadProxySliceTest method passesStatusAndHeadersFromResponse.

@Test
void passesStatusAndHeadersFromResponse() {
    final RsStatus status = RsStatus.CREATED;
    final Headers.From headers = new Headers.From("abc", "123");
    MatcherAssert.assertThat(new HeadProxySlice(new SliceSimple(new RsWithHeaders(new RsWithStatus(status), headers))), new SliceHasResponse(Matchers.allOf(new RsHasStatus(status), new RsHasHeaders(headers)), new RequestLine(RqMethod.HEAD, "/")));
}
Also used : RequestLine(com.artipie.http.rq.RequestLine) SliceHasResponse(com.artipie.http.hm.SliceHasResponse) RsWithStatus(com.artipie.http.rs.RsWithStatus) RsHasStatus(com.artipie.http.hm.RsHasStatus) RsWithHeaders(com.artipie.http.rs.RsWithHeaders) RsHasHeaders(com.artipie.http.hm.RsHasHeaders) Headers(com.artipie.http.Headers) RsWithHeaders(com.artipie.http.rs.RsWithHeaders) RsStatus(com.artipie.http.rs.RsStatus) RsHasHeaders(com.artipie.http.hm.RsHasHeaders) SliceSimple(com.artipie.http.slice.SliceSimple) 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