use of io.swagger.models.auth.AuthorizationValue in project swagger-parser by swagger-api.
the class RemoteUrlTest method testHostHeader.
@Test
public void testHostHeader() throws Exception {
final String expectedBody = setupStub();
final String headerName = "Authorization";
final String headerValue = "foobar";
final AuthorizationValue authorizationValue = new HostAuthorizationValue(LOCALHOST, headerName, headerValue, "header");
final String actualBody = RemoteUrl.urlToString(getUrl(), Arrays.asList(authorizationValue));
assertEquals(actualBody, expectedBody);
verify(getRequestedFor(urlEqualTo("/v2/pet/1")).withHeader("Accept", equalTo(EXPECTED_ACCEPTS_HEADER)).withHeader(headerName, equalTo(headerValue)));
}
use of io.swagger.models.auth.AuthorizationValue in project swagger-parser by swagger-api.
the class RemoteUrlTest method testAppendQueryParam.
@Test
public void testAppendQueryParam() throws Exception {
final String firstParamName = "first";
final String firstParamValue = "first-value";
final String queryParamName = "Authorization";
final String queryParamValue = "foobar";
final String expectedBody = "a really good body";
stubFor(get(urlPathEqualTo("/v2/pet/1")).withQueryParam(firstParamName, equalTo(firstParamValue)).withQueryParam(queryParamName, equalTo(queryParamValue)).willReturn(aResponse().withBody(expectedBody).withHeader("Content-Type", "application/json")));
final AuthorizationValue authorizationValue = new HostAuthorizationValue(LOCALHOST, queryParamName, queryParamValue, "query");
final String actualBody = RemoteUrl.urlToString(String.format("%s?%s=%s", getUrl(), firstParamName, firstParamValue), Arrays.asList(authorizationValue));
assertEquals(actualBody, expectedBody);
verify(getRequestedFor(urlPathEqualTo("/v2/pet/1")).withHeader("Accept", equalTo(EXPECTED_ACCEPTS_HEADER)).withQueryParam(firstParamName, equalTo(firstParamValue)).withQueryParam(queryParamName, equalTo(queryParamValue)));
}
use of io.swagger.models.auth.AuthorizationValue in project swagger-parser by swagger-api.
the class RemoteUrlTest method testSkippedQueryParam.
@Test
public void testSkippedQueryParam() throws Exception {
final String queryParamName = "Authorization";
final String queryParamValue = "foobar";
final String expectedBody = "a really good body";
stubFor(get(urlPathEqualTo("/v2/pet/1")).willReturn(aResponse().withBody(expectedBody).withHeader("Content-Type", "application/json")));
final AuthorizationValue authorizationValue = new HostAuthorizationValue(SOME_HOST, queryParamName, queryParamValue, "query");
final String actualBody = RemoteUrl.urlToString(getUrl(), Arrays.asList(authorizationValue));
assertEquals(actualBody, expectedBody);
verify(getRequestedFor(urlPathEqualTo("/v2/pet/1")).withHeader("Accept", equalTo(EXPECTED_ACCEPTS_HEADER)).withoutHeader(queryParamName));
}
Aggregations