cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject [2/4] cxf-fediz git commit: Fixed IdP unit tests when run with realm b.
Date Tue, 22 Dec 2015 15:52:02 GMT
Fixed IdP unit tests when run with realm b.

Conflicts:
	services/idp/src/test/java/org/apache/cxf/fediz/service/idp/integrationtests/RestITTest.java


Project: http://git-wip-us.apache.org/repos/asf/cxf-fediz/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf-fediz/commit/908ce2ba
Tree: http://git-wip-us.apache.org/repos/asf/cxf-fediz/tree/908ce2ba
Diff: http://git-wip-us.apache.org/repos/asf/cxf-fediz/diff/908ce2ba

Branch: refs/heads/1.2.x-fixes
Commit: 908ce2ba4ce961d6945d44f3fdefe96a95ad5c2c
Parents: c9c0de7
Author: Colm O hEigeartaigh <coheigea@apache.org>
Authored: Tue Dec 22 15:33:04 2015 +0000
Committer: Colm O hEigeartaigh <coheigea@apache.org>
Committed: Tue Dec 22 15:39:55 2015 +0000

----------------------------------------------------------------------
 services/idp/pom.xml                            |   3 +
 .../idp/integrationtests/RestITTest.java        | 131 +++++++++++++------
 2 files changed, 93 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/908ce2ba/services/idp/pom.xml
----------------------------------------------------------------------
diff --git a/services/idp/pom.xml b/services/idp/pom.xml
index 76f2f7f..4640291 100644
--- a/services/idp/pom.xml
+++ b/services/idp/pom.xml
@@ -430,6 +430,7 @@
                             <skip>false</skip>
                             <systemPropertyVariables>
                                 <idp.https.port>${idp.https.port}</idp.https.port>
+                                <realm>${realm}</realm>
                                 <catalina.base>target</catalina.base>
                             </systemPropertyVariables>
                             <includes>
@@ -483,6 +484,7 @@
                 <jpa.url>jdbc:hsqldb:target/db/realma/myDB;shutdown=true</jpa.url>
                 <idp.https.port>9443</idp.https.port>
                 <idp.http.port>9080</idp.http.port>
+                <realm>realm-a</realm>
             </properties>
             <build>
                 <filters>
@@ -510,6 +512,7 @@
                 <jpa.url>jdbc:hsqldb:target/db/realmb/myDB;shutdown=true</jpa.url>
                 <idp.https.port>12346</idp.https.port>
                 <idp.http.port>12345</idp.http.port>
+                <realm>realm-b</realm>
             </properties>
             <build>
                 <filters>

http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/908ce2ba/services/idp/src/test/java/org/apache/cxf/fediz/service/idp/integrationtests/RestITTest.java
----------------------------------------------------------------------
diff --git a/services/idp/src/test/java/org/apache/cxf/fediz/service/idp/integrationtests/RestITTest.java
b/services/idp/src/test/java/org/apache/cxf/fediz/service/idp/integrationtests/RestITTest.java
index 6931633..8c02d11 100644
--- a/services/idp/src/test/java/org/apache/cxf/fediz/service/idp/integrationtests/RestITTest.java
+++ b/services/idp/src/test/java/org/apache/cxf/fediz/service/idp/integrationtests/RestITTest.java
@@ -45,6 +45,7 @@ import org.junit.Test;
 public class RestITTest {
         
     private static String idpHttpsPort;
+    private static String realm;
     private static Bus bus;
 
 
@@ -62,6 +63,9 @@ public class RestITTest {
 
         idpHttpsPort = System.getProperty("idp.https.port");
         Assert.assertNotNull("Property 'idp.https.port' null", idpHttpsPort);
+        
+        realm = System.getProperty("realm");
+        Assert.assertNotNull("Property 'realm' null", realm);
 
         SpringBusFactory bf = new SpringBusFactory();
         
@@ -81,7 +85,7 @@ public class RestITTest {
     
     @Test
     public void testGetAllIdps() throws UnsupportedEncodingException, MalformedURLException
{
-        String address = "https://localhost:" + idpHttpsPort + "/fediz-idp/services/rs";
+        String address = "https://localhost:" + idpHttpsPort + "/" + getContextName() + "/services/rs";
         Client client = ClientBuilder.newClient();
         Idps idps = client.target(address).path("idps")
             .request("application/xml").header("Authorization", getBasicAuthentication("admin",
"password"))
@@ -89,57 +93,96 @@ public class RestITTest {
         Assert.assertEquals(1L, idps.getIdps().size());
         
         Idp idp = idps.getIdps().iterator().next();
-        Assert.assertEquals("Certificate doesn't match",
-                            "stsKeystoreA.properties", idp.getCertificate());
-        Assert.assertEquals("Certificate password doesn't match",
-                            "realma", idp.getCertificatePassword());
-        Assert.assertEquals("Realm doesn't match",
-                            "urn:org:apache:cxf:fediz:idp:realm-A", idp.getRealm());
-        Assert.assertEquals("ServiceDescription doesn't match",
-                            "IDP of Realm A", idp.getServiceDescription());
-        Assert.assertEquals("ServiceDisplayName doesn't match",
-                            "REALM A", idp.getServiceDisplayName());
-        Assert.assertEquals("IdpUrl doesn't match",
-                            new URL("https://localhost:9443/fediz-idp/federation"), idp.getIdpUrl());
-        Assert.assertEquals("StsUrl doesn't match",
-                            new URL("https://localhost:9443/fediz-idp-sts/REALMA"), idp.getStsUrl());
-        Assert.assertEquals("Uri doesn't match",
-                            "realma", idp.getUri());
-        Assert.assertTrue("ProvideIDPList doesn't match", idp.isProvideIdpList());
-        Assert.assertTrue("UseCurrentIDP doesn't match", idp.isUseCurrentIdp());
-        Assert.assertEquals("Number of AuthenticationURIs doesn't match",
-                            4, idp.getAuthenticationURIs().size());
-        Assert.assertEquals("Number of SupportedProtocols doesn't match",
-                            2, idp.getSupportedProtocols().size());
-        Assert.assertEquals("Number of TokenTypesOffered doesn't match",
-                            2, idp.getTokenTypesOffered().size());
-        Assert.assertEquals("Number of applications doesn't match",
-                            1, idp.getApplications().size());
-        Assert.assertEquals("Number of trusted IDPs doesn't match",
-                            1, idp.getTrustedIdps().size());
-        Assert.assertEquals("Number of claims doesn't match",
-                            4, idp.getClaimTypesOffered().size());
+        if ("realm-a".equals(realm)) {
+            Assert.assertEquals("Certificate doesn't match",
+                                "stsKeystoreA.properties", idp.getCertificate());
+            Assert.assertEquals("Certificate password doesn't match",
+                                "realma", idp.getCertificatePassword());
+            Assert.assertEquals("Realm doesn't match",
+                                "urn:org:apache:cxf:fediz:idp:realm-A", idp.getRealm());
+            Assert.assertEquals("ServiceDescription doesn't match",
+                                "IDP of Realm A", idp.getServiceDescription());
+            Assert.assertEquals("ServiceDisplayName doesn't match",
+                                "REALM A", idp.getServiceDisplayName());
+            Assert.assertEquals("IdpUrl doesn't match",
+                                new URL("https://localhost:9443/fediz-idp/federation"), idp.getIdpUrl());
+            Assert.assertEquals("StsUrl doesn't match",
+                                new URL("https://localhost:9443/fediz-idp-sts/REALMA"), idp.getStsUrl());
+            Assert.assertEquals("Uri doesn't match",
+                                "realma", idp.getUri());
+            Assert.assertTrue("ProvideIDPList doesn't match", idp.isProvideIdpList());
+            Assert.assertTrue("UseCurrentIDP doesn't match", idp.isUseCurrentIdp());
+            Assert.assertEquals("Number of AuthenticationURIs doesn't match",
+                                4, idp.getAuthenticationURIs().size());
+            Assert.assertEquals("Number of SupportedProtocols doesn't match",
+                                2, idp.getSupportedProtocols().size());
+            Assert.assertEquals("Number of TokenTypesOffered doesn't match",
+                                2, idp.getTokenTypesOffered().size());
+            Assert.assertEquals("Number of applications doesn't match",
+                                2, idp.getApplications().size());
+            Assert.assertEquals("Number of trusted IDPs doesn't match",
+                                1, idp.getTrustedIdps().size());
+            Assert.assertEquals("Number of claims doesn't match",
+                                4, idp.getClaimTypesOffered().size());
+        } else {
+            Assert.assertEquals("Certificate doesn't match",
+                                "stsKeystoreB.properties", idp.getCertificate());
+            Assert.assertEquals("Certificate password doesn't match",
+                                "realmb", idp.getCertificatePassword());
+            Assert.assertEquals("Realm doesn't match",
+                                "urn:org:apache:cxf:fediz:idp:realm-B", idp.getRealm());
+            Assert.assertEquals("ServiceDescription doesn't match",
+                                "IDP of Realm B", idp.getServiceDescription());
+            Assert.assertEquals("ServiceDisplayName doesn't match",
+                                "REALM B", idp.getServiceDisplayName());
+            Assert.assertEquals("IdpUrl doesn't match",
+                                new URL("https://localhost:12443/fediz-idp-remote/federation"),
idp.getIdpUrl());
+            Assert.assertEquals("StsUrl doesn't match",
+                                new URL("https://localhost:12443/fediz-idp-sts/REALMB"),
idp.getStsUrl());
+            Assert.assertEquals("Uri doesn't match",
+                                "realmb", idp.getUri());
+            Assert.assertTrue("ProvideIDPList doesn't match", idp.isProvideIdpList());
+            Assert.assertTrue("UseCurrentIDP doesn't match", idp.isUseCurrentIdp());
+            Assert.assertEquals("Number of AuthenticationURIs doesn't match",
+                                4, idp.getAuthenticationURIs().size());
+            Assert.assertEquals("Number of SupportedProtocols doesn't match",
+                                2, idp.getSupportedProtocols().size());
+            Assert.assertEquals("Number of TokenTypesOffered doesn't match",
+                                2, idp.getTokenTypesOffered().size());
+            Assert.assertEquals("Number of applications doesn't match",
+                                1, idp.getApplications().size());
+            Assert.assertEquals("Number of claims doesn't match",
+                                4, idp.getClaimTypesOffered().size());
+        }
     }
 
     @Test
     public void testReadExistingIdpEmbeddedTrustedIdps() throws UnsupportedEncodingException
{
-        String address = "https://localhost:" + idpHttpsPort + "/fediz-idp/services/rs";
+        String address = "https://localhost:" + idpHttpsPort + "/" + getContextName() + "/services/rs";
         Client client = ClientBuilder.newClient();
-        Idp idp = client.target(address).path("idps/").path("urn:org:apache:cxf:fediz:idp:realm-A")
-            .request("application/xml").header("Authorization", getBasicAuthentication("admin",
"password"))
-            .get(Idp.class);
-        Assert.assertEquals("", "urn:org:apache:cxf:fediz:idp:realm-A", idp.getRealm());
+        
+        if ("realm-a".equals(realm)) {
+            Idp idp = client.target(address).path("idps/").path("urn:org:apache:cxf:fediz:idp:realm-A")
+                .request("application/xml").header("Authorization", getBasicAuthentication("admin",
"password"))
+                .get(Idp.class);
+            Assert.assertEquals("", "urn:org:apache:cxf:fediz:idp:realm-A", idp.getRealm());
+        } else {
+            Idp idp = client.target(address).path("idps/").path("urn:org:apache:cxf:fediz:idp:realm-B")
+                .request("application/xml").header("Authorization", getBasicAuthentication("admin",
"password"))
+                .get(Idp.class);
+            Assert.assertEquals("", "urn:org:apache:cxf:fediz:idp:realm-B", idp.getRealm());
+        }
     }
     
     @Test
     public void testAddClaimToApplication() throws UnsupportedEncodingException {
         
-        String address = "https://localhost:" + idpHttpsPort + "/fediz-idp/services/rs";
+        String address = "https://localhost:" + idpHttpsPort + "/" + getContextName() + "/services/rs";
         Client client = ClientBuilder.newClient();
         
-        String realm = "urn:org:apache:cxf:fediz:fedizhelloworld:testaddclaim";
+        String realmToAdd = "urn:org:apache:cxf:fediz:fedizhelloworld:testaddclaim";
         Application application = new Application();
-        application.setRealm(realm);
+        application.setRealm(realmToAdd);
         application.setEncryptionCertificate("");
         application.setLifeTime(3600);
         application.setProtocol("http://docs.oasis-open.org/wsfed/federation/200706");
@@ -158,12 +201,12 @@ public class RestITTest {
         requestClaim.setOptional(false);
         requestClaim.setClaimType(URI.create("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname"));
         
-        response = client.target(address).path("applications").path(realm).path("claims")
+        response = client.target(address).path("applications").path(realmToAdd).path("claims")
             .request("application/xml").header("Authorization", getBasicAuthentication("admin",
"password"))
             .post(Entity.entity(requestClaim, MediaType.APPLICATION_XML));
         Assert.assertEquals(Status.NO_CONTENT.getStatusCode(), response.getStatus());
         
-        application = client.target(address).path("applications").path(realm).queryParam("expand",
"claims")
+        application = client.target(address).path("applications").path(realmToAdd).queryParam("expand",
"claims")
             .request("application/xml").header("Authorization", getBasicAuthentication("admin",
"password"))
             .get(Application.class);
         Assert.assertEquals("Claims size should be 1 instead of " + application.getRequestedClaims().size(),
@@ -175,5 +218,11 @@ public class RestITTest {
         return "Basic " + Base64.encode(token.getBytes());
     }
 
+    private String getContextName() {
+        if ("realm-a".equals(realm)) {
+            return "fediz-idp";
+        }
+        return "fediz-idp-remote";
+    }
 
 }


Mime
View raw message