[jboss-cvs] JBossAS SVN: r63887 - in projects/security/security-xacml/trunk/jboss-xacml/src/tests/org/jboss/test/security/xacml: config and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Jul 6 17:59:06 EDT 2007


Author: anil.saldhana at jboss.com
Date: 2007-07-06 17:59:06 -0400 (Fri, 06 Jul 2007)
New Revision: 63887

Added:
   projects/security/security-xacml/trunk/jboss-xacml/src/tests/org/jboss/test/security/xacml/core/
   projects/security/security-xacml/trunk/jboss-xacml/src/tests/org/jboss/test/security/xacml/core/JBossPDPUnitTestCase.java
Modified:
   projects/security/security-xacml/trunk/jboss-xacml/src/tests/org/jboss/test/security/xacml/config/JBossXACMLConfigUnitTestCase.java
Log:
SECURITY-60:xacml spi tests

Modified: projects/security/security-xacml/trunk/jboss-xacml/src/tests/org/jboss/test/security/xacml/config/JBossXACMLConfigUnitTestCase.java
===================================================================
--- projects/security/security-xacml/trunk/jboss-xacml/src/tests/org/jboss/test/security/xacml/config/JBossXACMLConfigUnitTestCase.java	2007-07-06 21:57:18 UTC (rev 63886)
+++ projects/security/security-xacml/trunk/jboss-xacml/src/tests/org/jboss/test/security/xacml/config/JBossXACMLConfigUnitTestCase.java	2007-07-06 21:59:06 UTC (rev 63887)
@@ -76,13 +76,14 @@
       assertEquals("1 PolicySet", 1, pst.size());
       PolicySetType psetType = pst.get(0);
       String loc = psetType.getLocation();
-      assertEquals("Location of PolicySet is file://SomeLocation", "file://SomeLocation", loc);
+      assertTrue("Location of PolicySet is >0", loc.length() > 0);
       assertEquals("PolicyType is null", 0,pts.getPolicy().size());
       
       //Validate Locators
       LocatorsType lts = pdp.getLocators();
       assertNotNull("LocatorsType != null", lts);
-      LocatorType lt = lts.getLocator();
+      List<LocatorType> lt = lts.getLocator();
       assertNotNull("LocatorType != null", lt);
+      assertEquals("LocatorType != null", 1,lt.size());
    } 
 }

Added: projects/security/security-xacml/trunk/jboss-xacml/src/tests/org/jboss/test/security/xacml/core/JBossPDPUnitTestCase.java
===================================================================
--- projects/security/security-xacml/trunk/jboss-xacml/src/tests/org/jboss/test/security/xacml/core/JBossPDPUnitTestCase.java	                        (rev 0)
+++ projects/security/security-xacml/trunk/jboss-xacml/src/tests/org/jboss/test/security/xacml/core/JBossPDPUnitTestCase.java	2007-07-06 21:59:06 UTC (rev 63887)
@@ -0,0 +1,90 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2007, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt in the distribution for a
+  * full listing of individual contributors.
+  *
+  * This is free software; you can redistribute it and/or modify it
+  * under the terms of the GNU Lesser General Public License as
+  * published by the Free Software Foundation; either version 2.1 of
+  * the License, or (at your option) any later version.
+  *
+  * This software is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  * Lesser General Public License for more details.
+  *
+  * You should have received a copy of the GNU Lesser General Public
+  * License along with this software; if not, write to the Free
+  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  */
+package org.jboss.test.security.xacml.core;
+
+import java.io.InputStream;
+
+import org.jboss.security.xacml.core.JBossPDP;
+import org.jboss.security.xacml.factories.RequestResponseContextFactory;
+import org.jboss.security.xacml.interfaces.PolicyDecisionPoint;
+import org.jboss.security.xacml.interfaces.RequestContext;
+import org.jboss.security.xacml.interfaces.ResponseContext;
+import org.jboss.security.xacml.interfaces.XACMLConstants;
+
+import junit.framework.TestCase;
+
+//$Id$
+
+/**
+ *  Unit tests for the JBossPDP
+ *  @author Anil.Saldhana at redhat.com
+ *  @since  Jul 6, 2007 
+ *  @version $Revision$
+ */
+public class JBossPDPUnitTestCase extends TestCase
+{ 
+   public void testInteropTest() throws Exception
+   {
+      ClassLoader tcl = Thread.currentThread().getContextClassLoader();
+      InputStream is = tcl.getResourceAsStream("test/config/interopPolicySetConfig.xml");
+      assertNotNull("InputStream != null", is);
+      PolicyDecisionPoint pdp = new JBossPDP(is);
+      assertNotNull("JBossPDP is != null", pdp);
+//http://www.oasis-open.org/committees/download.php/24475/xacml-2.0-core-interop-draft-12-04.doc
+/*
+ Test (Trade-limit)(Cred-line)(Curr-cred)(Req-tr-appr) (Req-cr-appr) (Num-shrs)(Buy-price)(Expected Decision
+ 1     10000   15000           10000       False        False         1000       10  Deny
+ 2     10000   15000           10000       False        False         1000       1    Permit
+ 3     10000   15000           10000       True         False         1000       5   Permit
+ 4     10000   15000           10000       True         False         1000       9   Deny
+ 5     10000   15000           10000       True         False         1000       10  Deny
+ 6     10000   15000           10000       True         False         1000       15  Deny
+ 7     10000   15000           10000       True         True          1000       10  Permit
+*/
+
+      assertEquals("Case 1 should be deny", XACMLConstants.DECISION_DENY,
+            getDecision(pdp,"test/requests/interop/scenario2-testcase1-request.xml"));
+      assertEquals("Case 2 should be deny", XACMLConstants.DECISION_PERMIT,
+            getDecision(pdp,"test/requests/interop/scenario2-testcase2-request.xml"));
+      assertEquals("Case 3 should be deny", XACMLConstants.DECISION_PERMIT,
+            getDecision(pdp,"test/requests/interop/scenario2-testcase3-request.xml"));
+      assertEquals("Case 4 should be deny", XACMLConstants.DECISION_DENY,
+            getDecision(pdp,"test/requests/interop/scenario2-testcase4-request.xml"));
+      assertEquals("Case 5 should be deny", XACMLConstants.DECISION_DENY,
+            getDecision(pdp,"test/requests/interop/scenario2-testcase5-request.xml"));
+      assertEquals("Case 6 should be deny", XACMLConstants.DECISION_DENY,
+            getDecision(pdp,"test/requests/interop/scenario2-testcase6-request.xml"));
+      assertEquals("Case 7 should be deny", XACMLConstants.DECISION_PERMIT,
+            getDecision(pdp,"test/requests/interop/scenario2-testcase7-request.xml"));
+   } 
+   
+   private int getDecision(PolicyDecisionPoint pdp, String loc) throws Exception
+   {
+      ClassLoader tcl = Thread.currentThread().getContextClassLoader();
+      InputStream is = tcl.getResourceAsStream(loc);
+      RequestContext request = RequestResponseContextFactory.createRequestCtx();
+      request.readRequest(is);
+      ResponseContext response = pdp.evaluate(request);
+      assertNotNull("Response is not null", response);
+      return response.getDecision(); 
+   }
+}




More information about the jboss-cvs-commits mailing list