(DISTFILES): Comment out a few missing files.
[mono-project.git] / mcs / class / Mono.Security / Test / Mono.Security.Protocol.Ntlm / ChallengeResponseTest.cs
blobba0f403e8a78b8a23117ec43c446fa1ec60b3240
1 //
2 // Mono.Security.Protocol.Ntlm.ChallengeResponseTest
3 //
4 // Author:
5 // Sebastien Pouliot (sebastien@ximian.com)
6 //
7 // Copyright (C) 2003 Motus Technologies Inc. (http://www.motus.com)
8 // Copyright (C) 2004 Novell (http://www.novell.com)
9 //
11 using System;
12 using System.Text;
14 using Mono.Security.Protocol.Ntlm;
15 using NUnit.Framework;
17 namespace MonoTests.Mono.Security.Protocol.Ntlm {
19 [TestFixture]
20 public class ChallengeResponseTest : Assertion {
22 [Test]
23 // Example from http://www.innovation.ch/java/ntlm.html
24 public void BeeblebroxSrvNonce ()
26 byte[] SrvNonce = Encoding.ASCII.GetBytes ("SrvNonce");
27 using (ChallengeResponse ntlm = new ChallengeResponse ("Beeblebrox", SrvNonce)) {
28 AssertEquals ("NT", "E0-E0-0D-E3-10-4A-1B-F2-05-3F-07-C7-DD-A8-2D-3C-48-9A-E9-89-E1-B0-00-D3", BitConverter.ToString (ntlm.NT));
29 AssertEquals ("LM", "AD-87-CA-6D-EF-E3-46-85-B9-C4-3C-47-7A-8C-42-D6-00-66-7D-68-92-E7-E8-97", BitConverter.ToString (ntlm.LM));
33 [Test]
34 // Example from http://packetstormsecurity.nl/Crackers/NT/l0phtcrack/l0phtcrack2.5-readme.html
35 public void L0phtCrack ()
37 byte[] SrvNonce = new byte [8] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 };
38 using (ChallengeResponse ntlm = new ChallengeResponse ("WELCOME", SrvNonce)) {
39 AssertEquals ("NT", "7A-CE-90-85-AB-CC-37-59-38-0B-1C-68-62-E3-98-C3-C0-EF-9C-FC-22-E8-A2-C2", BitConverter.ToString (ntlm.NT));
40 AssertEquals ("LM", "CA-12-00-72-3C-41-D5-77-AB-18-C7-64-C6-DE-F3-4F-A6-1B-FA-06-71-EA-5F-C8", BitConverter.ToString (ntlm.LM));
44 [Test]
45 public void NullPassword ()
47 byte[] SrvNonce = new byte [8] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 };
48 using (ChallengeResponse ntlm = new ChallengeResponse (null, SrvNonce)) {
49 AssertEquals ("NT", "4A-FD-81-EC-01-87-E8-8D-97-77-8D-F7-93-C6-DA-D4-F0-3A-36-63-66-9D-20-1C", BitConverter.ToString (ntlm.NT));
50 // note the last 8 bytes... they are the same as the previous unit test ;-)
51 AssertEquals ("LM", "0A-39-2B-11-CF-05-2B-02-6D-65-CF-F5-68-BD-E4-15-A6-1B-FA-06-71-EA-5F-C8", BitConverter.ToString (ntlm.LM));
55 [Test]
56 public void EmptyPassword ()
58 byte[] SrvNonce = new byte [8] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 };
59 using (ChallengeResponse ntlm = new ChallengeResponse (String.Empty, SrvNonce)) {
60 // same as the previous one as this is the same (null/empty) password expressed diffently
61 AssertEquals ("NT", "4A-FD-81-EC-01-87-E8-8D-97-77-8D-F7-93-C6-DA-D4-F0-3A-36-63-66-9D-20-1C", BitConverter.ToString (ntlm.NT));
62 AssertEquals ("LM", "0A-39-2B-11-CF-05-2B-02-6D-65-CF-F5-68-BD-E4-15-A6-1B-FA-06-71-EA-5F-C8", BitConverter.ToString (ntlm.LM));
66 [Test]
67 public void NoPropertiesOutput ()
69 ChallengeResponse ntlm = new ChallengeResponse ("Mono", new byte [8]);
70 // no out!
71 AssertNull ("Password", ntlm.Password);
72 AssertNull ("Challenge", ntlm.Challenge);
75 [Test]
76 [ExpectedException (typeof (ArgumentNullException))]
77 public void Challenge_Null ()
79 ChallengeResponse ntlm = new ChallengeResponse ();
80 ntlm.Challenge = null;
83 [Test]
84 [ExpectedException (typeof (ObjectDisposedException))]
85 public void Password_Disposed ()
87 ChallengeResponse ntlm = new ChallengeResponse ("Mono", new byte [8]);
88 ntlm.Dispose ();
89 ntlm.Password = "Mini";
92 [Test]
93 [ExpectedException (typeof (ObjectDisposedException))]
94 public void Challenge_Disposed ()
96 ChallengeResponse ntlm = new ChallengeResponse ("Mono", new byte [8]);
97 ntlm.Dispose ();
98 ntlm.Challenge = new byte [8];
101 [Test]
102 [ExpectedException (typeof (ObjectDisposedException))]
103 public void NT_Disposed ()
105 ChallengeResponse ntlm = new ChallengeResponse ("Mono", new byte [8]);
106 ntlm.Dispose ();
107 AssertNotNull ("NT", ntlm.NT);
110 [Test]
111 [ExpectedException (typeof (ObjectDisposedException))]
112 public void LM_Disposed ()
114 ChallengeResponse ntlm = new ChallengeResponse ("Mono", new byte [8]);
115 ntlm.Dispose ();
116 AssertNotNull ("LM", ntlm.LM);