public AuthResult TryToApply()
        {
            AuthResult result = AuthResult.Failed();

            _requestData.Value(SamlResponseKey, v => {
                try
                {
                    var xml = v.RawValue as string;
                    ProcessSamlResponseXml(xml);
                }
                catch (Exception e)
                {
                    _logger.Error("Saml Response handling failed", e);
                    _director.FailedUser();
                }

                result = _director.Result();
            });

            return(result);
        }
示例#2
0
        public async Task IncorrectedOrMissingCredentials_BadRequest()
        {
            // Arrange:
            var mockMessaging = MockMessagingService.Setup(results => {
                var expectedResult = AuthResult.Failed("INVALID_CONTEXT");
                results.RegisterResponse <AuthenticateCaller, AuthResult>(expectedResult);
            });

            var plugin     = new MockAppHostPlugin();
            var httpClient = TestHttpClient.Create(plugin, mockMessaging);

            // Act:
            var credentials = new AuthCredentialModel {
            };
            var result      = await httpClient.AuthenticateAsync(credentials);

            // Assert:
            Assert.Equal(HttpStatusCode.BadRequest, result.StatusCode);
            Assert.NotNull(result.Content);

            var content = await result.Content.ReadAsStringAsync();

            Assert.Equal("INVALID_CONTEXT", content);
        }
示例#3
0
        public void try_to_apply_fails_if_all_fail()
        {
            theStrategies.Each(x => x.Stub(o => o.TryToApply()).Return(AuthResult.Failed()));

            ClassUnderTest.TryToApply().Success.ShouldBeFalse();
        }