Beispiel #1
0
        public async Task FailsToCreateAuthorizationRequest_ResponseType_HasInvalidValues()
        {
            // Arrange
            var parameters =
                new Dictionary <string, string[]>
            {
                [OpenIdConnectParameterNames.State]        = new[] { "state" },
                [OpenIdConnectParameterNames.ClientId]     = new[] { "a" },
                [OpenIdConnectParameterNames.RedirectUri]  = new[] { "http://www.example.com/callback" },
                [OpenIdConnectParameterNames.ResponseType] = new[] { "invalid" }
            };
            var expectedError = new AuthorizationRequestError(ProtocolErrorProvider.InvalidParameterValue("invalid", OpenIdConnectParameterNames.ResponseType), null, null);

            expectedError.Message.State = "state";

            var factory = CreateAuthorizationRequestFactory();

            // Act
            var result = await factory.CreateAuthorizationRequestAsync(parameters);

            // Assert
            Assert.False(result.IsValid);
            Assert.Equal(expectedError, result.Error, IdentityServiceErrorComparer.Instance);
            Assert.Equal("http://www.example.com/callback", result.Error.RedirectUri);
            Assert.Equal(OpenIdConnectResponseMode.Query, result.Error.ResponseMode);
        }
        private (string responseMode, OpenIdConnectMessage responseModeError) ValidateResponseMode(IDictionary <string, string[]> parameters)
        {
            var(responseMode, responseModeParameterError) = RequestParametersHelper.ValidateOptionalParameterIsUnique(parameters, OpenIdConnectParameterNames.ResponseMode, _errorProvider);
            var responseModeValidationError = responseMode != null && !ValidResponseModes.Contains(responseMode) ?
                                              _errorProvider.InvalidParameterValue(responseMode, OpenIdConnectParameterNames.ResponseMode) :
                                              null;
            var isResponseModeInvalid = responseModeParameterError != null || responseModeValidationError != null;

            return(isResponseModeInvalid ? null : responseMode, responseModeParameterError ?? responseModeValidationError);
        }