Search in sources :

Example 1 with BeforeExam

use of org.codice.ddf.itests.common.annotations.BeforeExam in project ddf by codice.

the class TestApplicationService method beforeExam.

@BeforeExam
public void beforeExam() throws Exception {
    try {
        waitForSystemReady();
        Security security = Security.getInstance();
        systemSubject = security.runAsAdmin(security::getSystemSubject);
    } catch (Exception e) {
        LoggingUtils.failWithThrowableStacktrace(e, "Failed in @BeforeExam: ");
    }
}
Also used : Security(org.codice.ddf.security.common.Security) ApplicationServiceException(org.codice.ddf.admin.application.service.ApplicationServiceException) BeforeExam(org.codice.ddf.itests.common.annotations.BeforeExam)

Example 2 with BeforeExam

use of org.codice.ddf.itests.common.annotations.BeforeExam in project ddf by codice.

the class TestRegistry method beforeExam.

@BeforeExam
public void beforeExam() throws Exception {
    try {
        waitForSystemReady();
        getServiceManager().startFeature(true, CATALOG_REGISTRY);
        getServiceManager().waitForAllBundles();
        getServiceManager().startFeature(true, CATALOG_REGISTRY_CORE);
        getServiceManager().waitForAllBundles();
        cswServer = new FederatedCswMockServer("MockCswServer", "http://localhost:", Integer.parseInt(CSW_STUB_SERVER_PORT.getPort()));
        String defaultResponse = getRegistryQueryResponse("11111111111111111111111111111111", REMOTE_REGISTRY_ID, REMOTE_REGISTRY_ID, "RemoteRegistry", "2018-02-26T17:16:34.996Z");
        cswServer.setupDefaultQueryResponseExpectation(defaultResponse);
        cswServer.start();
        waitForMockServer();
        getServiceManager().createManagedService(FACTORY_PID, getCswRegistryStoreProperties(REGISTRY_CATALOG_STORE_ID, "http://localhost:" + CSW_STUB_SERVER_PORT.getPort() + "/services/csw", getServiceManager()));
        storeId = String.format("RemoteRegistry (localhost:%s) (%s)", CSW_STUB_SERVER_PORT.getPort(), CSW_REGISTRY_TYPE);
        getCatalogBundle().waitForCatalogStore(storeId);
    } catch (Exception e) {
        LoggingUtils.failWithThrowableStacktrace(e, "Failed in @BeforeExam: ");
    }
}
Also used : FederatedCswMockServer(org.codice.ddf.itests.common.csw.mock.FederatedCswMockServer) IOException(java.io.IOException) BeforeExam(org.codice.ddf.itests.common.annotations.BeforeExam)

Example 3 with BeforeExam

use of org.codice.ddf.itests.common.annotations.BeforeExam in project ddf by codice.

the class TestSecurity method beforeTest.

@BeforeExam
public void beforeTest() throws Exception {
    try {
        waitForSystemReady();
        Configuration config = getAdminConfig().getConfiguration("org.codice.ddf.admin.config.policy.AdminConfigPolicy");
        config.setBundleLocation("mvn:ddf.admin.core/admin-core-configpolicy/" + System.getProperty("ddf.version"));
        Dictionary properties = new Hashtable<>();
        List<String> featurePolicies = new ArrayList<>();
        featurePolicies.addAll(Arrays.asList(getDefaultRequiredApps()));
        featurePolicies.addAll(FEATURES_TO_FILTER);
        featurePolicies.replaceAll(featureName -> featureName + "=\"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/role=admin\"");
        List<String> servicePolicies = new ArrayList<>();
        servicePolicies.addAll(SERVICES_TO_FILTER);
        servicePolicies.replaceAll(serviceName -> serviceName + "=\"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/role=admin\"");
        properties.put("featurePolicies", featurePolicies.stream().toArray(String[]::new));
        properties.put("servicePolicies", servicePolicies.stream().toArray(String[]::new));
        config.update(properties);
    } catch (Exception e) {
        LoggingUtils.failWithThrowableStacktrace(e, "Failed in @BeforeExam: ");
    }
}
Also used : Dictionary(java.util.Dictionary) Configuration(org.osgi.service.cm.Configuration) Hashtable(java.util.Hashtable) ArrayList(java.util.ArrayList) Matchers.containsString(org.hamcrest.Matchers.containsString) NoHttpResponseException(org.apache.http.NoHttpResponseException) SSLHandshakeException(javax.net.ssl.SSLHandshakeException) KeyManagementException(java.security.KeyManagementException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) IOException(java.io.IOException) BeforeExam(org.codice.ddf.itests.common.annotations.BeforeExam)

Example 4 with BeforeExam

use of org.codice.ddf.itests.common.annotations.BeforeExam in project ddf by codice.

the class TestSingleSignOn method beforeTest.

@BeforeExam
public void beforeTest() throws Exception {
    try {
        waitForSystemReady();
        // Start the services needed for testing.
        // We need to start the Search UI to test that it redirects properly
        getServiceManager().startFeature(true, "security-idp");
        getServiceManager().waitForAllBundles();
        // Get all of the metadata
        String metadata = get(SERVICE_ROOT + "/idp/login/metadata").asString();
        String ddfSpMetadata = get(SERVICE_ROOT + "/saml/sso/metadata").asString();
        // Make sure all the metadata is valid before we set it
        validateSaml(metadata, SamlSchema.METADATA);
        validateSaml(ddfSpMetadata, SamlSchema.METADATA);
        // The IdP server can point to multiple Service Providers and as such expects an array.
        // Thus, even though we are only setting a single item, we must wrap it in an array.
        setConfig("org.codice.ddf.security.idp.client.IdpMetadata", "metadata", metadata);
        setConfig("org.codice.ddf.security.idp.server.IdpEndpoint", "spMetadata", new String[] { ddfSpMetadata });
        metacardId = ingest(getFileContent(JSON_RECORD_RESOURCE_PATH + "/SimpleGeoJsonRecord"), "application/json");
        getSecurityPolicy().configureWebContextPolicy(null, IDP_AUTH_TYPES, null, null);
        getServiceManager().waitForAllBundles();
        getServiceManager().waitForHttpEndpoint(SERVICE_ROOT + "/catalog/query");
        getServiceManager().waitForHttpEndpoint(WHO_AM_I_URL.getUrl());
        getServiceManager().waitForHttpEndpoint(SERVICE_ROOT + "/idp/login/metadata");
        getServiceManager().waitForHttpEndpoint(SERVICE_ROOT + "/saml/sso/metadata");
        Map<String, Object> openSearchProperties = getOpenSearchSourceProperties(OPENSEARCH_SOURCE_ID, OPENSEARCH_PATH.getUrl(), getServiceManager());
        openSearchProperties.put("username", "admin");
        openSearchProperties.put("password", "admin");
        getServiceManager().createManagedService(OPENSEARCH_FACTORY_PID, openSearchProperties);
        getCatalogBundle().waitForFederatedSource(OPENSEARCH_SOURCE_ID);
    } catch (Exception e) {
        LoggingUtils.failWithThrowableStacktrace(e, "Failed in @BeforeExam: ");
    }
}
Also used : Matchers.isEmptyOrNullString(org.hamcrest.Matchers.isEmptyOrNullString) Matchers.containsString(org.hamcrest.Matchers.containsString) URISyntaxException(java.net.URISyntaxException) SAXException(org.xml.sax.SAXException) IOException(java.io.IOException) BeforeExam(org.codice.ddf.itests.common.annotations.BeforeExam)

Example 5 with BeforeExam

use of org.codice.ddf.itests.common.annotations.BeforeExam in project ddf by codice.

the class TestFederation method beforeExam.

@BeforeExam
public void beforeExam() throws Exception {
    try {
        waitForSystemReady();
        getCatalogBundle().setupMaxDownloadRetryAttempts(MAX_DOWNLOAD_RETRY_ATTEMPTS);
        Map<String, Object> openSearchProperties = getOpenSearchSourceProperties(OPENSEARCH_SOURCE_ID, OPENSEARCH_PATH.getUrl(), getServiceManager());
        getServiceManager().createManagedService(OPENSEARCH_FACTORY_PID, openSearchProperties);
        cswServer = new FederatedCswMockServer(CSW_STUB_SOURCE_ID, INSECURE_ROOT, Integer.parseInt(CSW_STUB_SERVER_PORT.getPort()));
        cswServer.start();
        Map<String, Object> cswStubServerProperties = getCswSourceProperties(CSW_STUB_SOURCE_ID, CSW_PATH.getUrl(), getServiceManager());
        cswStubServerProperties.put("cswUrl", CSW_STUB_SERVER_PATH.getUrl());
        cswStubServerProperties.put(POLL_INTERVAL, CSW_SOURCE_POLL_INTERVAL);
        getServiceManager().createManagedService(CSW_FEDERATED_SOURCE_FACTORY_PID, cswStubServerProperties);
        getServiceManager().waitForHttpEndpoint(CSW_PATH + "?_wadl");
        Map<String, Object> cswProperties = getCswSourceProperties(CSW_SOURCE_ID, CSW_PATH.getUrl(), getServiceManager());
        cswProperties.put(POLL_INTERVAL, CSW_SOURCE_POLL_INTERVAL);
        getServiceManager().createManagedService(CSW_FEDERATED_SOURCE_FACTORY_PID, cswProperties);
        Map<String, Object> cswProperties2 = getCswSourceProperties(CSW_SOURCE_WITH_METACARD_XML_ID, CSW_PATH.getUrl(), getServiceManager());
        cswProperties2.put("outputSchema", "urn:catalog:metacard");
        cswProperties2.put(POLL_INTERVAL, CSW_SOURCE_POLL_INTERVAL);
        getServiceManager().createManagedService(CSW_FEDERATED_SOURCE_FACTORY_PID, cswProperties2);
        Map<String, Object> gmdProperties = getCswSourceProperties(GMD_SOURCE_ID, GMD_CSW_FEDERATED_SOURCE_FACTORY_PID, CSW_PATH.getUrl(), getServiceManager());
        gmdProperties.put(POLL_INTERVAL, CSW_SOURCE_POLL_INTERVAL);
        getServiceManager().createManagedService(GMD_CSW_FEDERATED_SOURCE_FACTORY_PID, gmdProperties);
        getCatalogBundle().waitForFederatedSource(OPENSEARCH_SOURCE_ID);
        getCatalogBundle().waitForFederatedSource(CSW_STUB_SOURCE_ID);
        getCatalogBundle().waitForFederatedSource(CSW_SOURCE_ID);
        getCatalogBundle().waitForFederatedSource(CSW_SOURCE_WITH_METACARD_XML_ID);
        getCatalogBundle().waitForFederatedSource(GMD_SOURCE_ID);
        getServiceManager().waitForSourcesToBeAvailable(REST_PATH.getUrl(), OPENSEARCH_SOURCE_ID, CSW_STUB_SOURCE_ID, CSW_SOURCE_ID, CSW_SOURCE_WITH_METACARD_XML_ID, GMD_SOURCE_ID);
        LOGGER.info("Source status: \n{}", get(REST_PATH.getUrl() + "sources").body().prettyPrint());
    } catch (Exception e) {
        LoggingUtils.failWithThrowableStacktrace(e, "Failed in @BeforeExam: ");
    }
}
Also used : FederatedCswMockServer(org.codice.ddf.itests.common.csw.mock.FederatedCswMockServer) Matchers.containsString(org.hamcrest.Matchers.containsString) IOException(java.io.IOException) InvalidSyntaxException(org.osgi.framework.InvalidSyntaxException) BeforeExam(org.codice.ddf.itests.common.annotations.BeforeExam)

Aggregations

BeforeExam (org.codice.ddf.itests.common.annotations.BeforeExam)5 IOException (java.io.IOException)4 Matchers.containsString (org.hamcrest.Matchers.containsString)3 FederatedCswMockServer (org.codice.ddf.itests.common.csw.mock.FederatedCswMockServer)2 URISyntaxException (java.net.URISyntaxException)1 KeyManagementException (java.security.KeyManagementException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 ArrayList (java.util.ArrayList)1 Dictionary (java.util.Dictionary)1 Hashtable (java.util.Hashtable)1 SSLHandshakeException (javax.net.ssl.SSLHandshakeException)1 NoHttpResponseException (org.apache.http.NoHttpResponseException)1 ApplicationServiceException (org.codice.ddf.admin.application.service.ApplicationServiceException)1 Security (org.codice.ddf.security.common.Security)1 Matchers.isEmptyOrNullString (org.hamcrest.Matchers.isEmptyOrNullString)1 InvalidSyntaxException (org.osgi.framework.InvalidSyntaxException)1 Configuration (org.osgi.service.cm.Configuration)1 SAXException (org.xml.sax.SAXException)1