1 36 package org.columba.ristretto.auth.mechanism; 37 38 import java.io.IOException ; 39 40 import junit.framework.TestCase; 41 42 import org.columba.ristretto.auth.AuthenticationException; 43 import org.columba.ristretto.auth.AuthenticationMechanism; 44 45 public class PlainMechanismTest extends TestCase { 46 47 public void testOK() throws IOException { 48 TestAuthServer server = new TestAuthServer("\0test\0foo".getBytes()); 49 AuthenticationMechanism mechanism = new PlainMechanism(); 50 51 try { 52 mechanism.authenticate(server,"test","foo".toCharArray()); 53 } catch (AuthenticationException e) { 54 e.printStackTrace(); 55 } 56 57 assertTrue( server.isOk()); 58 } 59 60 public void testFailure() throws IOException { 61 TestAuthServer server = new TestAuthServer("\0test\0oo".getBytes()); 62 AuthenticationMechanism mechanism = new PlainMechanism(); 63 64 try { 65 mechanism.authenticate(server,"test","foo".toCharArray()); 66 } catch (AuthenticationException e) { 67 e.printStackTrace(); 68 } 69 70 assertFalse( server.isOk()); 71 } 72 } 73 | Popular Tags |