cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From owu...@apache.org
Subject svn commit: r1565827 - in /cxf/fediz/trunk/services/idp/src: main/java/org/apache/cxf/fediz/service/idp/rest/ApplicationServiceImpl.java test/java/org/apache/cxf/fediz/service/idp/integrationtests/RestITTest.java
Date Fri, 07 Feb 2014 22:02:14 GMT
Author: owulff
Date: Fri Feb  7 22:02:13 2014
New Revision: 1565827

URL: http://svn.apache.org/r1565827
Log:
Fix in REST service when adding claims to application

Modified:
    cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/rest/ApplicationServiceImpl.java
    cxf/fediz/trunk/services/idp/src/test/java/org/apache/cxf/fediz/service/idp/integrationtests/RestITTest.java

Modified: cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/rest/ApplicationServiceImpl.java
URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/rest/ApplicationServiceImpl.java?rev=1565827&r1=1565826&r2=1565827&view=diff
==============================================================================
--- cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/rest/ApplicationServiceImpl.java
(original)
+++ cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/rest/ApplicationServiceImpl.java
Fri Feb  7 22:02:13 2014
@@ -123,7 +123,7 @@ public class ApplicationServiceImpl impl
         Claim foundClaim = claimDAO.getClaim(claim.getClaimType().toString());
         RequestClaim rc = new RequestClaim(foundClaim);
         application.getRequestedClaims().add(rc);
-        applicationDAO.updateApplication(realm, application);
+        applicationDAO.addClaimToApplication(application, claim);
         
         return Response.noContent().build();
     }
@@ -144,7 +144,7 @@ public class ApplicationServiceImpl impl
             throw new WebApplicationException(Status.NOT_FOUND);
         }
         application.getRequestedClaims().remove(foundItem);
-        applicationDAO.updateApplication(realm, application);
+        applicationDAO.removeClaimFromApplication(application, foundItem);
         
         return Response.noContent().build();
     }

Modified: cxf/fediz/trunk/services/idp/src/test/java/org/apache/cxf/fediz/service/idp/integrationtests/RestITTest.java
URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/services/idp/src/test/java/org/apache/cxf/fediz/service/idp/integrationtests/RestITTest.java?rev=1565827&r1=1565826&r2=1565827&view=diff
==============================================================================
--- cxf/fediz/trunk/services/idp/src/test/java/org/apache/cxf/fediz/service/idp/integrationtests/RestITTest.java
(original)
+++ cxf/fediz/trunk/services/idp/src/test/java/org/apache/cxf/fediz/service/idp/integrationtests/RestITTest.java
Fri Feb  7 22:02:13 2014
@@ -18,14 +18,21 @@
  */
 package org.apache.cxf.fediz.service.idp.integrationtests;
 
+import java.net.URI;
 import java.net.URL;
 
 import javax.ws.rs.client.Client;
 import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.fediz.service.idp.domain.Application;
 import org.apache.cxf.fediz.service.idp.domain.Idp;
+import org.apache.cxf.fediz.service.idp.domain.RequestClaim;
 import org.apache.cxf.fediz.service.idp.rest.Idps;
 import org.junit.AfterClass;
 import org.junit.Assert;
@@ -108,9 +115,8 @@ public class RestITTest {
                             1, idp.getTrustedIdps().size());
         Assert.assertEquals("Number of claims doesn't match",
                             4, idp.getClaimTypesOffered().size());
-        
     }
-    
+
     @Test
     public void testReadExistingIdpEmbeddedTrustedIdps() {
         String address = "https://localhost:" + idpHttpsPort + "/fediz-idp/services/rs";
@@ -119,7 +125,42 @@ public class RestITTest {
             .request("application/xml").get(Idp.class);
         Assert.assertEquals("", "urn:org:apache:cxf:fediz:idp:realm-A", idp.getRealm());
     }
-
-    
     
+    @Test
+    public void testAddClaimToApplication() {
+        
+        String address = "https://localhost:" + idpHttpsPort + "/fediz-idp/services/rs";
+        Client client = ClientBuilder.newClient();
+        
+        String realm = "urn:org:apache:cxf:fediz:fedizhelloworld:testaddclaim";
+        Application application = new Application();
+        application.setRealm(realm);
+        application.setEncryptionCertificate("");
+        application.setLifeTime("3600");
+        application.setProtocol("http://docs.oasis-open.org/wsfed/federation/200706");
+        application.setRole("ApplicationServiceType");
+        application.setServiceDescription("Fedizhelloworld description");
+        application.setServiceDisplayName("Fedizhelloworld");
+        application.setTokenType("http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV2.0");
+        
+        Response response = client.target(address).path("applications/")
+            .request("application/xml").post(Entity.entity(application, MediaType.APPLICATION_XML));
+        Assert.assertEquals(Status.CREATED.getStatusCode(), response.getStatus());
+        
+        //Testcase
+        RequestClaim requestClaim = new RequestClaim();
+        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")
+            .request("application/xml").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")
+            .request("application/xml").get(Application.class);
+        Assert.assertEquals("Claims size should be 1 instead of " + application.getRequestedClaims().size(),
+                            1, application.getRequestedClaims().size());
+    }
+
+
 }



Mime
View raw message