io.restassured.http.Header Java Examples

The following examples show how to use io.restassured.http.Header. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RestAssuredEdgeGridRequestSigner.java    From AkamaiOPEN-edgegrid-java with Apache License 2.0 6 votes vote down vote up
@Override
protected Request map(FilterableRequestSpecification requestSpec) {
    if (!requestSpec.getMultiPartParams().isEmpty()) {
        throw new IllegalArgumentException("multipart request is not supported");
    }

    Request.RequestBuilder builder = Request.builder()
            .method(requestSpec.getMethod())
            .uri(URI.create(requestSpec.getURI()))
            .body(serialize(requestSpec.getBody()));

    for (Header header : requestSpec.getHeaders()) {
        builder.header(header.getName(), header.getValue());
    }
    return builder.build();
}
 
Example #2
Source File: ApplicationTest.java    From prebid-server-java with Apache License 2.0 6 votes vote down vote up
@Test
public void eventHandlerShouldRespondWithTrackingPixel() throws IOException {
    final Response response = given(SPEC)
            .queryParam("t", "win")
            .queryParam("b", "bidId")
            .queryParam("a", "14062")
            .queryParam("f", "i")
            .queryParam("bidder", "bidder")
            .queryParam("ts", "1000")
            .get("/event");

    assertThat(response.getStatusCode()).isEqualTo(200);
    assertThat(response.getHeaders()).contains(new Header("content-type", "image/png"));
    assertThat(response.getBody().asByteArray())
            .isEqualTo(ResourceUtil.readByteArrayFromClassPath("static/tracking-pixel.png"));
}
 
Example #3
Source File: CorsPerServiceTest.java    From api-layer with Eclipse Public License 2.0 6 votes vote down vote up
@Test
    // Verify the header to allow CORS isn't set
    // Verify there was no call to southbound service
void givenCorsIsDelegatedToGatewayButServiceDoesntAllowCors_whenPreflightRequestArrives_thenNoAccessControlAllowOriginIsSet() throws Exception {
    applicationRegistry.setCurrentApplication(serviceWithDefaultConfiguration.getId());
    mockValid200HttpResponse();
    discoveryClient.createRefreshCacheEvent();

    given()
        .header(new Header("Origin", "https://foo.bar.org"))
        .header(new Header("Access-Control-Request-Method", "POST"))
        .header(new Header("Access-Control-Request-Headers", "origin, x-requested-with"))
    .when()
        .options(basePath + serviceWithDefaultConfiguration.getPath())
    .then()
        .statusCode(is(SC_FORBIDDEN))
        .header("Access-Control-Allow-Origin", is(nullValue()));

    verify(mockClient, never()).execute(ArgumentMatchers.any(HttpUriRequest.class));
}
 
Example #4
Source File: GatewayCorsEnabledTest.java    From api-layer with Eclipse Public License 2.0 6 votes vote down vote up
@Test
// The CORS headers are properly set on the request
void givenCorsIsAllowedForSpecificService_whenPreFlightRequestArrives_thenCorsHeadersAreSet() throws Exception {
    // Preflight request
    given()
        .header(new Header("Origin", "https://foo.bar.org"))
        .header(new Header("Access-Control-Request-Method", "POST"))
        .header(new Header("Access-Control-Request-Headers", "origin, x-requested-with"))
    .when()
        .options(basePath + "/gateway/version")
    .then()
        .statusCode(is(SC_OK))
        .header("Access-Control-Allow-Origin","https://foo.bar.org")
        .header("Access-Control-Allow-Methods", "GET,HEAD,POST,DELETE,PUT,OPTIONS")
        .header("Access-Control-Allow-Headers", "origin, x-requested-with");

    // Actual request
    given()
        .header(new Header("Origin", "https://foo.bar.org"))
    .when()
        .get(basePath + "/gateway/version")
    .then()
        .statusCode(is(SC_OK))
        .header("Access-Control-Allow-Origin", "https://foo.bar.org");
}
 
Example #5
Source File: GatewayCorsEnabledTest.java    From api-layer with Eclipse Public License 2.0 6 votes vote down vote up
@Test
void givenCorsIsEnabled_whenRequestWithOriginComes_thenOriginIsntPassedToSouthbound() throws Exception {
    // There is request to the southbound server and the CORS headers are properly set on the response
    mockValid200HttpResponseWithAddedCors();
    applicationRegistry.setCurrentApplication(serviceWithCustomConfiguration.getId());
    discoveryClient.createRefreshCacheEvent();

    // Simple request
    given()
        .header(new Header("Origin", "https://foo.bar.org"))
    .when()
        .get(basePath + serviceWithCustomConfiguration.getPath())
    .then()
        .statusCode(is(SC_OK))
        .header("Access-Control-Allow-Origin", is("https://foo.bar.org"));

    // The actual request is passed to the southbound service
    verify(mockClient, times(1)).execute(ArgumentMatchers.any(HttpUriRequest.class));

    ArgumentCaptor<HttpUriRequest> captor = ArgumentCaptor.forClass(HttpUriRequest.class);
    verify(mockClient, times(1)).execute(captor.capture());

    HttpUriRequest toVerify = captor.getValue();
    org.apache.http.Header[] originHeaders = toVerify.getHeaders("Origin");
    assertThat(originHeaders, arrayWithSize(0));
}
 
Example #6
Source File: GatewayCorsEnabledTest.java    From api-layer with Eclipse Public License 2.0 6 votes vote down vote up
@Test
// There is request to the southbound server for the request
// The CORS header is properly set.
void givenCorsIsAllowedForSpecificService_whenSimpleRequestArrives_thenCorsHeadersAreSetAndOnlyTheOnesByGateway() throws Exception {
    // There is request to the southbound server and the CORS headers are properly set on the response
    mockValid200HttpResponseWithAddedCors();
    applicationRegistry.setCurrentApplication(serviceWithCustomConfiguration.getId());
    discoveryClient.createRefreshCacheEvent();

    // Preflight request
    given()
        .header(new Header("Origin", "https://foo.bar.org"))
    .when()
        .get(basePath + serviceWithCustomConfiguration.getPath())
    .then()
        .statusCode(is(SC_OK))
        .header("Access-Control-Allow-Origin", is("https://foo.bar.org"));

    // The actual request is passed to the southbound service
    verify(mockClient, times(1)).execute(ArgumentMatchers.any(HttpUriRequest.class));
}
 
Example #7
Source File: CorsPerServiceTest.java    From api-layer with Eclipse Public License 2.0 6 votes vote down vote up
@Test
    // Verify the header to allow CORS isn't set
    // Verify there was no call to southbound service
void givenCorsIsDelegatedToGatewayButServiceDoesntAllowCors_whenSimpleCorsRequestArrives_thenNoAccessControlAllowOriginIsSet() throws Exception {
    applicationRegistry.setCurrentApplication(serviceWithDefaultConfiguration.getId());
    mockValid200HttpResponse();
    discoveryClient.createRefreshCacheEvent();

    given()
        .header(new Header("Origin", "https://foo.bar.org"))
        .header(new Header("Access-Control-Request-Method", "POST"))
        .header(new Header("Access-Control-Request-Headers", "origin, x-requested-with"))
    .when()
        .get(basePath + serviceWithDefaultConfiguration.getPath())
    .then()
        .statusCode(is(SC_FORBIDDEN))
        .header("Access-Control-Allow-Origin", is(nullValue()));

    verify(mockClient, never()).execute(ArgumentMatchers.any(HttpUriRequest.class));
}
 
Example #8
Source File: CorsPerServiceTest.java    From api-layer with Eclipse Public License 2.0 6 votes vote down vote up
@Test
    // There is request to the southbound server for the request
    // The CORS header is properly set.
void givenCorsIsAllowedForSpecificService_whenSimpleRequestArrives_thenCorsHeadersAreSet() throws Exception {
    // There is request to the southbound server and the CORS headers are properly set on the response
    mockValid200HttpResponse();
    applicationRegistry.setCurrentApplication(serviceWithCustomConfiguration.getId());
    discoveryClient.createRefreshCacheEvent();

    // Preflight request
    given()
        .header(new Header("Origin", "https://foo.bar.org"))
    .when()
        .get(basePath + serviceWithCustomConfiguration.getPath())
    .then()
        .statusCode(is(SC_OK))
        .header("Access-Control-Allow-Origin", is("https://foo.bar.org"));

    // The actual request is passed to the southbound service
    verify(mockClient, times(1)).execute(ArgumentMatchers.any(HttpUriRequest.class));
}
 
Example #9
Source File: ReusedMetricsTest.java    From microprofile-metrics with Apache License 2.0 6 votes vote down vote up
@Test
@RunAsClient
@InSequence(2)
  public void testSharedCounter() {

      Header acceptJson = new Header("Accept", APPLICATION_JSON);

      Response resp = given().header(acceptJson).get("/metrics/application");
      JsonPath filteredJSONPath = new JsonPath(resp.jsonPath().prettify().replaceAll(JSON_APP_LABEL_REGEX, JSON_APP_LABEL_REGEXS_SUB));
      ResponseBuilder responseBuilder = new ResponseBuilder();
      responseBuilder.clone(resp);
      responseBuilder.setBody(filteredJSONPath.prettify());
      resp = responseBuilder.build();

      resp.then()
              .assertThat().body("'countMe2;tier=integration'", equalTo(1))
              .assertThat().body("'org.eclipse.microprofile.metrics.test.MetricAppBean2.meterMe2'.'count;tier=integration'", equalTo(1))
              .assertThat().body("'timeMe2'.'count;tier=integration'", equalTo(1))
              .assertThat().body("'simplyTimeMe2'.'count;tier=integration'", equalTo(1));

}
 
Example #10
Source File: MpMetricTest.java    From microprofile-metrics with Apache License 2.0 6 votes vote down vote up
@Test
@RunAsClient
@InSequence(4)
public void testListsAllJson() {
    Assume.assumeFalse(Boolean.getBoolean("skip.base.metric.tests"));
    Header acceptHeader = new Header("Accept", APPLICATION_JSON);

    Map response = given().header(acceptHeader).when().get("/metrics").as(Map.class);

    // all servers should have some base metrics
    assertTrue(response.containsKey("base"));

    // There may be application metrics, so check if the key exists and bail if it has no data
    if (response.containsKey("application")) {
      Map applicationData = (Map) response.get("application");
      assertThat(applicationData.size(), greaterThan(0));
    }
}
 
Example #11
Source File: MpMetricTest.java    From microprofile-metrics with Apache License 2.0 6 votes vote down vote up
@Test
@RunAsClient
@InSequence(11)
public void testBaseMetadataSingluarItems() {
    Assume.assumeFalse(Boolean.getBoolean("skip.base.metric.tests"));
    Header wantJson = new Header("Accept", APPLICATION_JSON);

    JsonPath jsonPath = given().header(wantJson).options("/metrics/base").jsonPath();

    Map<String, Object> elements = jsonPath.getMap(".");
    List<String> missing = new ArrayList<>();

    Map<String, MiniMeta> baseNames = getExpectedMetadataFromXmlFile(MetricRegistry.Type.BASE);
    for (String item : baseNames.keySet()) {
        if (item.startsWith("gc.") || baseNames.get(item).optional) {
            continue;
        }
        if (!elements.containsKey(item)) {
            missing.add(item);
        }
    }

    assertTrue("Following base items are missing: " + Arrays.toString(missing.toArray()), missing.isEmpty());
}
 
Example #12
Source File: MpMetricTest.java    From microprofile-metrics with Apache License 2.0 6 votes vote down vote up
@Test
@RunAsClient
@InSequence(13)
public void testOpenMetricsFormatNoBadChars() {
    Assume.assumeFalse(Boolean.getBoolean("skip.base.metric.tests"));
    Header wantOpenMetricsFormat = new Header("Accept", TEXT_PLAIN);

    String data = given().header(wantOpenMetricsFormat).get("/metrics/base").asString();

    String[] lines = data.split("\n");
    for (String line : lines) {
        if (line.startsWith("#")) {
            continue;
        }
        String nameAndTagsPart = line.substring(0, line.lastIndexOf(" "));
        String namePart = nameAndTagsPart.contains("{") ?
            nameAndTagsPart.substring(0, nameAndTagsPart.lastIndexOf("{")) : nameAndTagsPart;
        assertFalse("Name has illegal chars " + line, namePart.matches(".*[-.].*"));
        assertFalse("Found __ in " + line, line.matches(".*__.*"));
    }
}
 
Example #13
Source File: MpMetricTest.java    From microprofile-metrics with Apache License 2.0 6 votes vote down vote up
@Test
@RunAsClient
@InSequence(15)
public void testBaseMetadataGarbageCollection() {
    Assume.assumeFalse(Boolean.getBoolean("skip.base.metric.tests"));
    Header wantJson = new Header("Accept", APPLICATION_JSON);

    JsonPath jsonPath = given().header(wantJson).options("/metrics/base").jsonPath();

    int count = 0;
    Map<String, Object> elements = jsonPath.getMap(".");
    for (String name : elements.keySet()) {
        if (name.startsWith("gc.")) {
            assertTrue(name.endsWith(".total") || name.endsWith(".time"));
            count++;
        }
    }
    assertThat(count, greaterThan(0));
}
 
Example #14
Source File: MpMetricTest.java    From microprofile-metrics with Apache License 2.0 6 votes vote down vote up
@Test
@RunAsClient
@InSequence(19)
public void testApplicationMetadataItems() {
    Header wantJson = new Header("Accept", APPLICATION_JSON);

    JsonPath jsonPath = given().header(wantJson).options("/metrics/application").jsonPath();

    Map<String, Object> elements = jsonPath.getMap(".");
    
    List<String> missing = new ArrayList<>();

    Map<String, MiniMeta> names = getExpectedMetadataFromXmlFile(MetricRegistry.Type.APPLICATION);
    for (String item : names.keySet()) {
        if (!elements.containsKey(item)) {
            missing.add(item);
        }
    }
    assertTrue("Following application items are missing: " + Arrays.toString(missing.toArray()), missing.isEmpty());
}
 
Example #15
Source File: MpMetricTest.java    From microprofile-metrics with Apache License 2.0 6 votes vote down vote up
@Test
@RunAsClient
@InSequence(31)
public void testOptionalBaseMetrics() {
    Assume.assumeFalse(Boolean.getBoolean("skip.base.metric.tests"));
    Header wantJson = new Header("Accept", APPLICATION_JSON);

    JsonPath jsonPath = given().header(wantJson).options("/metrics/base").jsonPath();

    Map<String, Object> elements = jsonPath.getMap(".");
    Map<String, MiniMeta> names = getExpectedMetadataFromXmlFile(MetricRegistry.Type.BASE);

    for (MiniMeta item : names.values()) {
        if (elements.containsKey(item.toJSONName()) && names.get(item.name).optional) {
            String prefix = names.get(item.name).name;
            String type = "'"+item.toJSONName()+"'"+".type";
            String unit= "'"+item.toJSONName()+"'"+".unit";

            given().header(wantJson).options("/metrics/base/"+prefix).then().statusCode(200)
            .body(type, equalTo(names.get(item.name).type))
            .body(unit, equalTo(names.get(item.name).unit));
        }
    }

}
 
Example #16
Source File: MpMetricTest.java    From microprofile-metrics with Apache License 2.0 6 votes vote down vote up
/**
 * Test that semicolons `;` in tag values are translated to underscores `_`
 * in the JSON output
 */
@Test
@RunAsClient
@InSequence(46)
public void testTranslateSemiColonToUnderScoreJSON() {
    Header wantJson = new Header("Accept", APPLICATION_JSON);
    Response resp = given().header(wantJson).get("/metrics/application");
    JsonPath filteredJSONPath = new JsonPath(filterOutAppLabelJSON(resp.jsonPath().prettify()));
    ResponseBuilder responseBuilder = new ResponseBuilder();
    responseBuilder.clone(resp);
    responseBuilder.setBody(filteredJSONPath.prettify());
    resp = responseBuilder.build();
    
    resp.then().statusCode(200)
        .body("'org.eclipse.microprofile.metrics.test.MetricAppBean.semiColonTaggedCounter;"
                + "scTag=semi_colons_are_bad;tier=integration'", equalTo(0));
}
 
Example #17
Source File: PlaceholderHandlerTest.java    From heat with Apache License 2.0 6 votes vote down vote up
private Response buildResponse() {
    ResponseBuilder rspBuilder = new ResponseBuilder();
    rspBuilder.setStatusCode(200);
    rspBuilder.setBody("{\"field_path\":\"field_value\",\"array1\":[{\"array_field1\":\"array_field_value1\"}]}");

    List<Header> headerList = new ArrayList();
    Header header1 = new Header("test_header", "test_value");
    Header header2 = new Header("test_header2", "test_value2");
    headerList.add(header1);
    headerList.add(header2);
    Headers headers = new Headers(headerList);
    rspBuilder.setHeaders(headers);

    List<Cookie> cookieList = new ArrayList();
    Cookie cookie1 = new Cookie.Builder("test_cookie", "test_value").build();
    Cookie cookie2 = new Cookie.Builder("test_cookie2", "test_value2").build();
    cookieList.add(cookie1);
    cookieList.add(cookie2);
    Cookies cookies = new Cookies(cookieList);
    rspBuilder.setCookies(cookies);

    return rspBuilder.build();
}
 
Example #18
Source File: ReusedMetricsTest.java    From microprofile-metrics with Apache License 2.0 6 votes vote down vote up
@Test
@RunAsClient
@InSequence(4)
public void testSharedCounterAgain() {

  Header acceptJson = new Header("Accept", APPLICATION_JSON);

  Response resp = given().header(acceptJson).get("/metrics/application");
  JsonPath filteredJSONPath = new JsonPath(resp.jsonPath().prettify().replaceAll(JSON_APP_LABEL_REGEX, JSON_APP_LABEL_REGEXS_SUB));
  ResponseBuilder responseBuilder = new ResponseBuilder();
  responseBuilder.clone(resp);
  responseBuilder.setBody(filteredJSONPath.prettify());
  resp = responseBuilder.build();

  resp.then()
  .assertThat().body("'countMe2;tier=integration'", equalTo(2))
  .assertThat().body("'org.eclipse.microprofile.metrics.test.MetricAppBean2.meterMe2'.'count;tier=integration'", equalTo(2))
  .assertThat().body("'timeMe2'.'count;tier=integration'", equalTo(2))
  .assertThat().body("'simplyTimeMe2'.'count;tier=integration'", equalTo(2));


}
 
Example #19
Source File: MpMetricTest.java    From microprofile-metrics with Apache License 2.0 6 votes vote down vote up
@Test
@RunAsClient
@InSequence(7)
public void testBaseAttributeJson() {
    Assume.assumeFalse(Boolean.getBoolean("skip.base.metric.tests"));
    Header wantJson = new Header("Accept", APPLICATION_JSON);
    
    Response resp = given().header(wantJson).get("/metrics/base/thread.max.count");
    JsonPath filteredJSONPath = new JsonPath(filterOutAppLabelJSON(resp.jsonPath().prettify()));
    ResponseBuilder responseBuilder = new ResponseBuilder();
    responseBuilder.clone(resp);
    responseBuilder.setBody(filteredJSONPath.prettify());
    resp = responseBuilder.build();
    resp.then().statusCode(200).and()
            .contentType(MpMetricTest.APPLICATION_JSON).and().body(containsString("thread.max.count;tier=integration"));
}
 
Example #20
Source File: RestAssuredRamlMessage.java    From raml-tester with Apache License 2.0 5 votes vote down vote up
protected Values headersToValues(Headers headers) {
    final Values headerValues = new Values();
    for (final Header header : headers) {
        headerValues.addValue(header.getName(), header.getValue());
    }
    return headerValues;
}
 
Example #21
Source File: MpMetricTest.java    From microprofile-metrics with Apache License 2.0 5 votes vote down vote up
@Test
@RunAsClient
@InSequence(29)
public void testNonStandardUnitsJSON() {

    Header wantJSONFormat = new Header("Accept", APPLICATION_JSON);
    
    given().header(wantJSONFormat).options("/metrics/application/jellybeanHistogram").then().statusCode(200)
     .body("jellybeanHistogram.unit", equalTo("jellybeans"));

}
 
Example #22
Source File: MpMetricTest.java    From microprofile-metrics with Apache License 2.0 5 votes vote down vote up
@Test
@RunAsClient
@InSequence(12)
public void testBaseMetadataTypeAndUnit() {
    Assume.assumeFalse(Boolean.getBoolean("skip.base.metric.tests"));
    Header wantJson = new Header("Accept", APPLICATION_JSON);

    JsonPath jsonPath = given().header(wantJson).options("/metrics/base").jsonPath();

    Map<String, Map<String, Object>> elements = jsonPath.getMap(".");

    Map<String, MiniMeta> expectedMetadata = getExpectedMetadataFromXmlFile(MetricRegistry.Type.BASE);
          checkMetadataPresent(elements, expectedMetadata);

}
 
Example #23
Source File: RequestLoggerFilterTest.java    From swagger-coverage with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldCatchExceptionRestAssuredIssue1232() {
    RestAssured.given().filter(new SwaggerCoverageRestAssured())
            .multiPart("file", "{}")
            .header(new Header("X-Request-ID", "h"))
            .formParam("form_param", "f", "f2")
            .queryParam("query_param", "q", "q2")
            .pathParam("path_param", "p")
            .get(mock.url("/hello/{path_param}"));
}
 
Example #24
Source File: CorsPerServiceTest.java    From api-layer with Eclipse Public License 2.0 5 votes vote down vote up
@Test
    // There is no request to the southbound server for preflight
    // There is request to the southbound server for the second request
void givenCorsIsAllowedForSpecificService_whenPreFlightRequestArrives_thenCorsHeadersAreSet() throws Exception {
    mockValid200HttpResponse();
    applicationRegistry.setCurrentApplication(serviceWithCustomConfiguration.getId());
    discoveryClient.createRefreshCacheEvent();
    // Preflight request
    given()
        .header(new Header("Origin", "https://foo.bar.org"))
        .header(new Header("Access-Control-Request-Method", "POST"))
        .header(new Header("Access-Control-Request-Headers", "origin, x-requested-with"))
    .when()
        .options(basePath + serviceWithCustomConfiguration.getPath())
    .then()
        .statusCode(is(SC_OK))
        .header("Access-Control-Allow-Origin", is("https://foo.bar.org"))
        .header("Access-Control-Allow-Methods", is("GET,HEAD,POST,DELETE,PUT,OPTIONS"))
        .header("Access-Control-Allow-Headers", is("origin, x-requested-with"));

    // The preflight request isn't passed to the southbound service
    verify(mockClient, never()).execute(ArgumentMatchers.any(HttpUriRequest.class));

    // Actual request
    given()
        .header(new Header("Origin", "https://foo.bar.org"))
    .when()
        .post(basePath + serviceWithCustomConfiguration.getPath())
    .then()
        .statusCode(is(SC_OK))
        .header("Access-Control-Allow-Origin", is("https://foo.bar.org"));

    // The actual request is passed to the southbound service
    verify(mockClient, times(1)).execute(ArgumentMatchers.any(HttpUriRequest.class));
}
 
Example #25
Source File: RequestVerifierFilter.java    From spring-cloud-netflix with Apache License 2.0 5 votes vote down vote up
@Override
public Set<String> getAllHeaderKeys() {
	Set<String> headers = new LinkedHashSet<>();
	for (Header header : request.getHeaders()) {
		String value = header.getValue();
		if ("accept".equals(header.getName().toLowerCase()) && "*/*".equals(value)) {
			continue;
		}
		headers.add(header.getName());
	}
	return headers;
}
 
Example #26
Source File: MpMetricTest.java    From microprofile-metrics with Apache License 2.0 5 votes vote down vote up
@Test
@RunAsClient
@InSequence(16)
public void testApplicationMetadataOkJson() {
    Header wantJson = new Header("Accept", APPLICATION_JSON);

    Response response = given().header(wantJson).options("/metrics/application");
    int code = response.getStatusCode();

    assertTrue(code == 200 || code == 204);

}
 
Example #27
Source File: GatewaySpecificEndpointsCorsDisabledTest.java    From api-layer with Eclipse Public License 2.0 5 votes vote down vote up
@Test
// Verify the header to allow CORS isn't set
void givenDefaultConfiguration_whenPreflightRequestArrives_thenNoAccessControlAllowOriginIsSet() {
    given()
        .header(new Header("Origin", "https://foo.bar.org"))
        .header(new Header("Access-Control-Request-Method", "POST"))
        .header(new Header("Access-Control-Request-Headers", "origin, x-requested-with"))
    .when()
        .options(basePath + "/api/v1/gateway/auth/login")
    .then()
        .statusCode(is(SC_FORBIDDEN))
        .header("Access-Control-Allow-Origin", is(nullValue()));
}
 
Example #28
Source File: MpMetricTest.java    From microprofile-metrics with Apache License 2.0 5 votes vote down vote up
@Test
@RunAsClient
@InSequence(20)
public void testApplicationMetadataTypeAndUnit() {
    Header wantJson = new Header("Accept", APPLICATION_JSON);

    JsonPath jsonPath = given().header(wantJson).options("/metrics/application").jsonPath();

    Map<String, Map<String, Object>> elements = jsonPath.getMap(".");

    Map<String, MiniMeta> expectedMetadata = getExpectedMetadataFromXmlFile(MetricRegistry.Type.APPLICATION);
    checkMetadataPresent(elements, expectedMetadata);

}
 
Example #29
Source File: MpMetricTest.java    From microprofile-metrics with Apache License 2.0 5 votes vote down vote up
@Test
@RunAsClient
@InSequence(28)
public void testConvertingToBaseUnit() {
    Header wantOpenMetricsFormat = new Header("Accept", TEXT_PLAIN);
    given().header(wantOpenMetricsFormat).get("/metrics/application").then().statusCode(200)
    .and().body(containsString(
        "TYPE application_org_eclipse_microprofile_metrics_test_MetricAppBean_gaugeMeA_bytes gauge"))
    .and().body(containsString("TYPE application_metricTest_test1_gauge_bytes gauge"));


}
 
Example #30
Source File: GatewaySpecificEndpointsCorsDisabledTest.java    From api-layer with Eclipse Public License 2.0 5 votes vote down vote up
@Test
// Verify the header to allow CORS isn't set
void givenDefaultConfiguration_whenSimpleCorsRequestArrives_thenNoAccessControlAllowOriginIsSet() {
    given()
        .header(new Header("Origin", "https://foo.bar.org"))
        .header(new Header("Access-Control-Request-Method", "POST"))
        .header(new Header("Access-Control-Request-Headers", "origin, x-requested-with"))
    .when()
        .get(basePath + "/gateway/version")
    .then()
        .statusCode(is(SC_FORBIDDEN))
        .header("Access-Control-Allow-Origin", is(nullValue()));
}