[jboss-cvs] JBossAS SVN: r62952 - in projects/security/security-jboss-sx/trunk/src/tests/org/jboss/test: securitycontext and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu May 10 00:00:18 EDT 2007
Author: anil.saldhana at jboss.com
Date: 2007-05-10 00:00:17 -0400 (Thu, 10 May 2007)
New Revision: 62952
Removed:
projects/security/security-jboss-sx/trunk/src/tests/org/jboss/test/LoginContextTestCase.java
projects/security/security-jboss-sx/trunk/src/tests/org/jboss/test/SunConfigParserTestCase.java
projects/security/security-jboss-sx/trunk/src/tests/org/jboss/test/ldap/
Modified:
projects/security/security-jboss-sx/trunk/src/tests/org/jboss/test/PasswordHasher.java
projects/security/security-jboss-sx/trunk/src/tests/org/jboss/test/SecurityProviderlTestCase.java
projects/security/security-jboss-sx/trunk/src/tests/org/jboss/test/UtilTestCase.java
projects/security/security-jboss-sx/trunk/src/tests/org/jboss/test/securitycontext/SecurityContextBaseTest.java
Log:
move tests to JBAS/security
Deleted: projects/security/security-jboss-sx/trunk/src/tests/org/jboss/test/LoginContextTestCase.java
===================================================================
--- projects/security/security-jboss-sx/trunk/src/tests/org/jboss/test/LoginContextTestCase.java 2007-05-10 02:20:40 UTC (rev 62951)
+++ projects/security/security-jboss-sx/trunk/src/tests/org/jboss/test/LoginContextTestCase.java 2007-05-10 04:00:17 UTC (rev 62952)
@@ -1,318 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, 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;
-
-import java.util.Iterator;
-import java.util.Set;
-import javax.security.auth.login.Configuration;
-import javax.security.auth.login.LoginContext;
-import javax.security.auth.login.LoginException;
-import javax.security.auth.Subject;
-
-import junit.framework.TestCase;
-
-import org.jboss.security.auth.login.XMLLoginConfigImpl;
-import org.jboss.security.SimplePrincipal;
-
-public class LoginContextTestCase extends TestCase
-{
-
- public LoginContextTestCase(String name)
- {
- super(name);
- }
-
- protected void setUp() throws Exception
- {
- System.setOut(System.err);
- XMLLoginConfigImpl config = new XMLLoginConfigImpl();
- config.setConfigResource("login-config.xml");
- config.loadConfig();
- Configuration.setConfiguration(config);
- }
-
- private void validateSuccessfulLogin(LoginContext lc) throws LoginException
- {
- Subject subject = lc.getSubject();
- assertTrue("case5 subject != null", subject != null);
- boolean hasGuest = subject.getPrincipals().contains(new SimplePrincipal("guest"));
- assertTrue("subject has guest principal", hasGuest);
- lc.logout();
- hasGuest = subject.getPrincipals().contains(new SimplePrincipal("guest"));
- assertTrue("subject has guest principal", hasGuest == false);
- Set publicCreds = subject.getPublicCredentials();
- assertTrue("public creds has 'A public credential'",
- publicCreds.contains("A public credential"));
- Set privateCreds = subject.getPrivateCredentials();
- assertTrue("private creds has 'A private credential'",
- privateCreds.contains("A private credential"));
- Iterator iter = privateCreds.iterator();
- int count = 0;
- while( iter.hasNext() )
- {
- iter.next();
- count ++;
- }
- assertTrue("private creds has 1 entry", count == 1);
- }
-
- public void testCase1() throws Exception
- {
- LoginContext lc = new LoginContext("case1");
- lc.login();
- validateSuccessfulLogin(lc);
- }
-
- public void testCase2() throws Exception
- {
- LoginContext lc = new LoginContext("case2");
- lc.login();
- validateSuccessfulLogin(lc);
- }
-
- public void testCase3() throws Exception
- {
- LoginContext lc = new LoginContext("case3");
- try
- {
- lc.login();
- fail("LoginContext.login3 did not thrown an exception");
- }
- catch(LoginException e)
- {
- e.printStackTrace();
- }
- }
-
- /** This should fail because no login module succeeds
- *
- * @throws Exception
- */
- public void testCase4() throws Exception
- {
- LoginContext lc = new LoginContext("case4");
- try
- {
- lc.login();
- fail("LoginContext.login4 did not thrown an exception");
- }
- catch(LoginException e)
- {
- e.printStackTrace();
- }
- }
-
- public void testCase5() throws Exception
- {
- LoginContext lc = new LoginContext("case5");
- lc.login();
- validateSuccessfulLogin(lc);
- }
- public void testCase6() throws Exception
- {
- LoginContext lc = new LoginContext("case6");
- lc.login();
- validateSuccessfulLogin(lc);
- }
- public void testCase7() throws Exception
- {
- LoginContext lc = new LoginContext("case7");
- lc.login();
- validateSuccessfulLogin(lc);
- }
-
- public void testCase8() throws Exception
- {
- LoginContext lc = new LoginContext("case8");
- try
- {
- lc.login();
- fail("LoginContext.login8 did not thrown an exception");
- }
- catch(LoginException e)
- {
- e.printStackTrace();
- }
- }
-
- public void testCase9() throws Exception
- {
- LoginContext lc = new LoginContext("case9");
- lc.login();
- validateSuccessfulLogin(lc);
- }
-
- public void testCase10() throws Exception
- {
- LoginContext lc = new LoginContext("case10");
- try
- {
- lc.login();
- fail("LoginContext.login10 did not thrown an exception");
- }
- catch(LoginException e)
- {
- e.printStackTrace();
- }
- }
-
- public void testCase11() throws Exception
- {
- LoginContext lc = new LoginContext("case11");
- lc.login();
- validateSuccessfulLogin(lc);
- }
- public void testCase12() throws Exception
- {
- LoginContext lc = new LoginContext("case12");
- lc.login();
- validateSuccessfulLogin(lc);
- }
-
- public void testCase13() throws Exception
- {
- LoginContext lc = new LoginContext("case13");
- try
- {
- lc.login();
- fail("LoginContext.login13 did not thrown an exception");
- }
- catch(LoginException e)
- {
- e.printStackTrace();
- }
- }
-
- public void testCase14() throws Exception
- {
- LoginContext lc = new LoginContext("case14");
- try
- {
- lc.login();
- fail("LoginContext.login14 did not thrown an exception");
- }
- catch(LoginException e)
- {
- e.printStackTrace();
- }
- }
-
- public void testCase15() throws Exception
- {
- LoginContext lc = new LoginContext("case15");
- try
- {
- lc.login();
- fail("LoginContext.login15 did not thrown an exception");
- }
- catch(LoginException e)
- {
- e.printStackTrace();
- }
- }
-
- public void testCase16() throws Exception
- {
- LoginContext lc = new LoginContext("case16");
- lc.login();
- validateSuccessfulLogin(lc);
- }
-
- public void testCase17() throws Exception
- {
- LoginContext lc = new LoginContext("case17");
- lc.login();
- validateSuccessfulLogin(lc);
- }
-
- public void testCase18() throws Exception
- {
- LoginContext lc = new LoginContext("case18");
- try
- {
- lc.login();
- fail("LoginContext.login18 did not thrown an exception");
- }
- catch(LoginException e)
- {
- e.printStackTrace();
- }
- }
-
- public void testCase19() throws Exception
- {
- LoginContext lc = new LoginContext("case19");
- try
- {
- lc.login();
- fail("LoginContext.login19 did not thrown an exception");
- }
- catch(LoginException e)
- {
- e.printStackTrace();
- }
- }
-
- public void testCase20() throws Exception
- {
- LoginContext lc = new LoginContext("case20");
- try
- {
- lc.login();
- fail("LoginContext.login20 did not thrown an exception");
- }
- catch(LoginException e)
- {
- e.printStackTrace();
- }
- }
-
- public void testCase21() throws Exception
- {
- LoginContext lc = new LoginContext("case21");
- try
- {
- lc.login();
- }
- catch(LoginException e)
- {
- e.printStackTrace();
- }
- Subject subject = lc.getSubject();
- assertTrue("case21 subject == null", subject == null);
- }
-
- public void testCase22() throws Exception
- {
- LoginContext lc = new LoginContext("case22");
- try
- {
- lc.login();
- fail("LoginContext.login22 did not thrown an exception");
- }
- catch(LoginException e)
- {
- e.printStackTrace();
- }
- }
-
-}
Modified: projects/security/security-jboss-sx/trunk/src/tests/org/jboss/test/PasswordHasher.java
===================================================================
--- projects/security/security-jboss-sx/trunk/src/tests/org/jboss/test/PasswordHasher.java 2007-05-10 02:20:40 UTC (rev 62951)
+++ projects/security/security-jboss-sx/trunk/src/tests/org/jboss/test/PasswordHasher.java 2007-05-10 04:00:17 UTC (rev 62952)
@@ -21,8 +21,9 @@
*/
package org.jboss.test;
-import org.jboss.security.Util;
+import org.jboss.security.auth.spi.Util;
+
/** A utility program for generating password hashes given the hashAlgorithm,
hashEncoding, and hashCharset options used by the UsernamePasswordLoginModule.
The command line usage is:
Modified: projects/security/security-jboss-sx/trunk/src/tests/org/jboss/test/SecurityProviderlTestCase.java
===================================================================
--- projects/security/security-jboss-sx/trunk/src/tests/org/jboss/test/SecurityProviderlTestCase.java 2007-05-10 02:20:40 UTC (rev 62951)
+++ projects/security/security-jboss-sx/trunk/src/tests/org/jboss/test/SecurityProviderlTestCase.java 2007-05-10 04:00:17 UTC (rev 62952)
@@ -29,8 +29,8 @@
import junit.framework.TestCase;
import junit.framework.TestSuite;
-import org.jboss.crypto.JBossSXProvider;
-import org.jboss.security.Util;
+import org.jboss.crypto.CryptoUtil;
+import org.jboss.crypto.JBossSXProvider;
/** Tests of the org.jboss.crypto.* Java Cryptography Architecture plugin
classes
@@ -56,15 +56,15 @@
MessageDigest md = MessageDigest.getInstance("SHA-SRP");
byte[] test = "session_key".getBytes();
- byte[] hash1 = Util.sessionKeyHash(test);
- String hash1b64 = Util.encodeBase64(hash1);
+ byte[] hash1 = CryptoUtil.sessionKeyHash(test);
+ String hash1b64 = CryptoUtil.encodeBase64(hash1);
System.out.println("hash1 = "+hash1b64);
byte[] hash2 = md.digest(test);
- String hash2b64 = Util.encodeBase64(hash2);
+ String hash2b64 = CryptoUtil.encodeBase64(hash2);
System.out.println("hash2 = "+hash2b64);
super.assertTrue(hash1b64.equals(hash2b64) == false);
}
- /** This should match the Util.sessionKeyHash
+ /** This should match the CryptoUtil.sessionKeyHash
*/
public void testSHAReverseInterleave() throws Exception
{
@@ -72,11 +72,11 @@
MessageDigest md = MessageDigest.getInstance("SHA-SRP-Reverse");
byte[] test = "session_key".getBytes();
- byte[] hash1 = Util.sessionKeyHash(test);
- String hash1b64 = Util.encodeBase64(hash1);
+ byte[] hash1 = CryptoUtil.sessionKeyHash(test);
+ String hash1b64 = CryptoUtil.encodeBase64(hash1);
System.out.println("hash1 = "+hash1b64);
byte[] hash2 = md.digest(test);
- String hash2b64 = Util.encodeBase64(hash2);
+ String hash2b64 = CryptoUtil.encodeBase64(hash2);
System.out.println("hash2 = "+hash2b64);
super.assertEquals(hash1b64, hash2b64);
}
@@ -90,7 +90,7 @@
{
protected void setUp() throws Exception
{
- Util.init();
+ CryptoUtil.init();
JBossSXProvider provider = new JBossSXProvider();
Security.addProvider(provider);
}
Deleted: projects/security/security-jboss-sx/trunk/src/tests/org/jboss/test/SunConfigParserTestCase.java
===================================================================
--- projects/security/security-jboss-sx/trunk/src/tests/org/jboss/test/SunConfigParserTestCase.java 2007-05-10 02:20:40 UTC (rev 62951)
+++ projects/security/security-jboss-sx/trunk/src/tests/org/jboss/test/SunConfigParserTestCase.java 2007-05-10 04:00:17 UTC (rev 62952)
@@ -1,129 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, 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;
-
-import java.io.InputStreamReader;
-import java.net.URL;
-import javax.security.auth.login.AppConfigurationEntry;
-import javax.security.auth.login.AppConfigurationEntry.LoginModuleControlFlag;
-
-import junit.framework.TestCase;
-
-import org.jboss.security.auth.login.SunConfigParser;
-import org.jboss.security.auth.login.XMLLoginConfigImpl;
-
-/** Tests of the Sun login configuration file format parser
- *
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-public class SunConfigParserTestCase extends TestCase
-{
-
- public SunConfigParserTestCase(String name)
- {
- super(name);
- }
-
- /** Test the Sun config file parser directly.
- *
- * @throws Exception
- */
- public void testParser() throws Exception
- {
- XMLLoginConfigImpl config = new XMLLoginConfigImpl();
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- URL configURL = loader.getResource("login-config.conf");
- InputStreamReader configFile = new InputStreamReader(configURL.openStream());
- SunConfigParser.doParse(configFile, config, true);
-
- AppConfigurationEntry[] entry = config.getAppConfigurationEntry("case1");
- assertTrue("case1 entry != null", entry != null);
- assertTrue("case1.length == 2", entry.length == 2);
- assertTrue("case1[0].module == org.jboss.test.TestLoginModule",
- entry[0].getLoginModuleName().equals("org.jboss.test.TestLoginModule"));
- assertTrue("case1[0].flag == required",
- entry[0].getControlFlag() == LoginModuleControlFlag.REQUIRED);
- assertTrue("case1[0].option(name) == 1.1",
- entry[0].getOptions().get("name").equals("1.1"));
- assertTrue("case1[0].option(succeed) == true",
- entry[0].getOptions().get("succeed").equals("true"));
- assertTrue("case1[0].option(throwEx) == false",
- entry[0].getOptions().get("throwEx").equals("false"));
-
- entry = config.getAppConfigurationEntry("case2");
- assertTrue("case2 entry != null", entry != null);
- assertTrue("case2.length == 2", entry.length == 2);
- assertTrue("case2[0].module = org.jboss.test.TestLoginModule",
- entry[0].getLoginModuleName().equals("org.jboss.test.TestLoginModule"));
- assertTrue("case2[0].flag == optional",
- entry[0].getControlFlag() == LoginModuleControlFlag.OPTIONAL);
- assertTrue("case2[1].option(name) == 2.2",
- entry[1].getOptions().get("name").equals("2.2"));
- assertTrue("case2[1].option(succeed) == false",
- entry[1].getOptions().get("succeed").equals("false"));
- assertTrue("case2[1].option(throwEx) == true",
- entry[1].getOptions().get("throwEx").equals("true"));
- }
-
- /** Test the Sun config file parser by creating a XMLLoginConfig with a
- * URL pointing to a Sun format config file.
- *
- * @throws Exception
- */
- public void testSunLoginConfig() throws Exception
- {
- XMLLoginConfigImpl config = new XMLLoginConfigImpl();
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- URL configURL = loader.getResource("login-config.conf");
- config.setConfigURL(configURL);
- config.loadConfig();
-
- AppConfigurationEntry[] entry = config.getAppConfigurationEntry("case1");
- assertTrue("case1 entry != null", entry != null);
- assertTrue("case1.length == 2", entry.length == 2);
- assertTrue("case1[0].module == org.jboss.test.TestLoginModule",
- entry[0].getLoginModuleName().equals("org.jboss.test.TestLoginModule"));
- assertTrue("case1[0].flag == required",
- entry[0].getControlFlag() == LoginModuleControlFlag.REQUIRED);
- assertTrue("case1[0].option(name) == 1.1",
- entry[0].getOptions().get("name").equals("1.1"));
- assertTrue("case1[0].option(succeed) == true",
- entry[0].getOptions().get("succeed").equals("true"));
- assertTrue("case1[0].option(throwEx) == false",
- entry[0].getOptions().get("throwEx").equals("false"));
-
- entry = config.getAppConfigurationEntry("case2");
- assertTrue("case2 entry != null", entry != null);
- assertTrue("case2.length == 2", entry.length == 2);
- assertTrue("case2[0].module = org.jboss.test.TestLoginModule",
- entry[0].getLoginModuleName().equals("org.jboss.test.TestLoginModule"));
- assertTrue("case2[0].flag == optional",
- entry[0].getControlFlag() == LoginModuleControlFlag.OPTIONAL);
- assertTrue("case2[1].option(name) == 2.2",
- entry[1].getOptions().get("name").equals("2.2"));
- assertTrue("case2[1].option(succeed) == false",
- entry[1].getOptions().get("succeed").equals("false"));
- assertTrue("case2[1].option(throwEx) == true",
- entry[1].getOptions().get("throwEx").equals("true"));
- }
-}
Modified: projects/security/security-jboss-sx/trunk/src/tests/org/jboss/test/UtilTestCase.java
===================================================================
--- projects/security/security-jboss-sx/trunk/src/tests/org/jboss/test/UtilTestCase.java 2007-05-10 02:20:40 UTC (rev 62951)
+++ projects/security/security-jboss-sx/trunk/src/tests/org/jboss/test/UtilTestCase.java 2007-05-10 04:00:17 UTC (rev 62952)
@@ -20,16 +20,15 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.test;
+
-import javax.mail.internet.MimeUtility;
-
import junit.framework.TestCase;
import junit.framework.TestSuite;
+
+import org.jboss.security.SecurityUtil;
+import org.jboss.crypto.CryptoUtil;
-import org.jboss.security.Util;
-import org.jboss.util.Base64;
-
-/** Tests of the org.jboss.security.Util class
+/** Tests of the org.jboss.security.CryptoUtil class
@author Scott.Stark at jboss.org
@version $Revision$
@@ -41,31 +40,31 @@
super(name);
}
- /** Compare Util.encodeBase64 against the sun misc class
+ /** Compare CryptoUtil.encodeBase64 against the sun misc class
*/
public void testBase64() throws Exception
{
System.out.println("testBase64");
byte[] test = "echoman".getBytes();
- String b64_1 = Util.encodeBase64(test);
+ String b64_1 = CryptoUtil.encodeBase64(test);
//String b64_1 = Base64.encodeBytes(test);
System.out.println("b64_1 = "+b64_1);
- //Anil: I think the MimeUtility.encodeText is broken
+ //Anil: I think the MimeCryptoUtility.encodeText is broken
/*
- String b64_2 = MimeUtility.encodeText("echoman", "iso-8859-1", "B");
+ String b64_2 = MimeCryptoUtility.encodeText("echoman", "iso-8859-1", "B");
System.out.println("b64_2 = "+b64_2);
super.assertEquals("encodeBase64 == BASE64Encoder", b64_1, b64_2);*/
}
- /** Compare Util.encodeBase16 against the java.math.BigInteger class
+ /** Compare CryptoUtil.encodeBase16 against the java.math.BigInteger class
*/
public void testBase16() throws Exception
{
System.out.println("testBase16");
byte[] test = "echoman".getBytes();
- String b16_1 = Util.encodeBase16(test);
+ String b16_1 = CryptoUtil.encodeBase16(test);
System.out.println("b16_1 = "+b16_1);
java.math.BigInteger encoder = new java.math.BigInteger(test);
@@ -76,9 +75,9 @@
public void testUnPrefixSecurityDomain() throws Exception
{
- assertEquals("sd==sd", "sd",Util.unprefixSecurityDomain("sd"));
- assertEquals("java:/jaas/sd==sd","sd", Util.unprefixSecurityDomain("java:/jaas/sd"));
- assertEquals("java:/jbsx/sd==sd","sd", Util.unprefixSecurityDomain("java:/jbsx/sd"));
+ assertEquals("sd==sd", "sd", SecurityUtil.unprefixSecurityDomain("sd"));
+ assertEquals("java:/jaas/sd==sd","sd", SecurityUtil.unprefixSecurityDomain("java:/jaas/sd"));
+ assertEquals("java:/jbsx/sd==sd","sd", SecurityUtil.unprefixSecurityDomain("java:/jbsx/sd"));
}
public static void main(java.lang.String[] args)
Modified: projects/security/security-jboss-sx/trunk/src/tests/org/jboss/test/securitycontext/SecurityContextBaseTest.java
===================================================================
--- projects/security/security-jboss-sx/trunk/src/tests/org/jboss/test/securitycontext/SecurityContextBaseTest.java 2007-05-10 02:20:40 UTC (rev 62951)
+++ projects/security/security-jboss-sx/trunk/src/tests/org/jboss/test/securitycontext/SecurityContextBaseTest.java 2007-05-10 04:00:17 UTC (rev 62952)
@@ -24,8 +24,7 @@
import java.security.Principal;
import java.util.List;
-import org.jboss.security.SimplePrincipal;
-import org.jboss.security.Util;
+import org.jboss.security.SimplePrincipal;
import org.jboss.security.config.ApplicationPolicy;
import org.jboss.security.config.RoleMappingInfo;
import org.jboss.security.config.SecurityConfiguration;
@@ -54,7 +53,7 @@
{
ApplicationPolicy ap = createApplicationPolicy(null);
SecurityConfiguration.addApplicationPolicy(securityDomain, ap);
- assertEquals(Util.getApplicationPolicy(securityDomain), ap);
+ assertEquals(SecurityConfiguration.getApplicationPolicy(securityDomain), ap);
}
protected JBossSecurityContext getSC(String domain)
More information about the jboss-cvs-commits
mailing list