use of ee.ria.xroad.proxy.testsuite.TestSuiteGlobalConf in project X-Road by nordic-institute.
the class MetadataClientRequestProcessorTest method init.
/**
* Init data for tests
*/
@Before
public void init() throws IOException {
GlobalConf.reload(new TestSuiteGlobalConf());
KeyConf.reload(new TestSuiteKeyConf());
mockRequest = mock(HttpServletRequest.class);
mockJsonRequest = mock(HttpServletRequest.class);
mockResponse = mock(HttpServletResponse.class);
mockServletOutputStream = new MetaserviceTestUtil.StubServletOutputStream();
when(mockResponse.getOutputStream()).thenReturn(mockServletOutputStream);
when(mockJsonRequest.getHeaders("Accept")).thenReturn(Collections.enumeration(Arrays.asList("application/json")));
}
use of ee.ria.xroad.proxy.testsuite.TestSuiteGlobalConf in project X-Road by nordic-institute.
the class MetadataClientRequestProcessorTest method shouldProcessListClientsAndReturnJson.
@Test
public void shouldProcessListClientsAndReturnJson() throws Exception {
final List<MemberInfo> expectedMembers = Arrays.asList(createMember("producer", null), createMember("producer", "subsystem"));
GlobalConf.reload(new TestSuiteGlobalConf() {
@Override
public List<MemberInfo> getMembers(String... instanceIdentifier) {
String[] instances = instanceIdentifier;
assertThat("Wrong Xroad instance in query", instances, arrayContaining(EXPECTED_XR_INSTANCE));
return expectedMembers;
}
});
MetadataClientRequestProcessor processorToTest = new MetadataClientRequestProcessor(LIST_CLIENTS, mockJsonRequest, mockResponse);
processorToTest.process();
assertContentTypeIsIn(Arrays.asList("application/json; charset=utf-8"));
}
use of ee.ria.xroad.proxy.testsuite.TestSuiteGlobalConf in project X-Road by nordic-institute.
the class MetadataClientRequestProcessorTest method shouldProcessListCentralServices.
@Test
public void shouldProcessListCentralServices() throws Exception {
final List<CentralServiceId> expectedCentraServices = Arrays.asList(create(EXPECTED_XR_INSTANCE, "getInfo"), create(EXPECTED_XR_INSTANCE, "someService"), create(EXPECTED_XR_INSTANCE, "getRandom"));
GlobalConf.reload(new TestSuiteGlobalConf() {
@Override
public List<CentralServiceId> getCentralServices(String instanceIdentifier) {
assertThat("Wrong Xroad instance in query", instanceIdentifier, is(EXPECTED_XR_INSTANCE));
return expectedCentraServices;
}
});
MetadataClientRequestProcessor processorToTest = new MetadataClientRequestProcessor(LIST_CENTRAL_SERVICES, mockRequest, mockResponse);
processorToTest.process();
assertContentTypeIsIn(xmlUtf8ContentTypes());
List<CentralServiceId> resultCentralServices = unmarshaller.unmarshal(mockServletOutputStream.getResponseSource(), CentralServiceListType.class).getValue().getCentralService();
assertThat("Wrong amount of services", resultCentralServices.size(), is(expectedCentraServices.size()));
assertThat("Wrong services", resultCentralServices, containsInAnyOrder(expectedCentraServices.toArray()));
}
use of ee.ria.xroad.proxy.testsuite.TestSuiteGlobalConf in project X-Road by nordic-institute.
the class GetListCentralServicesMessage method startUp.
@Override
protected void startUp() throws Exception {
super.startUp();
GlobalConf.reload(new TestSuiteGlobalConf() {
@Override
public List<CentralServiceId> getCentralServices(String instanceIdentifier) {
assertThat("Wrong Xroad instance in query", instanceIdentifier, is(EXPECTED_XR_INSTANCE));
return EXPECTED_CENTRAL_SERVICES;
}
});
}
use of ee.ria.xroad.proxy.testsuite.TestSuiteGlobalConf in project X-Road by nordic-institute.
the class SslClientCertVerificationError method startUp.
@Override
protected void startUp() throws Exception {
ServerConf.reload(new TestSuiteServerConf());
GlobalConf.reload(new TestSuiteGlobalConf() {
@Override
public boolean authCertMatchesMember(X509Certificate cert, ClientId member) {
return false;
}
});
}
Aggregations