[jboss-cvs] JBossAS SVN: r90070 - branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/testsecure.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Jun 10 19:36:00 EDT 2009
Author: scott.stark at jboss.org
Date: 2009-06-10 19:36:00 -0400 (Wed, 10 Jun 2009)
New Revision: 90070
Modified:
branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/testsecure/ProfileServiceUnitTestCase.java
Log:
JBAS-6982, add a test of passing security info using JndiLoginInitialContextFactory
Modified: branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/testsecure/ProfileServiceUnitTestCase.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/testsecure/ProfileServiceUnitTestCase.java 2009-06-10 23:33:24 UTC (rev 90069)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/testsecure/ProfileServiceUnitTestCase.java 2009-06-10 23:36:00 UTC (rev 90070)
@@ -24,9 +24,12 @@
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
+import java.util.Properties;
import java.util.Set;
+import javax.naming.Context;
import javax.naming.InitialContext;
+import javax.naming.NamingException;
import javax.security.auth.login.LoginContext;
import javax.security.auth.login.LoginException;
@@ -52,6 +55,15 @@
*/
public class ProfileServiceUnitTestCase extends AbstractProfileServiceTest
{
+ private static final String JNDI_LOGIN_INITIAL_CONTEXT_FACTORY = "org.jboss.security.jndi.JndiLoginInitialContextFactory";
+
+ private static final String SECURE_PROFILE_SERVICE_JNDI_NAME = "SecureProfileService/remote";
+ private static final String SECURE_MANAGEMENT_VIEW_JNDI_NAME = "SecureManagementView/remote";
+ private static final String SECURE_DEPLOYMENT_MANAGER_JNDI_NAME = "SecureDeploymentManager/remote";
+
+ private static final String PROFILE_SERVICE_PRINCIPAL = "javaduke";
+ private static final String PROFILE_SERVICE_CREDENTIALS = "anotherduke";
+
private LoginContext loginContext;
/**
@@ -211,6 +223,28 @@
logout();
}
+ /**
+ * Validate that there is only 1 DefaultDS ManagedComponent
+ * @throws Exception
+ */
+ public void testDefaultDSComponentCountUsingJLICF()
+ throws Exception
+ {
+ ManagementView mgtView = getManagementViewJLICF();
+ ComponentType type = new ComponentType("DataSource", "LocalTx");
+ Set<ManagedComponent> comps = mgtView.getComponentsForType(type);
+ int count = 0;
+ for (ManagedComponent comp : comps)
+ {
+ String cname = comp.getName();
+ if( cname.endsWith("DefaultDS") )
+ {
+ count ++;
+ }
+ }
+ assertEquals("There is 1 DefaultDS ManagedComponent", 1, 1);
+ }
+
// Private and protected
@Override
@@ -219,6 +253,22 @@
return "profileservice";
}
+ protected InitialContext getInitialContextJLICF()
+ throws NamingException
+ {
+ Properties env = new Properties();
+ env.setProperty(Context.INITIAL_CONTEXT_FACTORY, JNDI_LOGIN_INITIAL_CONTEXT_FACTORY);
+ env.setProperty(Context.SECURITY_PRINCIPAL, PROFILE_SERVICE_PRINCIPAL);
+ env.setProperty(Context.SECURITY_CREDENTIALS, PROFILE_SERVICE_CREDENTIALS);
+
+ InitialContext ctx = new InitialContext(env);
+ return ctx;
+ }
+ /**
+ *
+ * @return
+ * @throws Exception
+ */
protected ProfileService getProfileService()
throws Exception
{
@@ -228,6 +278,22 @@
ProfileService ps = (ProfileService) ref;
return ps;
}
+
+ /**
+ * Lookup of the ProfileService using a JNDI login InitialContextFactory
+ * @return
+ * @throws Exception
+ */
+ protected ProfileService getProfileServiceJLICF()
+ throws Exception
+ {
+ InitialContext ctx = getInitialContextJLICF();
+ Object ref = ctx.lookup(SECURE_PROFILE_SERVICE_JNDI_NAME);
+ log.debug(SECURE_PROFILE_SERVICE_JNDI_NAME+": "+ref);
+ ProfileService ps = (ProfileService) ref;
+ return ps;
+ }
+
@Override
protected ManagementView getManagementView()
throws Exception
@@ -236,6 +302,13 @@
ManagementView mgtView = (ManagementView) ctx.lookup("SecureManagementView/remote");
return mgtView;
}
+ protected ManagementView getManagementViewJLICF()
+ throws Exception
+ {
+ InitialContext ctx = getInitialContextJLICF();
+ ManagementView mgtView = (ManagementView) ctx.lookup("SecureManagementView/remote");
+ return mgtView;
+ }
/**
* Authenticates the client identified by the given {@code username} using the specified {@code password}.
More information about the jboss-cvs-commits
mailing list