Search in sources :

Example 1 with RsHasHeaders

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

Example 2 with RsHasHeaders

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

the class DockerRoutingSliceTest method emptyDockerRequest.

@Test
void emptyDockerRequest() {
    final String username = "alice";
    final String password = "letmein";
    MatcherAssert.assertThat(new DockerRoutingSlice(new SettingsWithAuth(new Authentication.Single(username, password)), (line, headers, body) -> {
        throw new UnsupportedOperationException();
    }), new SliceHasResponse(new AllOf<>(Arrays.asList(new RsHasStatus(RsStatus.OK), new RsHasHeaders(new Headers.From("Docker-Distribution-API-Version", "registry/2.0")))), new RequestLine(RqMethod.GET, "/v2/"), new Headers.From(new Authorization.Basic(username, password)), Content.EMPTY));
}
Also used : RsHasHeaders(com.artipie.http.hm.RsHasHeaders) RqMethod(com.artipie.http.rq.RqMethod) Settings(com.artipie.Settings) Arrays(java.util.Arrays) RqLineHasUri(com.artipie.http.hm.RqLineHasUri) YamlMapping(com.amihaiemil.eoyaml.YamlMapping) Users(com.artipie.auth.Users) SliceHasResponse(com.artipie.http.hm.SliceHasResponse) RsStatus(com.artipie.http.rs.RsStatus) CompletableFuture(java.util.concurrent.CompletableFuture) Content(com.artipie.asto.Content) RsHasStatus(com.artipie.http.hm.RsHasStatus) Layout(com.artipie.Layout) AllOf(org.hamcrest.core.AllOf) Test(org.junit.jupiter.api.Test) Authorization(com.artipie.http.headers.Authorization) RequestLine(com.artipie.http.rq.RequestLine) CompletionStage(java.util.concurrent.CompletionStage) MatcherAssert(org.hamcrest.MatcherAssert) Flowable(io.reactivex.Flowable) Storage(com.artipie.asto.Storage) AssertSlice(com.artipie.http.hm.AssertSlice) Authentication(com.artipie.http.auth.Authentication) Collections(java.util.Collections) SliceHasResponse(com.artipie.http.hm.SliceHasResponse) RsHasStatus(com.artipie.http.hm.RsHasStatus) RsHasHeaders(com.artipie.http.hm.RsHasHeaders) RsHasHeaders(com.artipie.http.hm.RsHasHeaders) Authorization(com.artipie.http.headers.Authorization) RequestLine(com.artipie.http.rq.RequestLine) Authentication(com.artipie.http.auth.Authentication) AllOf(org.hamcrest.core.AllOf) Test(org.junit.jupiter.api.Test)

Example 3 with RsHasHeaders

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

the class PromuSliceTest method producesMetrics.

@ParameterizedTest
@CsvSource({ "http.response.length,500,counter,text/plain", "http.response.length,500,counter,application/openmetrics-text", "app.used.memory,200,gauge,text/plain", "app.used.memory,200,gauge,application/openmetrics-text" })
void producesMetrics(final String name, final long value, final String type, final String mimetype) {
    final Metrics metrics = new InMemoryMetrics();
    collect(metrics, name, value, type);
    MatcherAssert.assertThat(new PromuSlice(metrics), new SliceHasResponse(new AllOf<>(Arrays.asList(new RsHasStatus(RsStatus.OK), new RsHasHeaders(new IsEqual<>(new Header(ContentType.NAME, mimetype)), new IsAnything<>()), new RsHasBody(new MatchesPattern(Pattern.compile(metricFormatted(name, value, type, mimetype))), StandardCharsets.UTF_8))), new RequestLine(RqMethod.GET, "/prometheus/metrics"), new Headers.From(Accept.NAME, mimetype), Content.EMPTY));
}
Also used : SliceHasResponse(com.artipie.http.hm.SliceHasResponse) RsHasStatus(com.artipie.http.hm.RsHasStatus) MatchesPattern(org.hamcrest.text.MatchesPattern) RsHasHeaders(com.artipie.http.hm.RsHasHeaders) RequestLine(com.artipie.http.rq.RequestLine) Metrics(com.artipie.metrics.Metrics) InMemoryMetrics(com.artipie.metrics.memory.InMemoryMetrics) InMemoryMetrics(com.artipie.metrics.memory.InMemoryMetrics) Header(com.artipie.http.headers.Header) RsHasBody(com.artipie.http.hm.RsHasBody) AllOf(org.hamcrest.core.AllOf) CsvSource(org.junit.jupiter.params.provider.CsvSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

RsHasHeaders (com.artipie.http.hm.RsHasHeaders)3 RsHasStatus (com.artipie.http.hm.RsHasStatus)3 SliceHasResponse (com.artipie.http.hm.SliceHasResponse)3 RequestLine (com.artipie.http.rq.RequestLine)3 RsStatus (com.artipie.http.rs.RsStatus)2 AllOf (org.hamcrest.core.AllOf)2 Test (org.junit.jupiter.api.Test)2 YamlMapping (com.amihaiemil.eoyaml.YamlMapping)1 Layout (com.artipie.Layout)1 Settings (com.artipie.Settings)1 Content (com.artipie.asto.Content)1 Storage (com.artipie.asto.Storage)1 Users (com.artipie.auth.Users)1 Headers (com.artipie.http.Headers)1 Authentication (com.artipie.http.auth.Authentication)1 Authorization (com.artipie.http.headers.Authorization)1 Header (com.artipie.http.headers.Header)1 AssertSlice (com.artipie.http.hm.AssertSlice)1 RqLineHasUri (com.artipie.http.hm.RqLineHasUri)1 RsHasBody (com.artipie.http.hm.RsHasBody)1