use of com.github.tomakehurst.wiremock.matching.MultipartValuePatternBuilder in project spring-bot by finos.
the class TestOboCall method setupWireMock.
@BeforeEach
public void setupWireMock() {
// session auth / cert login
wireMockRule.stubFor(post(urlEqualTo("/sessionauth/v1/app/authenticate")).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody("{\"name\": \"some-app-token\", \"token\": \"" + APP_TOKEN + "\"}")));
wireMockRule.stubFor(post(urlEqualTo("/sessionauth/v1/app/user/1234/authenticate")).withHeader("sessionToken", new EqualToPattern(APP_TOKEN)).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody("{\"sessionToken\": \"" + OBO_TOKEN + "\"}")));
// rsa auth
wireMockRule.stubFor(post(urlEqualTo("/login/pubkey/authenticate")).withRequestBody(new RegexPattern("\\{\"token\":\".*}")).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody("{\"name\": \"some-app-token\", \"token\": \"" + APP_TOKEN + "\"}")));
wireMockRule.stubFor(post(urlEqualTo("/login/pubkey/app/user/1234/authenticate")).withHeader("sessionToken", new EqualToPattern(APP_TOKEN)).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody("{\"token\": \"" + OBO_TOKEN + "\"}")));
// sending the blast message
wireMockRule.stubFor(post(urlEqualTo("/agent/v4/message/blast")).withMultipartRequestBody(new MultipartValuePatternBuilder("sids").withBody(new EqualToPattern(STREAM_IDS))).withMultipartRequestBody(new MultipartValuePatternBuilder("message").withBody(new EqualToPattern(MESSAGE_CONTENT))).withHeader("sessionToken", new EqualToPattern(OBO_TOKEN)).willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(200)));
wireMockRule.start();
}
use of com.github.tomakehurst.wiremock.matching.MultipartValuePatternBuilder in project junit-servers by mjeanroy.
the class WireMockTestUtils method assertUploadRequest.
/**
* Verify that a given request has been triggered.
*
* @param endpoint Request endpoint.
* @param method Request method.
*/
static void assertUploadRequest(String endpoint, HttpMethod method, File file) {
UrlPattern urlPattern = urlEqualTo(endpoint);
RequestMethod rqMethod = new RequestMethod(method.name());
RequestPatternBuilder rq = new RequestPatternBuilder(rqMethod, urlPattern).withAllRequestBodyParts(new MultipartValuePatternBuilder().withName(file.getName()).withBody(new BinaryEqualToPattern(TestUtils.readFile(file))));
WireMock.verify(1, rq);
}
Aggregations