public void TestArgumentExceptions() { var credentials = new NetworkCredential("username", "password"); Assert.Throws <ArgumentNullException> (() => SaslMechanism.Create(null, Encoding.UTF8, credentials)); Assert.Throws <ArgumentNullException> (() => SaslMechanism.Create("PLAIN", null, credentials)); Assert.Throws <ArgumentNullException> (() => SaslMechanism.Create("PLAIN", Encoding.UTF8, null)); Assert.Throws <ArgumentNullException> (() => SaslMechanism.Create(null, credentials)); Assert.Throws <ArgumentNullException> (() => SaslMechanism.Create("PLAIN", null)); Assert.Throws <ArgumentNullException> (() => SaslMechanism.IsSupported(null)); Assert.Throws <ArgumentNullException> (() => SaslMechanism.SaslPrep(null)); }
public void TestIsSupported() { var supported = new [] { "PLAIN", "LOGIN", "CRAM-MD5", "DIGEST-MD5", "SCRAM-SHA-1", "SCRAM-SHA-256", "NTLM", "XOAUTH2" }; var unsupported = new [] { "ANONYMOUS", "GSSAPI", "KERBEROS_V4" }; var credentials = new NetworkCredential("username", "password"); var uri = new Uri("smtp://localhost"); foreach (var mechanism in supported) { Assert.IsTrue(SaslMechanism.IsSupported(mechanism), mechanism); var sasl = SaslMechanism.Create(mechanism, uri, credentials); Assert.IsNotNull(sasl, mechanism); Assert.AreEqual(mechanism, sasl.MechanismName, "MechanismName"); } foreach (var mechanism in unsupported) { Assert.IsFalse(SaslMechanism.IsSupported(mechanism), mechanism); } }
public void TestIsSupported() { var supported = new [] { "PLAIN", "LOGIN", "CRAM-MD5", "DIGEST-MD5", "SCRAM-SHA-1", "SCRAM-SHA-1-PLUS", "SCRAM-SHA-256", "SCRAM-SHA-256-PLUS", "SCRAM-SHA-512", "SCRAM-SHA-512-PLUS", "NTLM", "OAUTHBEARER", "XOAUTH2", "ANONYMOUS" }; var unsupported = new [] { "EXTERNAL", "GSSAPI", "KERBEROS_V4" }; var credentials = new NetworkCredential("username", "password"); foreach (var mechanism in supported) { Assert.IsTrue(SaslMechanism.IsSupported(mechanism), mechanism); var sasl = SaslMechanism.Create(mechanism, credentials); Assert.IsNotNull(sasl, mechanism); Assert.AreEqual(mechanism, sasl.MechanismName, "MechanismName"); sasl.Reset(); } foreach (var mechanism in unsupported) { Assert.IsFalse(SaslMechanism.IsSupported(mechanism), mechanism); } }