use of com.github.tomakehurst.wiremock.matching.RequestPatternBuilder in project box-java-sdk by box.
the class BoxAPIRequestTest method requestSendsXBoxUAHeader.
@Test
public void requestSendsXBoxUAHeader() throws MalformedURLException {
stubFor(get(urlEqualTo("/")).willReturn(aResponse().withStatus(200)));
BoxAPIConnection api = new BoxAPIConnection("");
BoxAPIRequest request = new BoxAPIRequest(api, boxMockUrl(), "GET");
request.send();
String headerRegex = "agent=box-java-sdk/\\d\\.\\d+\\.\\d+(-[a-zA-Z]+)?; env=Java/\\d+\\.\\d+\\.\\d+.*";
RequestPatternBuilder requestPatternBuilder = RequestPatternBuilder.newRequestPattern().withHeader("X-Box-UA", matching(headerRegex));
verify(requestPatternBuilder);
}
use of com.github.tomakehurst.wiremock.matching.RequestPatternBuilder in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class WebhookActionInvokerTest method testBearerToken.
@Test
void testBearerToken() throws InterruptedException {
wireMockServer.stubFor(post(urlEqualTo(TEST_WEBHOOK_PATH)).willReturn(aResponse().withStatus(200)));
CountDownLatch latch = new CountDownLatch(1);
addUpdateRequestListener(TEST_WEBHOOK_PATH, RequestMethod.POST, latch);
String testSinkEndpoint = webhookSinkUrl + TEST_WEBHOOK_PATH;
AbstractOidcClient abstractOidcClient = mock(AbstractOidcClient.class);
when(abstractOidcClient.getToken()).thenReturn("token");
WebhookActionInvoker invoker = new WebhookActionInvoker(testSinkEndpoint, WebClient.create(vertx), abstractOidcClient);
invoker.onEvent(TEST_EVENT, TEST_HEADERS);
assertThat(latch.await(30, TimeUnit.SECONDS)).isTrue();
RequestPatternBuilder requestPatternBuilder = postRequestedFor(urlEqualTo(TEST_WEBHOOK_PATH)).withRequestBody(equalToJson(TEST_EVENT, true, true)).withHeader("Content-Type", equalTo("application/json")).withHeader("Authorization", equalTo("Bearer token"));
for (Map.Entry<String, String> testHeader : TEST_HEADERS.entrySet()) {
requestPatternBuilder = requestPatternBuilder.withHeader("x-" + testHeader.getKey(), equalTo(testHeader.getValue()));
}
wireMockServer.verify(requestPatternBuilder);
}
use of com.github.tomakehurst.wiremock.matching.RequestPatternBuilder in project sda-dropwizard-commons by SDA-SE.
the class OpaClassExtension method verify.
@Override
void verify(int count, StubBuilder builder) {
RequestPatternBuilder requestPattern = buildRequestPattern(builder);
wireMockExtension.verify(count, requestPattern);
}
use of com.github.tomakehurst.wiremock.matching.RequestPatternBuilder in project junit-servers by mjeanroy.
the class WireMockTestUtils method assertRequestWithBody.
/**
* Verify that a given request has been triggered.
*
* @param endpoint Request endpoint.
* @param method Request method.
* @param body Request body.
*/
static void assertRequestWithBody(String endpoint, HttpMethod method, String body) {
UrlPattern urlPattern = urlEqualTo(endpoint);
RequestMethod rqMethod = new RequestMethod(method.name());
RequestPatternBuilder rq = new RequestPatternBuilder(rqMethod, urlPattern);
rq.withRequestBody(equalTo(body));
WireMock.verify(1, rq);
}
use of com.github.tomakehurst.wiremock.matching.RequestPatternBuilder in project junit-servers by mjeanroy.
the class WireMockTestUtils method assertRequestWithCookies.
/**
* Verify that a given request has been triggered.
*
* @param endpoint Request endpoint.
* @param method Request method.
* @param cookies Cookies sent in HTTP request.
*/
static void assertRequestWithCookies(String endpoint, HttpMethod method, Iterable<Pair> cookies) {
UrlPattern urlPattern = urlEqualTo(endpoint);
RequestMethod rqMethod = new RequestMethod(method.name());
RequestPatternBuilder rq = new RequestPatternBuilder(rqMethod, urlPattern);
for (Pair cookie : cookies) {
String cookieName = cookie.getO1();
String cookieValue = cookie.getO2().get(0);
rq.withCookie(cookieName, equalTo(cookieValue));
}
WireMock.verify(1, rq);
}
Aggregations