public void ThrowsExceptionWhenAlgorithmMissing() { string challenge = "realm=\"elwood.innosoft.com\",nonce=\"asdasadsad\""; DigestSaslClient client = CreateClient(); client.EvaluateChallenge(Encoding.UTF8.GetBytes(challenge)); }
public void ThrowsExceptionWhenSecondChallengeInvalid() { string challenge = "realm=\"elwood.innosoft.com\",nonce=\"OA6MG9tEQGm2hh\",qop=\"auth\",algorithm=md5-sess,charset=utf-8"; DigestSaslClient client = CreateClient(); byte[] bresp = client.EvaluateChallenge(Encoding.UTF8.GetBytes(challenge)); Encoding.UTF8.GetString(bresp); // repeat challenge 1, which is incorrect client.EvaluateChallenge(Encoding.UTF8.GetBytes(challenge)); }
public void CanAuthenticate() { string challenge = "realm=\"elwood.innosoft.com\",nonce=\"OA6MG9tEQGm2hh\",qop=\"auth\",algorithm=md5-sess,charset=utf-8"; DigestSaslClient client = CreateClient(); client.Cnonce = "OA6MHXh6VqTrRk"; byte[] bresp = client.EvaluateChallenge(Encoding.UTF8.GetBytes(challenge)); string response = Encoding.UTF8.GetString(bresp); string expectedResp = "username=\"chris\",realm=\"elwood.innosoft.com\",nonce=\"OA6MG9tEQGm2hh\",cnonce=\"" + client.Cnonce + "\",nc=00000001,qop=auth,digest-uri=\"imap/elwood.innosoft.com\",response=\"d388dad90d4bbd760a152321f2143af7\",maxbuf=65536,charset=utf-8"; Assert.AreEqual(expectedResp, response); Assert.IsFalse(client.IsComplete); string challenge2 = "rspauth=ea40f60335c427b5527b84dbabcdfffd"; bresp = client.EvaluateChallenge(Encoding.UTF8.GetBytes(challenge2)); // client responds with zero-length array Assert.AreEqual(0, bresp.Length); Assert.IsTrue(client.IsComplete); }
public void ThrowsExceptionWhenChallengeIsMissing() { DigestSaslClient client = CreateClient(); client.EvaluateChallenge(null); }