Example #1
0
        public void TestExchange()
        {
            using (var client = new AnonymousMechanism()) {
            Assert.AreEqual(SaslExchangeStatus.None, client.ExchangeStatus);

            client.Credential = new NetworkCredential("sirhc", "passwordnotused");

            byte[] serverChallenge;
            byte[] clientResponse;

            serverChallenge = new byte[0];

            Assert.AreEqual(SaslExchangeStatus.Succeeded,
                        client.Exchange(serverChallenge, out clientResponse));

            Assert.AreEqual(SaslExchangeStatus.Succeeded, client.ExchangeStatus);

            BytesAssert.AreEqual(Convert.FromBase64String("c2lyaGM="),
                             clientResponse);

            try {
              client.Exchange(serverChallenge, out clientResponse);
              Assert.Fail("InvalidOperationException not thrown");
            }
            catch (InvalidOperationException) {
            }
              }
        }
Example #2
0
        public void TestExchangeCredentialUsernameEmpty()
        {
            using (var client = new AnonymousMechanism()) {
            Assert.AreEqual(SaslExchangeStatus.None, client.ExchangeStatus);

            client.Credential = new NetworkCredential();

            byte[] serverChallenge;
            byte[] clientResponse;

            serverChallenge = new byte[0];

            Assert.AreEqual(SaslExchangeStatus.Failed,
                        client.Exchange(serverChallenge, out clientResponse));
            Assert.IsNull(clientResponse);

            Assert.AreEqual(SaslExchangeStatus.Failed, client.ExchangeStatus);

            try {
              client.Exchange(serverChallenge, out clientResponse);
              Assert.Fail("InvalidOperationException not thrown");
            }
            catch (InvalidOperationException) {
            }
              }
        }
Example #3
0
        public void TestCredentialNotSet()
        {
            using (var client = new AnonymousMechanism()) {
            Assert.AreEqual(SaslExchangeStatus.None, client.ExchangeStatus);

            byte[] clientResponse;

            client.Exchange(new byte[0], out clientResponse);
              }
        }
Example #4
0
        public void TestGetInitialResponse()
        {
            using (var client = new AnonymousMechanism()) {
            Assert.AreEqual(SaslExchangeStatus.None, client.ExchangeStatus);

            Assert.IsTrue(client.ClientFirst);

            client.Credential = new NetworkCredential("sirhc", "passwordnotused");

            byte[] initialResponse;

            Assert.AreEqual(SaslExchangeStatus.Succeeded,
                        client.GetInitialResponse(out initialResponse));

            Assert.AreEqual(SaslExchangeStatus.Succeeded, client.ExchangeStatus);

            BytesAssert.AreEqual(Convert.FromBase64String("c2lyaGM="),
                             initialResponse);

            try {
              byte[] clientResponse;

              client.Exchange(new byte[0], out clientResponse);
              Assert.Fail("InvalidOperationException not thrown");
            }
            catch (InvalidOperationException) {
            }
              }
        }