Пример #1
0
 public async Task When_Passing_Null_Parameter_To_PostIntrospection_Then_Exception_Is_Thrown()
 {
     await Assert
     .ThrowsAsync <NullReferenceException>(
         () => _introspectionActions.Execute(null, CancellationToken.None))
     .ConfigureAwait(false);
 }
Пример #2
0
        public async Task <IActionResult> Post(
            [FromForm] IntrospectionRequest introspectionRequest,
            CancellationToken cancellationToken)
        {
            if (introspectionRequest?.token == null)
            {
                return(BuildError(
                           ErrorCodes.InvalidRequest,
                           "no parameter in body request",
                           HttpStatusCode.BadRequest));
            }

            var result = await _introspectionActions.Execute(
                introspectionRequest.ToParameter(),
                cancellationToken)
                         .ConfigureAwait(false);

            return(result switch
            {
                Option <OauthIntrospectionResponse> .Result r => Ok(r.Item),
                Option <OauthIntrospectionResponse> .Error e => BadRequest(e.Details),
                _ => throw new ArgumentOutOfRangeException()
            });