Repository: cxf-fediz Updated Branches: refs/heads/master c7666265b -> 8991f44ed
Added 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/8991f44e Tree: http://git-wip-us.apache.org/repos/asf/cxf-fediz/tree/8991f44e Diff: http://git-wip-us.apache.org/repos/asf/cxf-fediz/diff/8991f44e Branch: refs/heads/master Commit: 8991f44eddd877984ccac5eed54544327d5c3682 Parents: c766626 Author: Colm O hEigeartaigh <[email protected]> Authored: Tue Sep 2 12:05:50 2014 +0100 Committer: Colm O hEigeartaigh <[email protected]> Committed: Tue Sep 2 12:05:50 2014 +0100 ---------------------------------------------------------------------- .../fediz/integrationtests/AbstractTests.java | 119 +++++++++++++++---- 1 file changed, 99 insertions(+), 20 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/8991f44e/systests/tests/src/test/java/org/apache/cxf/fediz/integrationtests/AbstractTests.java ---------------------------------------------------------------------- diff --git a/systests/tests/src/test/java/org/apache/cxf/fediz/integrationtests/AbstractTests.java b/systests/tests/src/test/java/org/apache/cxf/fediz/integrationtests/AbstractTests.java index f2b715a..478ce91 100644 --- a/systests/tests/src/test/java/org/apache/cxf/fediz/integrationtests/AbstractTests.java +++ b/systests/tests/src/test/java/org/apache/cxf/fediz/integrationtests/AbstractTests.java @@ -35,7 +35,7 @@ public abstract class AbstractTests { public abstract String getRpHttpsPort(); @org.junit.Test - public void testUserAlice() throws Exception { + public void testAlice() throws Exception { String url = "https://localhost:" + getRpHttpsPort() + "/fedizhelloworld/secure/fedservlet"; String user = "alice"; String password = "ecila"; @@ -58,9 +58,49 @@ public abstract class AbstractTests { response.indexOf(claim + "[email protected]") > 0); } + + @org.junit.Test + public void testAliceUser() throws Exception { + String url = "https://localhost:" + getRpHttpsPort() + "/fedizhelloworld/secure/user/fedservlet"; + String user = "alice"; + String password = "ecila"; + String response = + HTTPTestUtils.sendHttpGet(url, user, password, Integer.parseInt(getIdpHttpsPort())); + Assert.assertTrue("Principal not " + user, response.indexOf("userPrincipal=" + user) > 0); + Assert.assertTrue("User " + user + " does not have role Admin", response.indexOf("role:Admin=false") > 0); + Assert.assertTrue("User " + user + " does not have role Manager", response.indexOf("role:Manager=false") > 0); + Assert.assertTrue("User " + user + " must have role User", response.indexOf("role:User=true") > 0); + } + @org.junit.Test - public void testUserBob() throws Exception { + public void testAliceAdminNoAccess() throws Exception { + String url = "https://localhost:" + getRpHttpsPort() + "/fedizhelloworld/secure/admin/fedservlet"; + String user = "alice"; + String password = "ecila"; + HTTPTestUtils.sendHttpGet(url, user, password, 200, 403, Integer.parseInt(getIdpHttpsPort())); + } + + @org.junit.Test + public void testliceManagerNoAccess() throws Exception { + String url = "https://localhost:" + getRpHttpsPort() + "/fedizhelloworld/secure/manager/fedservlet"; + String user = "alice"; + String password = "ecila"; + HTTPTestUtils.sendHttpGet(url, user, password, 200, 403, Integer.parseInt(getIdpHttpsPort())); + } + + @org.junit.Test + public void testAliceWrongPasswordNoAccess() throws Exception { + String url = "https://localhost:" + getRpHttpsPort() + "/fedizhelloworld/secure/fedservlet"; + String user = "alice"; + String password = "alice"; + // sendHttpGet(url, user, password, 500, 0); + //[FIXED] Fix IDP return code from 500 to 401 + HTTPTestUtils.sendHttpGet(url, user, password, 401, 0, Integer.parseInt(getIdpHttpsPort())); + } + + @org.junit.Test + public void testBob() throws Exception { String url = "https://localhost:" + getRpHttpsPort() + "/fedizhelloworld/secure/fedservlet"; String user = "bob"; String password = "bob"; @@ -82,9 +122,51 @@ public abstract class AbstractTests { Assert.assertTrue("User " + user + " claim " + claim + " is not '[email protected]'", response.indexOf(claim + "[email protected]") > 0); } + + @org.junit.Test + public void testBobUser() throws Exception { + String url = "https://localhost:" + getRpHttpsPort() + "/fedizhelloworld/secure/user/fedservlet"; + String user = "bob"; + String password = "bob"; + String response = + HTTPTestUtils.sendHttpGet(url, user, password, Integer.parseInt(getIdpHttpsPort())); + Assert.assertTrue("Principal not " + user, response.indexOf("userPrincipal=" + user) > 0); + Assert.assertTrue("User " + user + " does not have role Admin", response.indexOf("role:Admin=true") > 0); + Assert.assertTrue("User " + user + " does not have role Manager", response.indexOf("role:Manager=true") > 0); + Assert.assertTrue("User " + user + " must have role User", response.indexOf("role:User=true") > 0); + } + @org.junit.Test - public void testUserTed() throws Exception { + public void testBobManager() throws Exception { + String url = "https://localhost:" + getRpHttpsPort() + "/fedizhelloworld/secure/manager/fedservlet"; + String user = "bob"; + String password = "bob"; + String response = + HTTPTestUtils.sendHttpGet(url, user, password, Integer.parseInt(getIdpHttpsPort())); + + Assert.assertTrue("Principal not " + user, response.indexOf("userPrincipal=" + user) > 0); + Assert.assertTrue("User " + user + " does not have role Admin", response.indexOf("role:Admin=true") > 0); + Assert.assertTrue("User " + user + " does not have role Manager", response.indexOf("role:Manager=true") > 0); + Assert.assertTrue("User " + user + " must have role User", response.indexOf("role:User=true") > 0); + } + + @org.junit.Test + public void testBobAdmin() throws Exception { + String url = "https://localhost:" + getRpHttpsPort() + "/fedizhelloworld/secure/admin/fedservlet"; + String user = "bob"; + String password = "bob"; + String response = + HTTPTestUtils.sendHttpGet(url, user, password, Integer.parseInt(getIdpHttpsPort())); + + Assert.assertTrue("Principal not " + user, response.indexOf("userPrincipal=" + user) > 0); + Assert.assertTrue("User " + user + " does not have role Admin", response.indexOf("role:Admin=true") > 0); + Assert.assertTrue("User " + user + " does not have role Manager", response.indexOf("role:Manager=true") > 0); + Assert.assertTrue("User " + user + " must have role User", response.indexOf("role:User=true") > 0); + } + + @org.junit.Test + public void testTed() throws Exception { String url = "https://localhost:" + getRpHttpsPort() + "/fedizhelloworld/secure/fedservlet"; String user = "ted"; String password = "det"; @@ -106,32 +188,29 @@ public abstract class AbstractTests { Assert.assertTrue("User " + user + " claim " + claim + " is not '[email protected]'", response.indexOf(claim + "[email protected]") > 0); } - + @org.junit.Test - public void testUserAliceNoAccess() throws Exception { - String url = "https://localhost:" + getRpHttpsPort() + "/fedizhelloworld/secure/admin/fedservlet"; - String user = "alice"; - String password = "ecila"; - HTTPTestUtils.sendHttpGet(url, user, password, 200, 403, Integer.parseInt(getIdpHttpsPort())); + public void testTedUserNoAccess() throws Exception { + String url = "https://localhost:" + getRpHttpsPort() + "/fedizhelloworld/secure/user/fedservlet"; + String user = "ted"; + String password = "det"; + HTTPTestUtils.sendHttpGet(url, user, password, 200, 403, Integer.parseInt(getIdpHttpsPort())); } @org.junit.Test - public void testUserAliceWrongPassword() throws Exception { - String url = "https://localhost:" + getRpHttpsPort() + "/fedizhelloworld/secure/fedservlet"; - String user = "alice"; - String password = "alice"; - // sendHttpGet(url, user, password, 500, 0); - //[FIXED] Fix IDP return code from 500 to 401 - HTTPTestUtils.sendHttpGet(url, user, password, 401, 0, Integer.parseInt(getIdpHttpsPort())); + public void testTedAdminNoAccess() throws Exception { + String url = "https://localhost:" + getRpHttpsPort() + "/fedizhelloworld/secure/admin/fedservlet"; + String user = "ted"; + String password = "det"; + HTTPTestUtils.sendHttpGet(url, user, password, 200, 403, Integer.parseInt(getIdpHttpsPort())); } - + @org.junit.Test - public void testUserTedNoAccess() throws Exception { - String url = "https://localhost:" + getRpHttpsPort() + "/fedizhelloworld/secure/admin/fedservlet"; + public void testTedManagerNoAccess() throws Exception { + String url = "https://localhost:" + getRpHttpsPort() + "/fedizhelloworld/secure/manager/fedservlet"; String user = "ted"; String password = "det"; HTTPTestUtils.sendHttpGet(url, user, password, 200, 403, Integer.parseInt(getIdpHttpsPort())); } - }
