using Microsoft.VisualStudio.TestTools.UnitTesting; using S22.Sasl.Mechanisms; using System.Text; namespace S22.Sasl.Test { /// /// Contains unit tests for the SASL CRAM-MD5 authentication mechanism. /// [TestClass] public class CramMd5Test { /// /// Verifies the various parts of a sample authentication exchange /// directly taken from RFC 2195 ("A.1.1. Example 1", p. 6). /// [TestMethod] [TestCategory("Cram-Md5")] public void VerifyAuthenticationExchange() { SaslMechanism m = new SaslCramMd5("joe", "tanstaaftanstaaf"); string initialServer = "<1896.697170952@postoffice.example.net>", expectedResponse = "joe 3dbc88f0624776a737b39093f6eb6427"; string initialResponse = Encoding.ASCII.GetString( m.GetResponse(Encoding.ASCII.GetBytes(initialServer))); Assert.AreEqual(expectedResponse, initialResponse); } } }