{"action":"created","comment":{"url":"https://api.github.com/repos/codice/ddf/pulls/comments/46430806","id":46430806,"diff_hunk":"@@ -87,182 +113,252 @@ public void beforeTest() throws Exception {\n         getServiceManager().waitForHttpEndpoint(SERVICE_ROOT + \"/catalog/query\");\n         getServiceManager().waitForHttpEndpoint(WHO_AM_I_URL.getUrl());\n \n-        // Start the services needed for testing. We need to start the Search UI to test that it redirects properly\n+        // Start the services needed for testing.\n+        // We need to start the Search UI to test that it redirects properly\n         getServiceManager().startFeature(true, \"security-idp\", \"search-ui-app\");\n \n-        // Create a validator from the metadata schema so that we can validate the metadata\n-        SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);\n-        Schema schema = schemaFactory.newSchema(getClass().getClassLoader().getResource(\"saml-schema-metadata-2.0.xsd\"));\n-        Validator validator = schema.newValidator();\n-\n-        // Get the metadata\n-        String serverMetadata = get(SERVICE_ROOT + \"/idp/login/metadata\").asString();\n-        String clientMetadata = get(SERVICE_ROOT + \"/saml/sso/metadata\").asString();\n-\n-        // Ensure the metadata is valid according to the SAML Metadata schema\n-        validator.validate(new StreamSource(new StringReader(clientMetadata)));\n-        validator.validate(new StreamSource(new StringReader(serverMetadata)));\n-\n-        // To find the right inputs for the settings, go into the metatype.xml file.\n-        // The key is the \"id\" and the value type is determined by the cardinality as such:\n-        // Positive = array, negative = vector, 0 (none) = single variable\n-        Dictionary<String, Object> clientSettings = new Hashtable<>();\n-        clientSettings.put(\"metadata\", serverMetadata);\n-        Dictionary<String, Object> serverSettings = new Hashtable<>();\n-        serverSettings.put(\"spMetadata\", new String[] {clientMetadata});\n-\n-        // Update the client and server with the metadata\n-        Configuration clientConfig = getAdminConfig()\n-                .getConfiguration(\"org.codice.ddf.security.idp.client.IdpMetadata\", null);\n-        Configuration serverConfig = getAdminConfig()\n-                .getConfiguration(\"org.codice.ddf.security.idp.server.IdpEndpoint\", null);\n-        clientConfig.update(clientSettings);\n-        serverConfig.update(serverSettings);\n-        expect(\"Configs to update\").within(2, TimeUnit.MINUTES)\n-                .until(clientConfig::getProperties, notNullValue());\n-        expect(\"Configs to update\").within(2, TimeUnit.MINUTES)\n-                .until(serverConfig::getProperties, notNullValue());\n+        // Get all of the metadata\n+        String metadata = get(SERVICE_ROOT + \"/idp/login/metadata\").asString();\n+        String ddfSpMetadata = get(SERVICE_ROOT + \"/saml/sso/metadata\").asString();\n+\n+        // Make sure all the metadata is valid before we set it\n+        validateSaml(metadata, SamlSchema.METADATA);\n+        validateSaml(ddfSpMetadata, SamlSchema.METADATA);\n+\n+        // Set the metadata\n+        setConfig(\"org.codice.ddf.security.idp.client.IdpMetadata\", \"metadata\", metadata);\n+        setConfig(\"org.codice.ddf.security.idp.server.IdpEndpoint\", \"spMetadata\", new String[] {ddfSpMetadata});\n     }\n \n-    private String getRedirectUrl(Response response) {\n-        String fullUrl = null;\n+    private void validateSaml(String xml, SamlSchema schema) throws IOException {\n \n-        // We can either get a legit redirect from the header, or we can have javascript redirect us.\n-        // Whenever javascript redirects us, we have to do ugly, fragile parsing of the HTML.\n-        if (response.headers().hasHeaderWithName(\"Location\")) {\n-            fullUrl = response.header(\"Location\");\n-        } else if (response.body().asString()\n-                .contains(\"<title>Redirect</title>\")) { // Javascript redirect\n-            Pattern pattern = Pattern.compile(\"encoded *= *\\\"(.*)\\\"\", Pattern.CASE_INSENSITIVE);\n-            Matcher matcher = pattern.matcher(response.body().asString());\n-            matcher.find();\n-            fullUrl = matcher.group(1);\n-        } else {\n-            fail(\"Unable to extract the redirect URL from the HTTP response. \"\n-                    + \"No redirect found in header and body does not match \"\n-                    + \"regular expression [encoded *= *\\\"(.*)\\\"]\");\n+        // Prepare the schema and xml\n+        String schemaFileName = \"saml-schema-\" + schema.toString().toLowerCase() + \"-2.0.xsd\";\n+        URL schemaURL = getClass().getClassLoader().getResource(schemaFileName);\n+        StreamSource streamSource = new StreamSource(new StringReader(xml));\n+\n+        // If we fail to create a validator we don't want to stop the show, so we just log a warning\n+        Validator validator = null;\n+        try {\n+            validator = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema(schemaURL).newValidator();\n+        } catch (SAXException e) {\n+            LOGGER.warn(\"Exception creating validator\", e.getLocalizedMessage());","path":"distribution/test/itests/test-itests-ddf/src/test/java/ddf/test/itests/platform/TestSingleSignOn.java","position":null,"original_position":168,"commit_id":"7147c0093503a8be75449b5c16d68b051dd24dcf","original_commit_id":"f0bc03881dfd6cb981b749aff723fcf333740924","user":{"login":"spearskw","id":9749143,"avatar_url":"https://avatars.githubusercontent.com/u/9749143?v=3","gravatar_id":"","url":"https://api.github.com/users/spearskw","html_url":"https://github.com/spearskw","followers_url":"https://api.github.com/users/spearskw/followers","following_url":"https://api.github.com/users/spearskw/following{/other_user}","gists_url":"https://api.github.com/users/spearskw/gists{/gist_id}","starred_url":"https://api.github.com/users/spearskw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spearskw/subscriptions","organizations_url":"https://api.github.com/users/spearskw/orgs","repos_url":"https://api.github.com/users/spearskw/repos","events_url":"https://api.github.com/users/spearskw/events{/privacy}","received_events_url":"https://api.github.com/users/spearskw/received_events","type":"User","site_admin":false},"body":"!fixed","created_at":"2015-12-02T15:49:48Z","updated_at":"2015-12-02T15:49:48Z","html_url":"https://github.com/codice/ddf/pull/364#discussion_r46430806","pull_request_url":"https://api.github.com/repos/codice/ddf/pulls/364","_links":{"self":{"href":"https://api.github.com/repos/codice/ddf/pulls/comments/46430806"},"html":{"href":"https://github.com/codice/ddf/pull/364#discussion_r46430806"},"pull_request":{"href":"https://api.github.com/repos/codice/ddf/pulls/364"}}},"pull_request":{"url":"https://api.github.com/repos/codice/ddf/pulls/364","id":52276251,"html_url":"https://github.com/codice/ddf/pull/364","diff_url":"https://github.com/codice/ddf/pull/364.diff","patch_url":"https://github.com/codice/ddf/pull/364.patch","issue_url":"https://api.github.com/repos/codice/ddf/issues/364","number":364,"state":"open","locked":false,"title":"DDF-1647 Added integration tests for non-standard SP's","user":{"login":"spearskw","id":9749143,"avatar_url":"https://avatars.githubusercontent.com/u/9749143?v=3","gravatar_id":"","url":"https://api.github.com/users/spearskw","html_url":"https://github.com/spearskw","followers_url":"https://api.github.com/users/spearskw/followers","following_url":"https://api.github.com/users/spearskw/following{/other_user}","gists_url":"https://api.github.com/users/spearskw/gists{/gist_id}","starred_url":"https://api.github.com/users/spearskw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spearskw/subscriptions","organizations_url":"https://api.github.com/users/spearskw/orgs","repos_url":"https://api.github.com/users/spearskw/repos","events_url":"https://api.github.com/users/spearskw/events{/privacy}","received_events_url":"https://api.github.com/users/spearskw/received_events","type":"User","site_admin":false},"body":"@oscaritoro \r\n@AzGoalie -Hero\r\n@stustison ","created_at":"2015-12-01T15:59:38Z","updated_at":"2015-12-02T15:49:48Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7eed2579c949ba57a61ebb4f891473cd524d0d88","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/codice/ddf/pulls/364/commits","review_comments_url":"https://api.github.com/repos/codice/ddf/pulls/364/comments","review_comment_url":"https://api.github.com/repos/codice/ddf/pulls/comments{/number}","comments_url":"https://api.github.com/repos/codice/ddf/issues/364/comments","statuses_url":"https://api.github.com/repos/codice/ddf/statuses/7147c0093503a8be75449b5c16d68b051dd24dcf","head":{"label":"spearskw:DDF-1647-idp-non-standard-integration-tests","ref":"DDF-1647-idp-non-standard-integration-tests","sha":"7147c0093503a8be75449b5c16d68b051dd24dcf","user":{"login":"spearskw","id":9749143,"avatar_url":"https://avatars.githubusercontent.com/u/9749143?v=3","gravatar_id":"","url":"https://api.github.com/users/spearskw","html_url":"https://github.com/spearskw","followers_url":"https://api.github.com/users/spearskw/followers","following_url":"https://api.github.com/users/spearskw/following{/other_user}","gists_url":"https://api.github.com/users/spearskw/gists{/gist_id}","starred_url":"https://api.github.com/users/spearskw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spearskw/subscriptions","organizations_url":"https://api.github.com/users/spearskw/orgs","repos_url":"https://api.github.com/users/spearskw/repos","events_url":"https://api.github.com/users/spearskw/events{/privacy}","received_events_url":"https://api.github.com/users/spearskw/received_events","type":"User","site_admin":false},"repo":{"id":44399285,"name":"ddf","full_name":"spearskw/ddf","owner":{"login":"spearskw","id":9749143,"avatar_url":"https://avatars.githubusercontent.com/u/9749143?v=3","gravatar_id":"","url":"https://api.github.com/users/spearskw","html_url":"https://github.com/spearskw","followers_url":"https://api.github.com/users/spearskw/followers","following_url":"https://api.github.com/users/spearskw/following{/other_user}","gists_url":"https://api.github.com/users/spearskw/gists{/gist_id}","starred_url":"https://api.github.com/users/spearskw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spearskw/subscriptions","organizations_url":"https://api.github.com/users/spearskw/orgs","repos_url":"https://api.github.com/users/spearskw/repos","events_url":"https://api.github.com/users/spearskw/events{/privacy}","received_events_url":"https://api.github.com/users/spearskw/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/spearskw/ddf","description":"The Distributed Data Framework - Distribution, SDK, and Test","fork":true,"url":"https://api.github.com/repos/spearskw/ddf","forks_url":"https://api.github.com/repos/spearskw/ddf/forks","keys_url":"https://api.github.com/repos/spearskw/ddf/keys{/key_id}","collaborators_url":"https://api.github.com/repos/spearskw/ddf/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/spearskw/ddf/teams","hooks_url":"https://api.github.com/repos/spearskw/ddf/hooks","issue_events_url":"https://api.github.com/repos/spearskw/ddf/issues/events{/number}","events_url":"https://api.github.com/repos/spearskw/ddf/events","assignees_url":"https://api.github.com/repos/spearskw/ddf/assignees{/user}","branches_url":"https://api.github.com/repos/spearskw/ddf/branches{/branch}","tags_url":"https://api.github.com/repos/spearskw/ddf/tags","blobs_url":"https://api.github.com/repos/spearskw/ddf/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/spearskw/ddf/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/spearskw/ddf/git/refs{/sha}","trees_url":"https://api.github.com/repos/spearskw/ddf/git/trees{/sha}","statuses_url":"https://api.github.com/repos/spearskw/ddf/statuses/{sha}","languages_url":"https://api.github.com/repos/spearskw/ddf/languages","stargazers_url":"https://api.github.com/repos/spearskw/ddf/stargazers","contributors_url":"https://api.github.com/repos/spearskw/ddf/contributors","subscribers_url":"https://api.github.com/repos/spearskw/ddf/subscribers","subscription_url":"https://api.github.com/repos/spearskw/ddf/subscription","commits_url":"https://api.github.com/repos/spearskw/ddf/commits{/sha}","git_commits_url":"https://api.github.com/repos/spearskw/ddf/git/commits{/sha}","comments_url":"https://api.github.com/repos/spearskw/ddf/comments{/number}","issue_comment_url":"https://api.github.com/repos/spearskw/ddf/issues/comments{/number}","contents_url":"https://api.github.com/repos/spearskw/ddf/contents/{+path}","compare_url":"https://api.github.com/repos/spearskw/ddf/compare/{base}...{head}","merges_url":"https://api.github.com/repos/spearskw/ddf/merges","archive_url":"https://api.github.com/repos/spearskw/ddf/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/spearskw/ddf/downloads","issues_url":"https://api.github.com/repos/spearskw/ddf/issues{/number}","pulls_url":"https://api.github.com/repos/spearskw/ddf/pulls{/number}","milestones_url":"https://api.github.com/repos/spearskw/ddf/milestones{/number}","notifications_url":"https://api.github.com/repos/spearskw/ddf/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/spearskw/ddf/labels{/name}","releases_url":"https://api.github.com/repos/spearskw/ddf/releases{/id}","created_at":"2015-10-16T17:05:29Z","updated_at":"2015-10-16T17:05:44Z","pushed_at":"2015-12-02T15:47:59Z","git_url":"git://github.com/spearskw/ddf.git","ssh_url":"git@github.com:spearskw/ddf.git","clone_url":"https://github.com/spearskw/ddf.git","svn_url":"https://github.com/spearskw/ddf","homepage":"","size":123837,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"codice:master","ref":"master","sha":"f66b1ab2d89cd6877ded7869be9f8454edc968d3","user":{"login":"codice","id":2386734,"avatar_url":"https://avatars.githubusercontent.com/u/2386734?v=3","gravatar_id":"","url":"https://api.github.com/users/codice","html_url":"https://github.com/codice","followers_url":"https://api.github.com/users/codice/followers","following_url":"https://api.github.com/users/codice/following{/other_user}","gists_url":"https://api.github.com/users/codice/gists{/gist_id}","starred_url":"https://api.github.com/users/codice/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codice/subscriptions","organizations_url":"https://api.github.com/users/codice/orgs","repos_url":"https://api.github.com/users/codice/repos","events_url":"https://api.github.com/users/codice/events{/privacy}","received_events_url":"https://api.github.com/users/codice/received_events","type":"Organization","site_admin":false},"repo":{"id":15173563,"name":"ddf","full_name":"codice/ddf","owner":{"login":"codice","id":2386734,"avatar_url":"https://avatars.githubusercontent.com/u/2386734?v=3","gravatar_id":"","url":"https://api.github.com/users/codice","html_url":"https://github.com/codice","followers_url":"https://api.github.com/users/codice/followers","following_url":"https://api.github.com/users/codice/following{/other_user}","gists_url":"https://api.github.com/users/codice/gists{/gist_id}","starred_url":"https://api.github.com/users/codice/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codice/subscriptions","organizations_url":"https://api.github.com/users/codice/orgs","repos_url":"https://api.github.com/users/codice/repos","events_url":"https://api.github.com/users/codice/events{/privacy}","received_events_url":"https://api.github.com/users/codice/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/codice/ddf","description":"The Distributed Data Framework - Distribution, SDK, and Test","fork":false,"url":"https://api.github.com/repos/codice/ddf","forks_url":"https://api.github.com/repos/codice/ddf/forks","keys_url":"https://api.github.com/repos/codice/ddf/keys{/key_id}","collaborators_url":"https://api.github.com/repos/codice/ddf/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/codice/ddf/teams","hooks_url":"https://api.github.com/repos/codice/ddf/hooks","issue_events_url":"https://api.github.com/repos/codice/ddf/issues/events{/number}","events_url":"https://api.github.com/repos/codice/ddf/events","assignees_url":"https://api.github.com/repos/codice/ddf/assignees{/user}","branches_url":"https://api.github.com/repos/codice/ddf/branches{/branch}","tags_url":"https://api.github.com/repos/codice/ddf/tags","blobs_url":"https://api.github.com/repos/codice/ddf/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/codice/ddf/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/codice/ddf/git/refs{/sha}","trees_url":"https://api.github.com/repos/codice/ddf/git/trees{/sha}","statuses_url":"https://api.github.com/repos/codice/ddf/statuses/{sha}","languages_url":"https://api.github.com/repos/codice/ddf/languages","stargazers_url":"https://api.github.com/repos/codice/ddf/stargazers","contributors_url":"https://api.github.com/repos/codice/ddf/contributors","subscribers_url":"https://api.github.com/repos/codice/ddf/subscribers","subscription_url":"https://api.github.com/repos/codice/ddf/subscription","commits_url":"https://api.github.com/repos/codice/ddf/commits{/sha}","git_commits_url":"https://api.github.com/repos/codice/ddf/git/commits{/sha}","comments_url":"https://api.github.com/repos/codice/ddf/comments{/number}","issue_comment_url":"https://api.github.com/repos/codice/ddf/issues/comments{/number}","contents_url":"https://api.github.com/repos/codice/ddf/contents/{+path}","compare_url":"https://api.github.com/repos/codice/ddf/compare/{base}...{head}","merges_url":"https://api.github.com/repos/codice/ddf/merges","archive_url":"https://api.github.com/repos/codice/ddf/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/codice/ddf/downloads","issues_url":"https://api.github.com/repos/codice/ddf/issues{/number}","pulls_url":"https://api.github.com/repos/codice/ddf/pulls{/number}","milestones_url":"https://api.github.com/repos/codice/ddf/milestones{/number}","notifications_url":"https://api.github.com/repos/codice/ddf/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/codice/ddf/labels{/name}","releases_url":"https://api.github.com/repos/codice/ddf/releases{/id}","created_at":"2013-12-13T20:38:28Z","updated_at":"2015-11-11T00:19:30Z","pushed_at":"2015-12-02T15:48:00Z","git_url":"git://github.com/codice/ddf.git","ssh_url":"git@github.com:codice/ddf.git","clone_url":"https://github.com/codice/ddf.git","svn_url":"https://github.com/codice/ddf","homepage":"","size":130302,"stargazers_count":24,"watchers_count":24,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":63,"mirror_url":null,"open_issues_count":11,"forks":63,"open_issues":11,"watchers":24,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/codice/ddf/pulls/364"},"html":{"href":"https://github.com/codice/ddf/pull/364"},"issue":{"href":"https://api.github.com/repos/codice/ddf/issues/364"},"comments":{"href":"https://api.github.com/repos/codice/ddf/issues/364/comments"},"review_comments":{"href":"https://api.github.com/repos/codice/ddf/pulls/364/comments"},"review_comment":{"href":"https://api.github.com/repos/codice/ddf/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/codice/ddf/pulls/364/commits"},"statuses":{"href":"https://api.github.com/repos/codice/ddf/statuses/7147c0093503a8be75449b5c16d68b051dd24dcf"}}}}