use of ee.ria.xroad.common.metadata.MetadataRequests.GET_WSDL in project X-Road by nordic-institute.
the class MetadataServiceHandlerTest method shouldThrowUnknownServiceWhenWsdlUrlNotFound.
@Test
public void shouldThrowUnknownServiceWhenWsdlUrlNotFound() throws Exception {
final ServiceId serviceId = ServiceId.create(DEFAULT_CLIENT, GET_WSDL);
final ServiceId requestingWsdlForService = ServiceId.create(DEFAULT_CLIENT, "someServiceWithoutWsdl");
MetadataServiceHandlerImpl handlerToTest = new MetadataServiceHandlerImpl();
WsdlRequestData wsdlRequestData = new WsdlRequestData();
wsdlRequestData.setServiceCode(requestingWsdlForService.getServiceCode());
InputStream soapContentInputStream = new TestSoapBuilder().withClient(DEFAULT_CLIENT).withService(serviceId).withModifiedBody(soapBody -> marshaller.marshal(wsdlRequestData, soapBody)).buildAsInputStream();
when(mockProxyMessage.getSoapContent()).thenReturn(soapContentInputStream);
handlerToTest.canHandle(serviceId, mockProxyMessage);
thrown.expect(CodedException.class);
thrown.expect(faultCodeEquals(X_UNKNOWN_SERVICE));
thrown.expectMessage(containsString("Could not find wsdl URL for service"));
// execution, should throw..
handlerToTest.startHandling(mockRequest, mockProxyMessage, httpClientMock, mock(OpMonitoringData.class));
}
use of ee.ria.xroad.common.metadata.MetadataRequests.GET_WSDL in project X-Road by nordic-institute.
the class MetadataServiceHandlerTest method shouldThrowWhenMissingServiceCodeInWsdlRequestBody.
@Test
public void shouldThrowWhenMissingServiceCodeInWsdlRequestBody() throws Exception {
final ServiceId serviceId = ServiceId.create(DEFAULT_CLIENT, GET_WSDL);
MetadataServiceHandlerImpl handlerToTest = new MetadataServiceHandlerImpl();
InputStream soapContentInputStream = new TestSoapBuilder().withClient(DEFAULT_CLIENT).withService(serviceId).withModifiedBody(soapBody -> soapBody.addChildElement(GET_WSDL_REQUEST).addChildElement(REQUEST)).buildAsInputStream();
when(mockProxyMessage.getSoapContent()).thenReturn(soapContentInputStream);
handlerToTest.canHandle(serviceId, mockProxyMessage);
thrown.expect(CodedException.class);
thrown.expect(faultCodeEquals(ErrorCodes.X_INVALID_REQUEST));
thrown.expectMessage(containsString("Missing serviceCode in message body"));
// execution, should throw..
handlerToTest.startHandling(mockRequest, mockProxyMessage, httpClientMock, mock(OpMonitoringData.class));
}
use of ee.ria.xroad.common.metadata.MetadataRequests.GET_WSDL in project X-Road by nordic-institute.
the class MetadataServiceHandlerTest method shouldBeAbleToHandleGetWsdl.
@Test
public void shouldBeAbleToHandleGetWsdl() throws Exception {
// setup
MetadataServiceHandlerImpl handlerToTest = new MetadataServiceHandlerImpl();
ServiceId serviceId = ServiceId.create(DEFAULT_CLIENT, GET_WSDL);
InputStream soapContentInputStream = new TestSoapBuilder().withClient(DEFAULT_CLIENT).withService(serviceId).withModifiedBody(soapBody -> soapBody.addChildElement(GET_WSDL_REQUEST).addChildElement(REQUEST)).buildAsInputStream();
when(mockProxyMessage.getSoapContent()).thenReturn(soapContentInputStream);
// execution & verification
assertTrue("Wasn't able to handle get wsdl", handlerToTest.canHandle(serviceId, mockProxyMessage));
}
use of ee.ria.xroad.common.metadata.MetadataRequests.GET_WSDL in project X-Road by nordic-institute.
the class MetadataServiceHandlerTest method shouldThrowRuntimeExWhenWsdlUrlNotOk200.
@Test
public void shouldThrowRuntimeExWhenWsdlUrlNotOk200() throws Exception {
final ServiceId serviceId = ServiceId.create(DEFAULT_CLIENT, GET_WSDL);
final ServiceId requestingWsdlForService = ServiceId.create(DEFAULT_CLIENT, "someServiceWithWsdl122");
MetadataServiceHandlerImpl handlerToTest = new MetadataServiceHandlerImpl();
WsdlRequestData wsdlRequestData = new WsdlRequestData();
wsdlRequestData.setServiceCode(requestingWsdlForService.getServiceCode());
InputStream soapContentInputStream = new TestSoapBuilder().withClient(DEFAULT_CLIENT).withService(serviceId).withModifiedBody(soapBody -> marshaller.marshal(wsdlRequestData, soapBody)).buildAsInputStream();
when(mockProxyMessage.getSoapContent()).thenReturn(soapContentInputStream);
setUpDatabase(requestingWsdlForService);
mockServer.stubFor(WireMock.any(urlPathEqualTo(EXPECTED_WSDL_QUERY_PATH)).willReturn(aResponse().withStatus(HttpServletResponse.SC_FORBIDDEN)));
mockServer.start();
handlerToTest.canHandle(serviceId, mockProxyMessage);
thrown.expect(RuntimeException.class);
thrown.expectMessage(containsString("Received HTTP error: 403 - Forbidden"));
// execution, should throw..
handlerToTest.startHandling(mockRequest, mockProxyMessage, httpClientMock, mock(OpMonitoringData.class));
}
Aggregations