Repository: cxf-fediz Updated Branches: refs/heads/master b63d8dd0c -> de6f9870f
More tests Project: http://git-wip-us.apache.org/repos/asf/cxf-fediz/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf-fediz/commit/de6f9870 Tree: http://git-wip-us.apache.org/repos/asf/cxf-fediz/tree/de6f9870 Diff: http://git-wip-us.apache.org/repos/asf/cxf-fediz/diff/de6f9870 Branch: refs/heads/master Commit: de6f9870f772fb43318f71d00684077bcc13100a Parents: b63d8dd Author: Colm O hEigeartaigh <cohei...@apache.org> Authored: Thu Jan 14 17:30:46 2016 +0000 Committer: Colm O hEigeartaigh <cohei...@apache.org> Committed: Thu Jan 14 17:30:46 2016 +0000 ---------------------------------------------------------------------- .../src/main/webapp/WEB-INF/views/client.jsp | 10 ++-- .../cxf/fediz/systests/oidc/OIDCTest.java | 53 +++++++++++++++++++- 2 files changed, 56 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/de6f9870/services/oidc/src/main/webapp/WEB-INF/views/client.jsp ---------------------------------------------------------------------- diff --git a/services/oidc/src/main/webapp/WEB-INF/views/client.jsp b/services/oidc/src/main/webapp/WEB-INF/views/client.jsp index 90dd1de..750bae0 100644 --- a/services/oidc/src/main/webapp/WEB-INF/views/client.jsp +++ b/services/oidc/src/main/webapp/WEB-INF/views/client.jsp @@ -69,7 +69,7 @@ <div class="padded"> <h1><%= client.getApplicationName() %></h1> <br/> -<table border="1"> +<table border="1" id=client> <% SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm", Locale.US); dateFormat.setTimeZone(TimeZone.getTimeZone("GMT")); @@ -117,9 +117,9 @@ if (client.getClientSecret() != null) { %> <td class="td_no_border"> -<form action="/fediz-oidc/clients/<%= client.getClientId() + "/reset"%>" method="POST"> +<form name="resetSecretForm" action="/fediz-oidc/clients/<%= client.getClientId() + "/reset"%>" method="POST"> <div data-type="control_button" class="form-line"> - <button class="form-submit-button" type="submit">Reset Secret</button> + <button name="submit_reset_button" class="form-submit-button" type="submit">Reset Secret</button> </div> </form> </td> @@ -127,9 +127,9 @@ } %> <td class="td_no_border"> -<form action="/fediz-oidc/clients/<%= client.getClientId() + "/remove"%>" method="POST"> +<form name="deleteForm" action="/fediz-oidc/clients/<%= client.getClientId() + "/remove"%>" method="POST"> <div data-type="control_button" class="form-line"> - <button class="form-submit-button" type="submit">Delete Client</button> + <button name="submit_delete_button" class="form-submit-button" type="submit">Delete Client</button> </div> </form> </td> http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/de6f9870/systests/oidc/src/test/java/org/apache/cxf/fediz/systests/oidc/OIDCTest.java ---------------------------------------------------------------------- diff --git a/systests/oidc/src/test/java/org/apache/cxf/fediz/systests/oidc/OIDCTest.java b/systests/oidc/src/test/java/org/apache/cxf/fediz/systests/oidc/OIDCTest.java index d8f20af..8b4b0ec 100644 --- a/systests/oidc/src/test/java/org/apache/cxf/fediz/systests/oidc/OIDCTest.java +++ b/systests/oidc/src/test/java/org/apache/cxf/fediz/systests/oidc/OIDCTest.java @@ -161,7 +161,15 @@ public class OIDCTest { } @AfterClass - public static void cleanup() { + public static void cleanup() throws Exception { + try { + loginToClientsPageAndDeleteClient(rpHttpsPort, idpHttpsPort); + } finally { + shutdownServers(); + } + } + + private static void shutdownServers() { try { if (idpServer.getServer() != null && idpServer.getServer().getState() != LifecycleState.DESTROYED) { @@ -199,7 +207,7 @@ public class OIDCTest { return "fedizhelloworld"; } - // Login to the OIDC Clients page + create a new client + // Runs as BeforeClass: Login to the OIDC Clients page + create a new client private static void loginToClientsPage(String rpPort, String idpPort) throws Exception { String url = "https://localhost:" + rpPort + "/fediz-oidc/clients"; String user = "alice"; @@ -233,6 +241,40 @@ public class OIDCTest { webClient.close(); } + // Runs as AfterClass: Login to the OIDC Clients page + delete the created client! + private static void loginToClientsPageAndDeleteClient(String rpPort, String idpPort) throws Exception { + String url = "https://localhost:" + rpPort + "/fediz-oidc/clients"; + String user = "alice"; + String password = "ecila"; + + // Login to the client page successfully + WebClient webClient = setupWebClient(user, password, idpPort); + HtmlPage loginPage = login(url, webClient); + final String bodyTextContent = loginPage.getBody().getTextContent(); + Assert.assertTrue(bodyTextContent.contains("Registered Clients")); + + // Get the client identifier + HtmlTable table = loginPage.getHtmlElementById("registered_clients"); + String clientId = table.getCellAt(1, 1).asText().trim(); + Assert.assertNotNull(clientId); + + // Now go to the specific client page + HtmlPage clientPage = webClient.getPage(url + "/" + clientId); + + final HtmlForm deleteForm = clientPage.getFormByName("deleteForm"); + Assert.assertNotNull(deleteForm); + + // Delete the client + final HtmlButton button = deleteForm.getButtonByName("submit_delete_button"); + final HtmlPage registeredClientsPage = button.click(); + + // Check we have no more registered clients + table = registeredClientsPage.getHtmlElementById("registered_clients"); + Assert.assertEquals(1, table.getRowCount()); + + webClient.close(); + } + // Test that we managed to create a new Client ok @org.junit.Test public void testClientCreated() throws Exception { @@ -262,6 +304,13 @@ public class OIDCTest { Assert.assertEquals("http://127.0.0.1", redirectURI); Assert.assertEquals(table.getRows().size(), 2); + + // Now check the specific client page + HtmlPage clientPage = webClient.getPage(url + "/" + clientId); + HtmlTable clientTable = clientPage.getHtmlElementById("client"); + Assert.assertEquals(clientId, clientTable.getCellAt(1, 0).asText().trim()); + + webClient.close(); } /*