directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r168020 - /directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/spnego/codec/SpnegoTest.java
Date Tue, 03 May 2005 23:26:48 GMT
Author: elecharny
Date: Tue May  3 16:26:48 2005
New Revision: 168020

URL: http://svn.apache.org/viewcvs?rev=168020&view=rev
Log:
Added a test case with req Flags.

Modified:
    directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/spnego/codec/SpnegoTest.java

Modified: directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/spnego/codec/SpnegoTest.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/spnego/codec/SpnegoTest.java?rev=168020&r1=168019&r2=168020&view=diff
==============================================================================
--- directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/spnego/codec/SpnegoTest.java
(original)
+++ directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/spnego/codec/SpnegoTest.java
Tue May  3 16:26:48 2005
@@ -400,6 +400,99 @@
     }
 
     /**
+     * Test the decoding of a Spnego NegTokenInit with all req flags set to true .
+     */
+    public void testDecodeSpnegoNegTokenInitReqFlagsTrue()
+    {
+        Asn1Decoder spnegoDecoder = new SpnegoDecoder();
+
+        ByteBuffer  stream      = ByteBuffer.allocate( 0x0A );
+        stream.put(
+            new byte[]
+            {
+                (byte)0xA0, 0x08, 					// SPNEGO --> CHOICE {
+                									//     	negTokenInit  [0]  NegTokenInit
+                0x30, 0x06, 						// NegTokenInit ::= SEQUENCE {
+                (byte)0xA1, 0x04, 					// ContextFlags  OPTIONAL,
+                0x03, 0x02, 0x01, (byte)0xF7		// ContextFlags ::= BIT_STRING {
+													// delegFlag     (0),
+													// mutualFlag    (1),
+													// replayFlag    (2),
+													// sequenceFlag  (3),
+													// anonFlag      (4),
+													// confFlag      (5),
+													// integFlag     (6)
+            } );
+
+        stream.flip();
+
+        // Allocate a Spnego Container
+        IAsn1Container spnegoContainer = null;
+
+        try
+        {
+            spnegoContainer = ( IAsn1Container ) spnegoDecoder.allocate(
+                    SpnegoPoolEnum.SPNEGO_CONTAINER_POOL );
+        }
+        catch ( PoolException pe )
+        {
+            Assert.fail("Cannot allocat a SpnegoContainer : " + pe.getMessage());
+        }
+
+        spnegoContainer.setPoolManager( spnegoDecoder.getPoolManager() );
+
+        try
+        {
+            spnegoDecoder.decode( stream, spnegoContainer );
+        }
+        catch ( DecoderException de )
+        {
+            de.printStackTrace();
+            Assert.fail( de.getMessage() );
+        }
+    	
+        SpnegoPOJO spnego = ( ( SpnegoContainer ) spnegoContainer ).getSpnego();
+
+        // Checks the Oids
+        OID oids[] = ((SpnegoNegTokenInitPOJO)spnego).getMechTypeList();
+        int nbOids = 0;
+        
+        for ( int i = 0 ; i < oids.length ; i++ )
+        {
+            if (oids[i] == null)
+            {
+                break;
+            }
+            
+            nbOids ++;
+        }
+        
+        Assert.assertEquals(0, nbOids);
+        
+        // Check the reqFlags
+        Assert.assertEquals(true, ((SpnegoNegTokenInitPOJO)spnego).isAnonFlag());
+        Assert.assertEquals(true, ((SpnegoNegTokenInitPOJO)spnego).isConfFlag());
+        Assert.assertEquals(true, ((SpnegoNegTokenInitPOJO)spnego).isDelegFlag());
+        Assert.assertEquals(true, ((SpnegoNegTokenInitPOJO)spnego).isIntegFlag());
+        Assert.assertEquals(true, ((SpnegoNegTokenInitPOJO)spnego).isMutualFlag());
+        Assert.assertEquals(true, ((SpnegoNegTokenInitPOJO)spnego).isReplayFlag());
+        Assert.assertEquals(true, ((SpnegoNegTokenInitPOJO)spnego).isSequenceFlag());
+
+        // Check the mech token
+        OctetString mechToken = ((SpnegoNegTokenInitPOJO)spnego).getMechToken();
+        
+        Assert.assertEquals(null, mechToken);
+
+        // Check the mech list MIC
+        Assert.assertEquals(null, ((SpnegoNegTokenInitPOJO)spnego).getMechListMIC());
+
+        // Free the BindRequest Container. It will be put back in the IPool
+        // after being reset.
+        spnegoContainer.free();
+    }
+
+    
+    /**
      * Test the decoding of a Spnego NegTokenInit with an empty mech token .
      */
     public void testDecodeSpnegoNegTokenInitEmptyMechToken()



Mime
View raw message