geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject cvs commit: incubator-geronimo/modules/security/src/test/org/apache/geronimo/security LoginPropertiesFileTest.java LoginSQLTest.java
Date Sun, 25 Jan 2004 01:47:30 GMT
adc         2004/01/24 17:47:30

  Modified:    modules/security/src/test/org/apache/geronimo/security
                        LoginPropertiesFileTest.java LoginSQLTest.java
  Log:
  Allow for tracking the subject by an id
  More tests
  
  Revision  Changes    Path
  1.2       +13 -5     incubator-geronimo/modules/security/src/test/org/apache/geronimo/security/LoginPropertiesFileTest.java
  
  Index: LoginPropertiesFileTest.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/security/src/test/org/apache/geronimo/security/LoginPropertiesFileTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LoginPropertiesFileTest.java	23 Jan 2004 06:47:08 -0000	1.1
  +++ LoginPropertiesFileTest.java	25 Jan 2004 01:47:30 -0000	1.2
  @@ -95,7 +95,6 @@
   
       public void testLogin() throws Exception {
   
  -        Subject subject = new Subject();
           CallbackHandler handler = new CallbackHandler() {
               public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException
{
                   for (int i = 0; i < callbacks.length; i++) {
  @@ -108,11 +107,20 @@
               }
   
           };
  -        LoginContext context = new LoginContext("Foo", subject, handler);
  +        LoginContext context = new LoginContext("Foo", handler);
   
           context.login();
  -        Subject rSubject = context.getSubject();
  -        assertTrue("expected non-null subject", rSubject != null);
  +        Subject subject = context.getSubject();
   
  +        assertTrue("expected non-null subject", subject != null);
  +        assertTrue("id of subject should be non-null", ContextManager.getSubjectId(subject)
!= null);
  +        assertTrue("subject should have two principals", subject.getPrincipals().size()
== 2);
  +        assertTrue("subject should have one realm principal", subject.getPrincipals(RealmPrincipal.class).size()
== 1);
  +        RealmPrincipal principal = (RealmPrincipal)subject.getPrincipals(RealmPrincipal.class).iterator().next();
  +        assertTrue("id of principal should be non-zero", principal.getId() != 0);
  +
  +        context.logout();
  +
  +        assertTrue("id of subject should be null", ContextManager.getSubjectId(subject)
== null);
       }
   }
  
  
  
  1.2       +13 -5     incubator-geronimo/modules/security/src/test/org/apache/geronimo/security/LoginSQLTest.java
  
  Index: LoginSQLTest.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/security/src/test/org/apache/geronimo/security/LoginSQLTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LoginSQLTest.java	23 Jan 2004 06:47:08 -0000	1.1
  +++ LoginSQLTest.java	25 Jan 2004 01:47:30 -0000	1.2
  @@ -145,7 +145,6 @@
   
       public void testLogin() throws Exception {
   
  -        Subject subject = new Subject();
           CallbackHandler handler = new CallbackHandler() {
               public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException
{
                   for (int i = 0; i < callbacks.length; i++) {
  @@ -158,11 +157,20 @@
               }
   
           };
  -        LoginContext context = new LoginContext("Foo", subject, handler);
  +        LoginContext context = new LoginContext("Foo", handler);
   
           context.login();
  -        Subject rSubject = context.getSubject();
  -        assertTrue("expected non-null subject", rSubject != null);
  +        Subject subject = context.getSubject();
  +
  +        assertTrue("expected non-null subject", subject != null);
  +        assertTrue("id of subject should be non-null", ContextManager.getSubjectId(subject)
!= null);
  +        assertTrue("subject should have two principals", subject.getPrincipals().size()
== 2);
  +        assertTrue("subject should have one realm principal", subject.getPrincipals(RealmPrincipal.class).size()
== 1);
  +        RealmPrincipal principal = (RealmPrincipal)subject.getPrincipals(RealmPrincipal.class).iterator().next();
  +        assertTrue("id of principal should be non-zero", principal.getId() != 0);
  +
           context.logout();
  +
  +        assertTrue("id of subject should be null", ContextManager.getSubjectId(subject)
== null);
       }
   }
  
  
  

Mime
View raw message