コード例 #1
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) {
            }
              }
        }
コード例 #2
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) {
            }
              }
        }
コード例 #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);
              }
        }
コード例 #4
0
ファイル: PlainMechanism.cs プロジェクト: pengyancai/cs-util
        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);
              }
        }
コード例 #5
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) {
            }
              }
        }
コード例 #6
0
        public void TestIsPlainText()
        {
            Assert.IsTrue(SaslClientMechanism.IsMechanismPlainText("ANONYMOUS"));

              using (var client = new AnonymousMechanism()) {
            Assert.IsTrue(client.IsPlainText);
              }
        }