示例#1
0
        public void Valid_BasicAuthentication_Request()
        {
            var header = new BasicAuthenticationHeaderValue("client", "secret");

            var credential = _validator.ValidateHttpRequest(header, null);

            Assert.IsFalse(credential.IsMalformed);
            Assert.IsTrue(credential.IsPresent);
            Assert.AreEqual(Constants.ClientAuthenticationMethods.Basic, credential.Type);

            Assert.AreEqual("client", credential.ClientId);
            Assert.AreEqual("secret", credential.Secret);
        }
示例#2
0
        public void Valid_BasicAuthentication_Request()
        {
            var header = new BasicAuthenticationHeaderValue("client", "secret");

            var credential = _validator.ValidateHttpRequest(header, null);

            credential.IsMalformed.Should().BeFalse();
            credential.IsPresent.Should().BeTrue();
            credential.Type.Should().Be(Constants.ClientAuthenticationMethods.Basic);

            credential.ClientId.Should().Be("client");
            credential.Secret.Should().Be("secret");
        }
示例#3
0
        public void No_Client_Credentials()
        {
            var validator  = new ClientValidator(null, _logger);
            var credential = validator.ValidateHttpRequest(null, null);

            Assert.IsFalse(credential.IsMalformed);
            Assert.IsFalse(credential.IsPresent);
        }
示例#4
0
        public void BasicAuthentication_Request_With_Empty_Basic_Header()
        {
            var validator = new ClientValidator(null, _logger);
            var header    = new AuthenticationHeaderValue("Basic");

            var credential = validator.ValidateHttpRequest(header, null);

            Assert.IsTrue(credential.IsMalformed);
            Assert.IsFalse(credential.IsPresent);
        }
示例#5
0
        public void BasicAuthentication_Request_With_Malformed_Credentials_NoBase64_Encoding()
        {
            var validator = new ClientValidator(null, _logger);
            var header    = new AuthenticationHeaderValue("Basic", "somerandomdata");

            var credential = validator.ValidateHttpRequest(header, null);

            Assert.IsTrue(credential.IsMalformed);
            Assert.IsFalse(credential.IsPresent);
        }
示例#6
0
        public void BasicAuthentication_Request_With_Unknown_Scheme()
        {
            var validator = new ClientValidator(null, _logger);
            var header    = new AuthenticationHeaderValue("Unkown", "data");

            var credential = validator.ValidateHttpRequest(header, null);

            Assert.IsFalse(credential.IsMalformed);
            Assert.IsFalse(credential.IsPresent);
        }
示例#7
0
        public void BasicAuthentication_Request_With_Malformed_Credentials_Base64_Encoding_UserName_Only_With_Colon()
        {
            var validator = new ClientValidator(null, _logger);

            var invalidCred = "username:"******"Basic", encoded);

            var credential = validator.ValidateHttpRequest(header, null);

            Assert.IsTrue(credential.IsMalformed);
            Assert.IsFalse(credential.IsPresent);
        }
示例#8
0
        public void Valid_FormPost_Request()
        {
            var validator = new ClientValidator(null, _logger);
            var body      = new NameValueCollection();

            body.Add("client_id", "client");
            body.Add("client_secret", "secret");

            var credential = validator.ValidateHttpRequest(null, body);

            Assert.IsFalse(credential.IsMalformed);
            Assert.IsTrue(credential.IsPresent);
            Assert.AreEqual(Constants.ClientAuthenticationMethods.FormPost, credential.Type);

            Assert.AreEqual("client", credential.ClientId);
            Assert.AreEqual("secret", credential.Secret);
        }