Esempio n. 1
0
        public void TestCredentialNotSet()
        {
            using (var client = new PlainMechanism()) {
            Assert.AreEqual(SaslExchangeStatus.None, client.ExchangeStatus);

            byte[] clientResponse;

            client.Exchange(new byte[0], out clientResponse);
              }
        }
Esempio n. 2
0
        public void TestExchangeWithoutAuthcid()
        {
            using (var client = new PlainMechanism()) {
            Assert.AreEqual(SaslExchangeStatus.None, client.ExchangeStatus);

            client.Credential = new NetworkCredential("tim", "tanstaaftanstaaf");

            byte[] clientResponse;

            Assert.AreEqual(SaslExchangeStatus.Succeeded,
                        client.Exchange(new byte[0], out clientResponse));
            Assert.AreEqual(SaslExchangeStatus.Succeeded, client.ExchangeStatus);

            BytesAssert.AreEqual("\0tim\0tanstaaftanstaaf", clientResponse);
              }
        }
Esempio n. 3
0
        public void TestExchangeWithAuthcid()
        {
            using (var client = new PlainMechanism()) {
            client.Credential = new NetworkCredential("Kurt", "xipj3plmq", "Ursel");

            byte[] serverChallenge = new byte[0];
            byte[] clientResponse;

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

            BytesAssert.AreEqual("Ursel\0Kurt\0xipj3plmq", clientResponse);

            try {
              client.Exchange(serverChallenge, out clientResponse);
              Assert.Fail("InvalidOperationException not thrown");
            }
            catch (InvalidOperationException) {
            }
              }
        }
Esempio n. 4
0
        public void TestGetInitialResponse()
        {
            using (var client = new PlainMechanism()) {
            Assert.AreEqual(SaslExchangeStatus.None, client.ExchangeStatus);

            Assert.IsTrue(client.ClientFirst);

            client.Credential = new NetworkCredential("test", "test", "test");

            byte[] initialResponse;

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

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

            try {
              byte[] clientResponse;

              client.Exchange(new byte[0], out clientResponse);
              Assert.Fail("InvalidOperationException not thrown");
            }
            catch (InvalidOperationException) {
            }
              }
        }
Esempio n. 5
0
        private void ExchangeEmptyCredentialProperty(NetworkCredential credential)
        {
            using (var client = new PlainMechanism()) {
            Assert.AreEqual(SaslExchangeStatus.None, client.ExchangeStatus);

            client.Credential = credential;

            byte[] serverChallenge = new byte[0];
            byte[] 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) {
            }
              }
        }
Esempio n. 6
0
        public void TestIsPlainText()
        {
            Assert.IsTrue(SaslClientMechanism.IsMechanismPlainText("PLAIN"));

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