directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vte...@apache.org
Subject svn commit: rev 57048 - incubator/directory/janus/trunk/sandbox/src/test/org/apache/janus/authorization
Date Tue, 09 Nov 2004 14:56:18 GMT
Author: vtence
Date: Tue Nov  9 06:56:17 2004
New Revision: 57048

Added:
   incubator/directory/janus/trunk/sandbox/src/test/org/apache/janus/authorization/DefaultAuthorizationControllerTest.java
Log:
Authorization service frontend (temporary naming)

Added: incubator/directory/janus/trunk/sandbox/src/test/org/apache/janus/authorization/DefaultAuthorizationControllerTest.java
==============================================================================
--- (empty file)
+++ incubator/directory/janus/trunk/sandbox/src/test/org/apache/janus/authorization/DefaultAuthorizationControllerTest.java
Tue Nov  9 06:56:17 2004
@@ -0,0 +1,69 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.janus.authorization;
+
+import junit.framework.TestCase;
+import org.apache.janus.authorization.effect.Effects;
+
+import javax.security.auth.Subject;
+
+public class DefaultAuthorizationControllerTest extends TestCase
+{
+    private DefaultAuthorizationController m_authorizer;
+
+    public static void main( String[] args )
+    {
+        junit.textui.TestRunner.run( DefaultAuthorizationControllerTest.class );
+    }
+
+    protected void setUp() throws Exception
+    {
+        m_authorizer = new DefaultAuthorizationController();
+    }
+
+    public void testTakesPositiveDecisionIfRuleSuggestsPermission()
+    {
+        m_authorizer.setRuleBase( new PrimitiveRule( Effects.GRANT ) );
+        assertTrue( m_authorizer.authorize( new Subject(), new SomePermission() ) );
+    }
+
+    public void testTakesPositiveDecisionIfRuleIsNotApplicable()
+    {
+        m_authorizer.setRuleBase( new PrimitiveRule( Effects.NOT_APPLICABLE ) );
+        assertTrue( m_authorizer.authorize( new Subject(), new SomePermission() ) );
+    }
+
+    public void testTakesNegativeDecisionIfRuleSuggestDenial()
+    {
+        m_authorizer.setRuleBase( new PrimitiveRule( Effects.DENY ) );
+        assertFalse( m_authorizer.authorize( new Subject(), new SomePermission() ) );
+    }
+
+    public void testCanForceEffectToGrantDecision()
+    {
+        m_authorizer.setRuleBase( new PrimitiveRule( Effects.DENY ) );
+        m_authorizer.grantOn( Effects.DENY );
+        assertTrue( m_authorizer.authorize( new Subject(), new SomePermission() ) );
+    }
+
+    public void testCanForceEffectToDenyDecision()
+    {
+        m_authorizer.setRuleBase( new PrimitiveRule( Effects.NOT_APPLICABLE ) );
+        m_authorizer.denyOn( Effects.NOT_APPLICABLE );
+        assertFalse( m_authorizer.authorize( new Subject(), new SomePermission() ) );
+    }
+}

Mime
View raw message