internal static TokenMintingResponse ToTokenMintingResponse(TokenRawResult tokenRawResult)
 {
     return(new TokenMintingResponse()
     {
         AccessToken = tokenRawResult.TokenResult.Response.AccessToken,
         IdentityToken = tokenRawResult.TokenResult.Response.IdentityToken,
         RefreshToken = tokenRawResult.TokenResult.Response.RefreshToken,
         ExpiresIn = tokenRawResult.TokenResult.Response.AccessTokenLifetime,
         TokenType = "Bearer",
         IsError = tokenRawResult.TokenErrorResult != null,
         ErrorDescription = (tokenRawResult.TokenErrorResult == null) ? "" : tokenRawResult.TokenErrorResult.Response.ErrorDescription,
         Error = (tokenRawResult.TokenErrorResult == null) ? "" : tokenRawResult.TokenErrorResult.Response.Error,
         Scheme = "self"
     });
 }
Example #2
0
        public void TokenMintingService_ToTokenMintingResponse()
        {
            var tokenRawResult = new TokenRawResult
            {
                TokenErrorResult =
                    new TokenErrorResult(new TokenErrorResponse()
                {
                    Custom = new Dictionary <string, object>()
                    {
                        { GuidString, GuidString }
                    },
                    Error            = GuidString,
                    ErrorDescription = GuidString
                }),
                TokenResult = new TokenResult(new TokenResponseExtra()
                {
                    AccessToken         = GuidString,
                    IdentityToken       = GuidString,
                    RefreshToken        = GuidString,
                    AccessTokenLifetime = 3,
                    Custom = new Dictionary <string, object>()
                    {
                        { GuidString, GuidString }
                    }
                })
            };
            var kk = InProcTokenMintingService.ToTokenMintingResponse(tokenRawResult);

            kk.ShouldNotBeNull();

            tokenRawResult = new TokenRawResult
            {
                TokenErrorResult =
                    new TokenErrorResult(new TokenErrorResponse()),
                TokenResult = new TokenResult(new TokenResponseExtra())
            };
            kk = InProcTokenMintingService.ToTokenMintingResponse(tokenRawResult);
            kk.ShouldNotBeNull();
        }