1 17 package org.alfresco.filesys.server.auth.ntlm; 18 19 import junit.framework.TestCase; 20 21 26 public class NTLMMessageTest extends TestCase 27 { 28 31 public void testType1Message() 32 { 33 35 Type1NTLMMessage ntlmMsg = new Type1NTLMMessage(); 36 ntlmMsg.buildType1(0, null, null); 37 38 assertEquals("Minimal type 1 message length wrong", 16, ntlmMsg.getLength()); 39 assertFalse("Minimal type 1 message domain supplied flag set", ntlmMsg.hasFlag(NTLM.FlagDomainSupplied)); 40 assertFalse("Minimal type 1 message workstation supplied flag set", ntlmMsg.hasFlag(NTLM.FlagWorkstationSupplied)); 41 assertFalse("Minimal type 1 has domain", ntlmMsg.hasDomain()); 42 assertNull("Minimal type 1 domain not null", ntlmMsg.getDomain()); 43 assertFalse("Minimal type 1 has workstation", ntlmMsg.hasWorkstation()); 44 assertNull("Minimal type 1 workstation not null", ntlmMsg.getWorkstation()); 45 46 48 byte[] buf = new byte[256]; 49 ntlmMsg = new Type1NTLMMessage(buf, 128, 128); 50 ntlmMsg.buildType1(0, null, null); 51 52 assertEquals("Minimal type 1 message length wrong", 16, ntlmMsg.getLength()); 53 assertFalse("Minimal type 1 message domain supplied flag set", ntlmMsg.hasFlag(NTLM.FlagDomainSupplied)); 54 assertFalse("Minimal type 1 message workstation supplied flag set", ntlmMsg.hasFlag(NTLM.FlagWorkstationSupplied)); 55 assertFalse("Minimal type 1 has domain", ntlmMsg.hasDomain()); 56 assertNull("Minimal type 1 domain not null", ntlmMsg.getDomain()); 57 assertFalse("Minimal type 1 has workstation", ntlmMsg.hasWorkstation()); 58 assertNull("Minimal type 1 workstation not null", ntlmMsg.getWorkstation()); 59 60 62 String testDomain = "TESTDOMAIN"; 63 String testWks = "TESTPC"; 64 65 ntlmMsg = new Type1NTLMMessage(); 66 ntlmMsg.buildType1(0, testDomain, null); 67 68 assertTrue("Minimal type 1 message length wrong", ntlmMsg.getLength() > 16); 69 assertTrue("Minimal type 1 message domain supplied flag not set", ntlmMsg.hasFlag(NTLM.FlagDomainSupplied)); 70 assertFalse("Minimal type 1 message workstation supplied flag set", ntlmMsg.hasFlag(NTLM.FlagWorkstationSupplied)); 71 assertTrue("Minimal type 1 no domain", ntlmMsg.hasDomain()); 72 assertEquals("Minimal type 1 domain not correct", testDomain, ntlmMsg.getDomain()); 73 assertFalse("Minimal type 1 has workstation", ntlmMsg.hasWorkstation()); 74 assertNull("Minimal type 1 workstation not null", ntlmMsg.getWorkstation()); 75 76 78 ntlmMsg = new Type1NTLMMessage(buf, 128, 128); 79 ntlmMsg.buildType1(0, testDomain, null); 80 81 assertTrue("Minimal type 1 message length wrong", ntlmMsg.getLength() > 16); 82 assertTrue("Minimal type 1 message domain supplied flag not set", ntlmMsg.hasFlag(NTLM.FlagDomainSupplied)); 83 assertFalse("Minimal type 1 message workstation supplied flag set", ntlmMsg.hasFlag(NTLM.FlagWorkstationSupplied)); 84 assertTrue("Minimal type 1 no domain", ntlmMsg.hasDomain()); 85 assertEquals("Minimal type 1 domain not correct", testDomain, ntlmMsg.getDomain()); 86 assertFalse("Minimal type 1 has workstation", ntlmMsg.hasWorkstation()); 87 assertNull("Minimal type 1 workstation not null", ntlmMsg.getWorkstation()); 88 89 91 ntlmMsg = new Type1NTLMMessage(); 92 ntlmMsg.buildType1(0, null, testWks); 93 94 assertTrue("Minimal type 1 message length wrong", ntlmMsg.getLength() > 16); 95 assertFalse("Minimal type 1 message domain supplied flag set", ntlmMsg.hasFlag(NTLM.FlagDomainSupplied)); 96 assertTrue("Minimal type 1 message workstation supplied flag not set", ntlmMsg.hasFlag(NTLM.FlagWorkstationSupplied)); 97 assertFalse("Minimal type 1 has domain", ntlmMsg.hasDomain()); 98 assertNull("Minimal type 1 domain not null", ntlmMsg.getDomain()); 99 assertTrue("Minimal type 1 no workstation", ntlmMsg.hasWorkstation()); 100 assertEquals("Minimal type 1 workstation not correct", testWks, ntlmMsg.getWorkstation()); 101 102 104 ntlmMsg = new Type1NTLMMessage(buf, 128, 128); 105 ntlmMsg.buildType1(0, null, testWks); 106 107 assertTrue("Minimal type 1 message length wrong", ntlmMsg.getLength() > 16); 108 assertFalse("Minimal type 1 message domain supplied flag set", ntlmMsg.hasFlag(NTLM.FlagDomainSupplied)); 109 assertTrue("Minimal type 1 message workstation supplied flag not set", ntlmMsg.hasFlag(NTLM.FlagWorkstationSupplied)); 110 assertFalse("Minimal type 1 has domain", ntlmMsg.hasDomain()); 111 assertNull("Minimal type 1 domain not null", ntlmMsg.getDomain()); 112 assertTrue("Minimal type 1 no workstation", ntlmMsg.hasWorkstation()); 113 assertEquals("Minimal type 1 workstation not correct", testWks, ntlmMsg.getWorkstation()); 114 115 117 ntlmMsg = new Type1NTLMMessage(); 118 ntlmMsg.buildType1(0, testDomain, testWks); 119 120 assertTrue("Minimal type 1 message length wrong", ntlmMsg.getLength() > 16); 121 assertTrue("Minimal type 1 message domain supplied flag not set", ntlmMsg.hasFlag(NTLM.FlagDomainSupplied)); 122 assertTrue("Minimal type 1 message workstation supplied flag not set", ntlmMsg.hasFlag(NTLM.FlagWorkstationSupplied)); 123 assertTrue("Minimal type 1 has domain", ntlmMsg.hasDomain()); 124 assertEquals("Minimal type 1 domain not correct", testDomain, ntlmMsg.getDomain()); 125 assertTrue("Minimal type 1 no workstation", ntlmMsg.hasWorkstation()); 126 assertEquals("Minimal type 1 workstation not correct", testWks, ntlmMsg.getWorkstation()); 127 128 130 ntlmMsg = new Type1NTLMMessage(buf, 128, 128); 131 ntlmMsg.buildType1(0, testDomain, testWks); 132 133 assertTrue("Minimal type 1 message length wrong", ntlmMsg.getLength() > 16); 134 assertTrue("Minimal type 1 message domain supplied flag not set", ntlmMsg.hasFlag(NTLM.FlagDomainSupplied)); 135 assertTrue("Minimal type 1 message workstation supplied flag not set", ntlmMsg.hasFlag(NTLM.FlagWorkstationSupplied)); 136 assertTrue("Minimal type 1 has domain", ntlmMsg.hasDomain()); 137 assertEquals("Minimal type 1 domain not correct", testDomain, ntlmMsg.getDomain()); 138 assertTrue("Minimal type 1 no workstation", ntlmMsg.hasWorkstation()); 139 assertEquals("Minimal type 1 workstation not correct", testWks, ntlmMsg.getWorkstation()); 140 } 141 142 145 public void testType2Message() 146 { 147 } 149 150 153 public void testType3Message() 154 { 155 156 } 157 } 158 | Popular Tags |