public async Task When_Parameter_Is_Empty_Then_Exception_Is_Thrown() { var authorizationParameter = new AuthorizationParameter(); var error = await _displayConsentAction.Execute( authorizationParameter, new ClaimsPrincipal(), "", CancellationToken.None) .ConfigureAwait(false); Assert.NotNull(error.EndpointResult.Error); }
public async Task <IActionResult> Index(string code, CancellationToken cancellationToken) { var request = _dataProtector.Unprotect <AuthorizationRequest>(code); if (request.client_id == null) { return(BadRequest()); } var authenticatedUser = await SetUser().ConfigureAwait(false); var issuerName = Request.GetAbsoluteUriWithVirtualPath(); var actionResult = await _displayConsent.Execute( request.ToParameter(), authenticatedUser ?? new ClaimsPrincipal(), issuerName, cancellationToken) .ConfigureAwait(false); var result = actionResult.EndpointResult.CreateRedirectionFromActionResult(request, _logger); if (result != null) { return(result); } var client = await _clientStore.GetById(request.client_id, cancellationToken).ConfigureAwait(false); if (client == null) { return(BadRequest()); } var viewModel = new ConsentViewModel { ClientDisplayName = client.ClientName, AllowedScopeDescriptions = actionResult?.Scopes == null ? new List <string>() : actionResult.Scopes.Select(s => s.Description).ToList(), AllowedIndividualClaims = actionResult?.AllowedClaims ?? new List <string>(), LogoUri = client.LogoUri?.AbsoluteUri, PolicyUri = client.PolicyUri?.AbsoluteUri, TosUri = client.TosUri?.AbsoluteUri, Code = code }; return(Ok(viewModel)); }