public void TestExchangeCredentialPasswordEmpty() { using (var client = new LoginMechanism()) { Assert.AreEqual(SaslExchangeStatus.None, client.ExchangeStatus); client.Credential = new NetworkCredential("user", (string)null); byte[] serverChallenge = new byte[0]; byte[] clientResponse; Assert.AreEqual(SaslExchangeStatus.Continuing, client.Exchange(serverChallenge, out clientResponse)); Assert.AreEqual(SaslExchangeStatus.Continuing, client.ExchangeStatus); BytesAssert.AreEqual(client.Credential.UserName, clientResponse); Assert.AreEqual(SaslExchangeStatus.Failed, client.Exchange(serverChallenge, out clientResponse)); Assert.AreEqual(SaslExchangeStatus.Failed, client.ExchangeStatus); Assert.IsNull(clientResponse); try { client.Exchange(serverChallenge, out clientResponse); Assert.Fail("InvalidOperationException not thrown"); } catch (InvalidOperationException) { } } }
public void TestCredentialNotSet() { using (var client = new LoginMechanism()) { Assert.AreEqual(SaslExchangeStatus.None, client.ExchangeStatus); byte[] clientResponse; client.Exchange(new byte[0], out clientResponse); } }
public void TestIsPlainText() { Assert.IsTrue(SaslClientMechanism.IsMechanismPlainText("LOGIN")); using (var client = new LoginMechanism()) { Assert.IsTrue(client.IsPlainText); } }
public void TestGetInitialResponse() { using (var client = new LoginMechanism()) { Assert.AreEqual(SaslExchangeStatus.None, client.ExchangeStatus); Assert.IsTrue(client.ClientFirst); client.Credential = new NetworkCredential("user", "pass"); byte[] initialResponse; Assert.AreEqual(SaslExchangeStatus.Continuing, client.GetInitialResponse(out initialResponse)); Assert.AreEqual(SaslExchangeStatus.Continuing, client.ExchangeStatus); BytesAssert.AreEqual(client.Credential.UserName, initialResponse); } }