Exemplo n.º 1
0
        public void OperatorURLsShouldBeOverriddenByProviderMetadataOnDeserialize()
        {
            var responseJson     = "{\"ttl\":1461169322705,\"subscriber_id\":\"e06a09de399ae6c6798c2126e531775ddf3cfe00367af1842534be709fef25e199157c49cc44adf661d286a29afa09c017747fb4383db22b2eaf33db5f878b3ea261c8f342b234e998757e83de23f4a637ce2390453d5d578c76cd65aae99332ee7fbdbd4a140c99babc4e700eae6aa44d3e17ac050771c1fd784fef0214bf770cd0854ea6f4cff87b3ea1e4b25dccd1d340f00eb66c0f041f90596f5236c1017b2541606fff5165320fc4b3381ebfe1fdb848ab04fbedc550bc575ca385b44695a0a9917a368552ee9f8e2178553318a17c32284197631f74f293f30fe6c04f7a77115ec0d2e8ab2a522db88c60263ec1b690ca22540b916e8a9d2c3d820ec1\",\"response\":{\"serving_operator\":\"Example Operator A\",\"country\":\"US\",\"currency\":\"USD\",\"apis\":{\"operatorid\":{\"link\":[{\"href\":\"http://operator_a.sandbox2.mobileconnect.io/oidc/authorize\",\"rel\":\"authorization\"},{\"href\":\"http://operator_a.sandbox2.mobileconnect.io/oidc/accesstoken\",\"rel\":\"token\"},{\"href\":\"http://operator_a.sandbox2.mobileconnect.io/oidc/userinfo\",\"rel\":\"userinfo\"},{\"href\":\"openid profile email\",\"rel\":\"scope\"}]}},\"client_id\":\"66742a85-2282-4747-881d-ed5b7bd74d2d\",\"client_secret\":\"f15199f4-b658-4e58-8bb3-e40998873392\",\"subscriber_id\":\"e06a09de399ae6c6798c2126e531775ddf3cfe00367af1842534be709fef25e199157c49cc44adf661d286a29afa09c017747fb4383db22b2eaf33db5f878b3ea261c8f342b234e998757e83de23f4a637ce2390453d5d578c76cd65aae99332ee7fbdbd4a140c99babc4e700eae6aa44d3e17ac050771c1fd784fef0214bf770cd0854ea6f4cff87b3ea1e4b25dccd1d340f00eb66c0f041f90596f5236c1017b2541606fff5165320fc4b3381ebfe1fdb848ab04fbedc550bc575ca385b44695a0a9917a368552ee9f8e2178553318a17c32284197631f74f293f30fe6c04f7a77115ec0d2e8ab2a522db88c60263ec1b690ca22540b916e8a9d2c3d820ec1\"}}";
            var restResponse     = new RestResponse(System.Net.HttpStatusCode.OK, responseJson);
            var authzEndpoint    = "test authz";
            var tokenEndpoint    = "test token";
            var userInfoEndpoint = "test userinfo";
            var jwksEndpoint     = "test jwks";
            var providerMetadata = new MobileConnect.Discovery.ProviderMetadata
            {
                AuthorizationEndpoint = authzEndpoint,
                UserInfoEndpoint      = userInfoEndpoint,
                TokenEndpoint         = tokenEndpoint,
                JwksUri = jwksEndpoint,
            };

            var discoveryResponse = new MobileConnect.Discovery.DiscoveryResponse(restResponse);

            discoveryResponse.ProviderMetadata = providerMetadata;

            var serialized = JsonConvert.SerializeObject(discoveryResponse);
            var actual     = JsonConvert.DeserializeObject <MobileConnect.Discovery.DiscoveryResponse>(serialized);

            Assert.AreEqual(authzEndpoint, actual.OperatorUrls.AuthorizationUrl);
            Assert.AreEqual(tokenEndpoint, actual.OperatorUrls.RequestTokenUrl);
            Assert.AreEqual(userInfoEndpoint, actual.OperatorUrls.UserInfoUrl);
            Assert.AreEqual(jwksEndpoint, actual.OperatorUrls.JWKSUrl);
        }
Exemplo n.º 2
0
        public void IsMobileConnectServiceSupportedShouldThrowIfScopesSupportedEmpty()
        {
            var responseJson      = "{\"ttl\":1461169322705,\"subscriber_id\":\"e06a09de399ae6c6798c2126e531775ddf3cfe00367af1842534be709fef25e199157c49cc44adf661d286a29afa09c017747fb4383db22b2eaf33db5f878b3ea261c8f342b234e998757e83de23f4a637ce2390453d5d578c76cd65aae99332ee7fbdbd4a140c99babc4e700eae6aa44d3e17ac050771c1fd784fef0214bf770cd0854ea6f4cff87b3ea1e4b25dccd1d340f00eb66c0f041f90596f5236c1017b2541606fff5165320fc4b3381ebfe1fdb848ab04fbedc550bc575ca385b44695a0a9917a368552ee9f8e2178553318a17c32284197631f74f293f30fe6c04f7a77115ec0d2e8ab2a522db88c60263ec1b690ca22540b916e8a9d2c3d820ec1\",\"response\":{\"serving_operator\":\"Example Operator A\",\"country\":\"US\",\"currency\":\"USD\",\"apis\":{\"operatorid\":{\"link\":[{\"href\":\"http://operator_a.sandbox2.mobileconnect.io/oidc/authorize\",\"rel\":\"authorization\"},{\"href\":\"http://operator_a.sandbox2.mobileconnect.io/oidc/accesstoken\",\"rel\":\"token\"},{\"href\":\"http://operator_a.sandbox2.mobileconnect.io/oidc/userinfo\",\"rel\":\"userinfo\"},{\"href\":\"openid profile email\",\"rel\":\"scope\"}]}},\"client_id\":\"66742a85-2282-4747-881d-ed5b7bd74d2d\",\"client_secret\":\"f15199f4-b658-4e58-8bb3-e40998873392\",\"subscriber_id\":\"e06a09de399ae6c6798c2126e531775ddf3cfe00367af1842534be709fef25e199157c49cc44adf661d286a29afa09c017747fb4383db22b2eaf33db5f878b3ea261c8f342b234e998757e83de23f4a637ce2390453d5d578c76cd65aae99332ee7fbdbd4a140c99babc4e700eae6aa44d3e17ac050771c1fd784fef0214bf770cd0854ea6f4cff87b3ea1e4b25dccd1d340f00eb66c0f041f90596f5236c1017b2541606fff5165320fc4b3381ebfe1fdb848ab04fbedc550bc575ca385b44695a0a9917a368552ee9f8e2178553318a17c32284197631f74f293f30fe6c04f7a77115ec0d2e8ab2a522db88c60263ec1b690ca22540b916e8a9d2c3d820ec1\"}}";
            var restResponse      = new RestResponse(System.Net.HttpStatusCode.OK, responseJson);
            var discoveryResponse = new MobileConnect.Discovery.DiscoveryResponse(restResponse);
            var providerMetadata  = new MobileConnect.Discovery.ProviderMetadata {
                ScopesSupported = new List <string>()
            };

            discoveryResponse.ProviderMetadata = providerMetadata;
            var scopesToTest = "openid mc_authz";

            Assert.Throws <MobileConnectProviderMetadataUnavailableException>(() => discoveryResponse.IsMobileConnectServiceSupported(scopesToTest));
        }