You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by do...@apache.org on 2002/09/25 13:25:55 UTC
cvs commit: jakarta-avalon-excalibur/loader/src/test/org/apache/excalibur/policy/verifier/test VerifierTestCase.java config1.xml config2.xml config3.xml config4.xml
donaldp 2002/09/25 04:25:55
Added: loader/src/test/org/apache/excalibur/policy/verifier/test
VerifierTestCase.java config1.xml config2.xml
config3.xml config4.xml
Log:
Add unit tests for verifier
Revision Changes Path
1.1 jakarta-avalon-excalibur/loader/src/test/org/apache/excalibur/policy/verifier/test/VerifierTestCase.java
Index: VerifierTestCase.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.excalibur.policy.verifier.test;
import org.apache.excalibur.policy.metadata.PolicyMetaData;
import org.apache.excalibur.policy.test.AbstractPolicyTestCase;
import org.apache.excalibur.policy.verifier.PolicyVerifier;
/**
* TestCase for {@link org.apache.excalibur.policy.reader.PolicyReader}.
*
* @author <a href="mailto:peter at apache.org">Peter Donald</a>
*/
public class VerifierTestCase
extends AbstractPolicyTestCase
{
public VerifierTestCase( final String name )
{
super( name );
}
public void testConfig1()
throws Exception
{
try
{
verifyResource( "config1.xml" );
}
catch( final Throwable t )
{
return;
}
fail( "Expected verify to fail as specified " +
"bad name for keyStore" );
}
public void testConfig2()
throws Exception
{
try
{
verifyResource( "config2.xml" );
}
catch( final Throwable t )
{
return;
}
fail( "Expected verify to fail as permission " +
"references non existent keystore" );
}
public void testConfig3()
throws Exception
{
try
{
verifyResource( "config3.xml" );
}
catch( final Throwable t )
{
return;
}
fail( "Expected verify to fail as grant " +
"references non existent keystore" );
}
public void testConfig4()
throws Exception
{
try
{
verifyResource( "config4.xml" );
}
catch( final Throwable t )
{
return;
}
fail( "Expected verify to fail as specified " +
"action with null target" );
}
private void verifyResource( final String resource )
throws Exception
{
final PolicyMetaData defs = buildFromResource( resource );
final PolicyVerifier verifier = new PolicyVerifier();
verifier.verifyPolicy( defs );
}
}
1.1 jakarta-avalon-excalibur/loader/src/test/org/apache/excalibur/policy/verifier/test/config1.xml
Index: config1.xml
===================================================================
<policy version="1.0">
<keystore name="$myKeystore"
location="sar:/conf/keystore"
type="JKS"/>
</policy>
1.1 jakarta-avalon-excalibur/loader/src/test/org/apache/excalibur/policy/verifier/test/config2.xml
Index: config2.xml
===================================================================
<policy version="1.0">
<grant code-base="myCodeBase">
<permission class="java.io.FilePermission"
target="${/}tmp${/}*"
signed-by="Bob"
key-store="nonExistingKeystore"
action="read,write"/>
</grant>
</policy>
1.1 jakarta-avalon-excalibur/loader/src/test/org/apache/excalibur/policy/verifier/test/config3.xml
Index: config3.xml
===================================================================
<policy version="1.0">
<grant signed-by="Bob" key-store="nonExistentKeystore"
code-base="sar:/SAR-INF/lib/*">
<permission class="java.io.FilePermission"/>
</grant>
</policy>
1.1 jakarta-avalon-excalibur/loader/src/test/org/apache/excalibur/policy/verifier/test/config4.xml
Index: config4.xml
===================================================================
<policy version="1.0">
<grant code-base="sar:/SAR-INF/lib/*">
<permission class="java.io.FilePermission" action="BadActionValue"/>
</grant>
</policy>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>