Search in sources :

Example 11 with TestSuiteGlobalConf

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")));
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) TestSuiteGlobalConf(ee.ria.xroad.proxy.testsuite.TestSuiteGlobalConf) TestSuiteKeyConf(ee.ria.xroad.proxy.testsuite.TestSuiteKeyConf) HttpServletResponse(javax.servlet.http.HttpServletResponse) MetaserviceTestUtil(ee.ria.xroad.proxy.util.MetaserviceTestUtil) Before(org.junit.Before)

Example 12 with TestSuiteGlobalConf

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"));
}
Also used : TestSuiteGlobalConf(ee.ria.xroad.proxy.testsuite.TestSuiteGlobalConf) MemberInfo(ee.ria.xroad.common.conf.globalconf.MemberInfo) List(java.util.List) Test(org.junit.Test)

Example 13 with TestSuiteGlobalConf

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()));
}
Also used : TestSuiteGlobalConf(ee.ria.xroad.proxy.testsuite.TestSuiteGlobalConf) List(java.util.List) CentralServiceId(ee.ria.xroad.common.identifier.CentralServiceId) Test(org.junit.Test)

Example 14 with TestSuiteGlobalConf

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;
        }
    });
}
Also used : TestSuiteGlobalConf(ee.ria.xroad.proxy.testsuite.TestSuiteGlobalConf) List(java.util.List)

Example 15 with TestSuiteGlobalConf

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;
        }
    });
}
Also used : TestSuiteGlobalConf(ee.ria.xroad.proxy.testsuite.TestSuiteGlobalConf) TestSuiteServerConf(ee.ria.xroad.proxy.testsuite.TestSuiteServerConf) ClientId(ee.ria.xroad.common.identifier.ClientId) X509Certificate(java.security.cert.X509Certificate)

Aggregations

TestSuiteGlobalConf (ee.ria.xroad.proxy.testsuite.TestSuiteGlobalConf)17 TestSuiteKeyConf (ee.ria.xroad.proxy.testsuite.TestSuiteKeyConf)8 TestSuiteServerConf (ee.ria.xroad.proxy.testsuite.TestSuiteServerConf)8 HttpServletRequest (javax.servlet.http.HttpServletRequest)7 Before (org.junit.Before)7 ClientId (ee.ria.xroad.common.identifier.ClientId)5 List (java.util.List)5 HttpServletResponse (javax.servlet.http.HttpServletResponse)5 SecurityServerId (ee.ria.xroad.common.identifier.SecurityServerId)4 ProxyMessage (ee.ria.xroad.proxy.protocol.ProxyMessage)4 MetaserviceTestUtil (ee.ria.xroad.proxy.util.MetaserviceTestUtil)3 X509Certificate (java.security.cert.X509Certificate)3 HttpClient (org.apache.http.client.HttpClient)3 WireMockServer (com.github.tomakehurst.wiremock.WireMockServer)2 MemberInfo (ee.ria.xroad.common.conf.globalconf.MemberInfo)2 CentralServiceId (ee.ria.xroad.common.identifier.CentralServiceId)2 Collection (java.util.Collection)2 Test (org.junit.Test)2 GlobalConf (ee.ria.xroad.common.conf.globalconf.GlobalConf)1 DescriptionType (ee.ria.xroad.common.conf.serverconf.model.DescriptionType)1