public async Task RequestTokenAsyncShouldHandleInvalidArgumentException()
        {
            var uri      = new Uri("http://localhost?state=state&nonce=nonce");
            var response = await _mobileConnect.RequestTokenAsync(null, uri, "state", "nonce");

            Assert.IsNotNull(response);
            Assert.AreEqual(MobileConnectResponseType.Error, response.ResponseType);
            Assert.IsInstanceOf <MobileConnectInvalidArgumentException>(response.Exception);
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
        public async Task RequestTokenAsyncShouldHandleInvalidArgumentException()
        {
            var discoveryResponse = new DiscoveryResponse(new RestResponse(System.Net.HttpStatusCode.OK, responseJson));

            discoveryResponse.ProviderMetadata             = ProviderMetadata.Default;
            discoveryResponse.OperatorUrls.RequestTokenUrl = null;
            var uri      = new Uri("http://localhost?state=state&nonce=nonce");
            var response = await _mobileConnect.RequestTokenAsync(discoveryResponse, uri, "state", "nonce", new MobileConnectRequestOptions());

            Assert.IsNotNull(response);
            Assert.AreEqual(MobileConnectResponseType.Error, response.ResponseType);
            Assert.IsInstanceOf <MobileConnectInvalidArgumentException>(response.Exception);
        }