use of ee.ria.xroad.common.identifier.ServiceId in project X-Road by nordic-institute.
the class MetadataServiceHandlerTest method shouldHandleGetWsdl.
@Test
public void shouldHandleGetWsdl() throws Exception {
final ServiceId serviceId = ServiceId.create(DEFAULT_CLIENT, GET_WSDL);
TestMetadataServiceHandlerImpl handlerToTest = prepareTestConstructsForWsdl(serviceId);
handlerToTest.setTestFilter(OverwriteAttributeFilter.createOverwriteSoapAddressFilter("expected-location"));
// execution
handlerToTest.startHandling(mockRequest, mockProxyMessage, httpClientMock, mock(OpMonitoringData.class));
// verification
final List<String> expectedWSDLServiceNames = Arrays.asList("getRandom", "helloService");
final List<String> expectedEndpointUrls = Arrays.asList("expected-location");
assertThat("Content type does not match", handlerToTest.getResponseContentType(), containsString("multipart/related; type=\"text/xml\"; charset=UTF-8;"));
TestMimeContentHandler handler = parseWsdlResponse(handlerToTest.getResponseContent(), // this response content type and the headless parsing is some super funky business
handlerToTest.getResponseContentType());
SoapHeader xrHeader = handler.getXrHeader();
assertThat("Response client does not match", xrHeader.getService(), is(serviceId));
final List<String> operationNames = handler.getOperationNames();
assertThat("Expected to find certain operations", operationNames, containsInAnyOrder(expectedWSDLServiceNames.toArray()));
List<String> endpointUrls = handler.getEndpointUrls();
assertThat("Expected to find overwritten endpoint urls", endpointUrls, containsInAnyOrder(expectedEndpointUrls.toArray()));
}
use of ee.ria.xroad.common.identifier.ServiceId in project X-Road by nordic-institute.
the class MetadataServiceHandlerTest method shouldBeAbleToHandleListMethods.
@Test
public void shouldBeAbleToHandleListMethods() throws Exception {
// setup
MetadataServiceHandlerImpl handlerToTest = new MetadataServiceHandlerImpl();
ServiceId serviceId = ServiceId.create(DEFAULT_CLIENT, LIST_METHODS);
InputStream soapContentInputStream = new TestSoapBuilder().withClient(DEFAULT_CLIENT).withService(serviceId).withModifiedBody(soapBody -> soapBody.addChildElement(LIST_METHODS_REQUEST).addChildElement(REQUEST)).buildAsInputStream();
when(mockProxyMessage.getSoapContent()).thenReturn(soapContentInputStream);
// execution & verification
assertTrue("Wasn't able to handle list methods", handlerToTest.canHandle(serviceId, mockProxyMessage));
}
use of ee.ria.xroad.common.identifier.ServiceId 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.identifier.ServiceId 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.identifier.ServiceId 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));
}
Aggregations