2 // Mono.Security.Protocol.Ntlm.Type1MessageTest
5 // Sebastien Pouliot (spouliot@motus.com)
7 // Copyright (C) 2003 Motus Technologies Inc. (http://www.motus.com)
13 using Mono.Security.Protocol.Ntlm;
14 using NUnit.Framework;
16 namespace MonoTests.Mono.Security.Protocol.Ntlm {
19 public class Type1MessageTest {
22 // Example from http://www.innovation.ch/java/ntlm.html
23 public void Encode1 ()
25 Type1Message msg = new Type1Message ();
26 Assert.AreEqual (1, msg.Type, "Type");
27 msg.Domain = "Ursa-Minor";
28 msg.Host = "LightCity";
29 Assert.AreEqual ("4E-54-4C-4D-53-53-50-00-01-00-00-00-07-B2-00-00-0A-00-0A-00-29-00-00-00-09-00-09-00-20-00-00-00-4C-49-47-48-54-43-49-54-59-55-52-53-41-2D-4D-49-4E-4F-52", BitConverter.ToString (msg.GetBytes ()), "GetBytes");
33 // Example from http://www.innovation.ch/java/ntlm.html
34 public void Decode1 ()
36 byte[] data = { 0x4e, 0x54, 0x4c, 0x4d, 0x53, 0x53, 0x50, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0xb2, 0x00, 0x00, 0x0a, 0x00, 0x0a, 0x00, 0x29, 0x00, 0x00, 0x00, 0x09, 0x00, 0x09, 0x00, 0x20, 0x00, 0x00, 0x00, 0x4c, 0x49, 0x47, 0x48, 0x54, 0x43, 0x49, 0x54, 0x59, 0x55, 0x52, 0x53, 0x41, 0x2d, 0x4d, 0x49, 0x4e, 0x4f, 0x52 };
37 Type1Message msg = new Type1Message (data);
38 Assert.AreEqual ("URSA-MINOR", msg.Domain, "Domain");
39 Assert.AreEqual ((NtlmFlags)0xb203, msg.Flags, "Flags");
40 Assert.AreEqual ("LIGHTCITY", msg.Host, "Host");
41 Assert.AreEqual (1, msg.Type, "Type");
45 // Example from http://davenport.sourceforge.net/ntlm.html#type1MessageExample
46 public void Decode2 ()
48 byte[] data = { 0x4e, 0x54, 0x4c, 0x4d, 0x53, 0x53, 0x50, 0x00, 0x01, 0x00, 0x00, 0x00, 0x07, 0x32, 0x00, 0x00, 0x06, 0x00, 0x06, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x0b, 0x00, 0x20, 0x00, 0x00, 0x00, 0x57, 0x4f, 0x52, 0x4b, 0x53, 0x54, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x44, 0x4f, 0x4d, 0x41, 0x49, 0x4e };
49 Type1Message msg = new Type1Message (data);
50 Assert.AreEqual ("DOMAIN", msg.Domain, "Domain");
51 Assert.AreEqual ((NtlmFlags)0x3207, msg.Flags, "Flags");
52 Assert.AreEqual ("WORKSTATION", msg.Host, "Host");
53 Assert.AreEqual (1, msg.Type, "Type");