Return-Path: X-Original-To: apmail-cxf-commits-archive@www.apache.org Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 62DB01199A for ; Tue, 2 Sep 2014 11:05:59 +0000 (UTC) Received: (qmail 75966 invoked by uid 500); 2 Sep 2014 11:05:59 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 75903 invoked by uid 500); 2 Sep 2014 11:05:59 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 75893 invoked by uid 99); 2 Sep 2014 11:05:59 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Sep 2014 11:05:59 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id C154C9AEDEF; Tue, 2 Sep 2014 11:05:58 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: coheigea@apache.org To: commits@cxf.apache.org Message-Id: <802db864a77d4c138eefd6616a5b26ee@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: git commit: Added more tests Date: Tue, 2 Sep 2014 11:05:58 +0000 (UTC) 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 Authored: Tue Sep 2 12:05:50 2014 +0100 Committer: Colm O hEigeartaigh 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 + "=alice@realma.org") > 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 'bobwindsor@realma.org'", response.indexOf(claim + "=bobwindsor@realma.org") > 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 'tcooper@realma.org'", response.indexOf(claim + "=tcooper@realma.org") > 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())); } - }