Ejemplo n.º 1
0
        public void TestInitialize()
        {
            using (var client = new AnonymousMechanism()) {
            client.Credential = new NetworkCredential("test", "test", "test");

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

            byte[] initialResponseFirst;

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

            client.Initialize();

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

            byte[] initialResponseSecond;

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

            Assert.AreEqual(initialResponseFirst, initialResponseSecond);
              }
        }
Ejemplo n.º 2
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) {
            }
              }
        }