SecurityMapConfigTestpublic final class SecurityMapConfigTest extends com.sun.enterprise.management.AMXTestBase
Fields Summary |
---|
private static final String | DEFAULT_BACKEND_PRINCIPAL | private static final String | DEFAULT_BACKEND_PASSWORD | private static final String[] | DEFAULT_PRINCIPALS | private static final String[] | DEFAULT_USERGROUPS | private static final String | CONNECTOR_DEF_NAME |
Constructors Summary |
---|
public SecurityMapConfigTest()
if ( checkNotOffline( "ensureDefaultInstance" ) )
{
ensureDefaultInstance( getDomainConfig() );
}
|
Methods Summary |
---|
public static com.sun.appserv.management.config.SecurityMapConfig | createInstance(com.sun.appserv.management.config.ConnectorConnectionPoolConfig ccpc, java.lang.String name, java.lang.String backendPrincipalUsername, java.lang.String backendPrincipalPassword, java.lang.String[] principals, java.lang.String[] userGroups)
final SecurityMapConfig smc =
ccpc.createSecurityMapConfig( name,
backendPrincipalUsername, backendPrincipalPassword,
principals, userGroups);
return smc;
| public static com.sun.appserv.management.config.SecurityMapConfig | ensureDefaultInstance(com.sun.appserv.management.config.DomainConfig domainConfig)
final ConnectorConnectionPoolConfig ccpc =
ConnectorConnectionPoolConfigTest.ensureDefaultInstance( domainConfig );
SecurityMapConfig result =
ccpc.getSecurityMapConfigMap().get( getDefaultInstanceName() );
if ( result == null )
{
result = createInstance( ccpc,
getDefaultInstanceName(),
DEFAULT_BACKEND_PRINCIPAL,
DEFAULT_BACKEND_PASSWORD,
DEFAULT_PRINCIPALS,
DEFAULT_USERGROUPS );
}
return result;
| public static java.lang.String | getDefaultInstanceName()
return getDefaultInstanceName( "SecurityMapConfig" );
| public void | testCreateRemove()
if ( ! checkNotOffline( "testDeleteLBConfig" ) )
{
return;
}
final String TEST_NAME = "SecurityMapConfigTest.testCreateRemove";
final ResourceAdapterConfig rac = ResourceAdapterConfigTest.createInstance(
getDomainConfig(), TEST_NAME );
try
{
final ConnectorConnectionPoolConfig ccpc =
ConnectorConnectionPoolConfigTest.createInstance( getDomainConfig(),
TEST_NAME,
CONNECTOR_DEF_NAME,
rac.getName(), null );
try
{
final String smcName = "SecurityMapConfigTest.testCreateRemove";
final String[] principals = new String[] { "SecurityMapConfigTest.testCreateRemove" };
final String[] userGroups = new String[ 0 ];
final SecurityMapConfig smc = createInstance(
ccpc,
smcName,
DEFAULT_BACKEND_PRINCIPAL,
DEFAULT_BACKEND_PASSWORD,
principals,
null );
try
{
assert( smcName.equals( smc.getName() ) );
assert( smc == ccpc.getSecurityMapConfigMap().get( smc.getName() ) );
testGetters( smc );
final Set<String> principalsBefore = GSetUtil.newSet( smc.getPrincipalNames() );
final String PRINCIPAL1 = "testCreateRemove.test1";
smc.createPrincipal( PRINCIPAL1 );
final Set<String> principalsAfter = GSetUtil.newSet( smc.getPrincipalNames() );
assert( principalsAfter.contains( PRINCIPAL1 ) );
smc.removePrincipal( PRINCIPAL1 );
assert( principalsBefore.equals( GSetUtil.newSet( smc.getPrincipalNames() ) ) );
}
finally
{
ccpc.removeSecurityMapConfig( smc.getName() );
}
}
finally
{
getDomainConfig().removeConnectorConnectionPoolConfig( ccpc.getName() );
}
}
finally
{
getDomainConfig().removeResourceAdapterConfig( rac.getName() );
}
| private void | testGetters(com.sun.appserv.management.config.SecurityMapConfig smc)
final String[] principalNames = smc.getPrincipalNames();
final String[] userGroupNames = smc.getUserGroupNames();
assert( principalNames != null || userGroupNames != null ) : "both principals and usergroups are null";
final BackendPrincipalConfig bpc = smc.getBackendPrincipalConfig();
assert( bpc != null );
final String s = bpc.getUserName();
bpc.setUserName( s );
final String password = bpc.getPassword();
bpc.setPassword( password );
|
|