Exemplo n.º 1
0
        public void AuthenticationPasses()
        {
            var context = new OAuthContext {
                XAuthMode = "client_auth", XAuthUsername = "******", XAuthPassword = "******"
            };

            var inspector = new XAuthValidationInspector(ValidateXAuthMode, this.AuthenticateXAuthUsernameAndPassword);

            Assert.DoesNotThrow(() => inspector.InspectContext(ProviderPhase.CreateAccessToken, context));
        }
Exemplo n.º 2
0
        public void EmptyPasswordThrows()
        {
            var context = new OAuthContext {
                XAuthMode = "client_auth", XAuthUsername = "******"
            };

            var inspector = new XAuthValidationInspector(ValidateXAuthMode, this.AuthenticateXAuthUsernameAndPassword);
            var ex        = Assert.Throws <OAuthException>(() => inspector.InspectContext(ProviderPhase.CreateAccessToken, context));

            Assert.Equal("The x_auth_password parameter must be present", ex.Message);
        }
Exemplo n.º 3
0
        public void AuthenticationFailureThrows()
        {
            var context = new OAuthContext {
                XAuthMode = "client_auth", XAuthUsername = "******", XAuthPassword = "******"
            };

            var inspector = new XAuthValidationInspector(ValidateXAuthMode, this.AuthenticateXAuthUsernameAndPassword);
            var ex        = Assert.Throws <OAuthException>(() => inspector.InspectContext(ProviderPhase.CreateAccessToken, context));

            Assert.Equal("Authentication failed with the specified username and password", ex.Message);
        }
Exemplo n.º 4
0
        public void InvalidModeThrows()
        {
            var context = new OAuthContext {
                XAuthMode = "test_mode"
            };

            var inspector = new XAuthValidationInspector(ValidateXAuthMode, this.AuthenticateXAuthUsernameAndPassword);
            var ex        = Assert.Throws <OAuthException>(() => inspector.InspectContext(ProviderPhase.CreateAccessToken, context));

            Assert.Equal("The x_auth_mode parameter is invalid", ex.Message);
        }