Esempio n. 1
0
        public async Task RequestTokenAcceptsValidToken()
        {
            _restClient.QueueParallelResponses(Tuple.Create <string, object>(_discoveryResponse.OperatorUrls.JWKSUrl, _responses["jwks"]),
                                               Tuple.Create <string, object>(_discoveryResponse.OperatorUrls.RequestTokenUrl, _responses["token"]));

            var result = await _mobileConnect.RequestTokenAsync(_discoveryResponse, new Uri($"{_config.RedirectUrl}?code=123123123456&state=zxcvbnm"), "zxcvbnm", "1234567890", null);

            Assert.AreEqual(MobileConnectResponseType.Complete, result.ResponseType);
            Assert.AreEqual(TokenValidationResult.Valid, result.TokenResponse.ValidationResult);
        }
        public async Task RefreshTokenShouldUseRefreshTokenUrl()
        {
            string session           = "zzzz";
            var    discoveryResponse = CompleteDiscovery();

            discoveryResponse.ProviderMetadata.RefreshEndpoint = "http://refresh";
            discoveryResponse.ProviderMetadata.TokenEndpoint   = "http://request";
            discoveryResponse.ResponseData?.response?.apis?.operatorid?.link?.Clear();
            await _cache.Add(session, discoveryResponse);

            _restClient.QueueParallelResponses(Tuple.Create <string, object>(discoveryResponse.ProviderMetadata.RefreshEndpoint, _responses["token"]),
                                               Tuple.Create <string, object>(discoveryResponse.ProviderMetadata.TokenEndpoint, _responses["error"]));

            var result = await _mobileConnect.RefreshTokenAsync(_request, "token", session);

            Assert.AreEqual(MobileConnectResponseType.Complete, result.ResponseType);
        }