use of com.github.tomakehurst.wiremock.matching.RegexPattern in project mod-kb-ebsco-java by folio-org.
the class EHoldingsProxyTypesImplTest method shouldReturn403WhenRMAPIRequestCompletesWith403ErrorStatus.
@Test
public void shouldReturn403WhenRMAPIRequestCompletesWith403ErrorStatus() {
saveKbCredentials(STUB_CREDENTIALS_ID, getWiremockUrl(), STUB_CREDENTIALS_NAME, STUB_API_KEY, STUB_CUSTOMER_ID, vertx);
saveAssignedUser(JOHN_ID, STUB_CREDENTIALS_ID, vertx);
mockGet(new RegexPattern(RMAPI_PROXIES_URL), SC_FORBIDDEN);
final JsonapiError error = getWithStatus(EHOLDINGS_PROXY_TYPES_URL, SC_FORBIDDEN, JOHN_TOKEN_HEADER).as(JsonapiError.class);
assertErrorContainsTitle(error, "Unauthorized");
}
use of com.github.tomakehurst.wiremock.matching.RegexPattern in project mod-kb-ebsco-java by folio-org.
the class EHoldingsProxyTypesImplTest method shouldReturnEmptyProxyTypesFromEmptyRMApiResponse.
@Test
public void shouldReturnEmptyProxyTypesFromEmptyRMApiResponse() throws IOException, URISyntaxException, JSONException {
saveKbCredentials(STUB_CREDENTIALS_ID, getWiremockUrl(), STUB_CREDENTIALS_NAME, STUB_API_KEY, STUB_CUSTOMER_ID, vertx);
saveAssignedUser(JOHN_ID, STUB_CREDENTIALS_ID, vertx);
mockGet(new RegexPattern(RMAPI_PROXIES_URL), "responses/rmapi/proxytypes/get-proxy-types-empty-response.json");
String actual = getWithStatus(EHOLDINGS_PROXY_TYPES_URL, SC_OK, JOHN_TOKEN_HEADER).asString();
String expected = readFile("responses/kb-ebsco/proxytypes/get-proxy-types-empty-response.json");
JSONAssert.assertEquals(expected, actual, true);
}
use of com.github.tomakehurst.wiremock.matching.RegexPattern in project mod-kb-ebsco-java by folio-org.
the class EHoldingsRootProxyImplTest method shouldReturnRootProxyWhenOneCredentialsExistsAndUserNotAssigned.
@Test
public void shouldReturnRootProxyWhenOneCredentialsExistsAndUserNotAssigned() throws IOException, URISyntaxException, JSONException {
saveKbCredentials(STUB_CREDENTIALS_ID, getWiremockUrl(), STUB_CREDENTIALS_NAME, STUB_API_KEY, STUB_CUSTOMER_ID, vertx);
mockGet(new RegexPattern(RMAPI_ROOT_PROXY_CUSTOM_LABELS_URL), RMAPI_ROOT_PROXY_CUSTOM_LABELS_RESPONSE);
String actual = getWithStatus(EHOLDINGS_ROOT_PROXY_URL, SC_OK, JOHN_TOKEN_HEADER).asString();
String expected = readFile(KB_EBSCO_GET_ROOT_PROXY_RESPONSE);
JSONAssert.assertEquals(expected, actual, true);
}
use of com.github.tomakehurst.wiremock.matching.RegexPattern in project mod-kb-ebsco-java by folio-org.
the class EHoldingsRootProxyImplTest method shouldReturn403WhenRMAPIReturns403.
@Test
public void shouldReturn403WhenRMAPIReturns403() {
saveKbCredentials(STUB_CREDENTIALS_ID, getWiremockUrl(), STUB_CREDENTIALS_NAME, STUB_API_KEY, STUB_CUSTOMER_ID, vertx);
mockGet(new RegexPattern(RMAPI_ROOT_PROXY_CUSTOM_LABELS_URL), SC_FORBIDDEN);
final String path = String.format(EHOLDINGS_ROOT_PROXY_BY_CREDENTIALS_ID_URL, STUB_CREDENTIALS_ID);
final JsonapiError error = getWithStatus(path, SC_FORBIDDEN, JOHN_TOKEN_HEADER).as(JsonapiError.class);
assertErrorContainsTitle(error, "Unauthorized");
}
use of com.github.tomakehurst.wiremock.matching.RegexPattern in project mod-kb-ebsco-java by folio-org.
the class EHoldingsRootProxyImplTest method shouldReturn401WhenRMAPIReturns401.
@Test
public void shouldReturn401WhenRMAPIReturns401() {
saveKbCredentials(STUB_CREDENTIALS_ID, getWiremockUrl(), STUB_CREDENTIALS_NAME, STUB_API_KEY, STUB_CUSTOMER_ID, vertx);
mockGet(new RegexPattern(RMAPI_ROOT_PROXY_CUSTOM_LABELS_URL), SC_UNAUTHORIZED);
final String path = String.format(EHOLDINGS_ROOT_PROXY_BY_CREDENTIALS_ID_URL, STUB_CREDENTIALS_ID);
final JsonapiError error = getWithStatus(path, SC_UNAUTHORIZED, JOHN_TOKEN_HEADER).as(JsonapiError.class);
assertErrorContainsTitle(error, "Unauthorized Access");
}
Aggregations