Exemple #1
0
        public MainPage()
        {
            _mobileConnect = MobileConnectFactory.MobileConnect;
            _config        = MobileConnectFactory.Config;

            this.InitializeComponent();
        }
Exemple #2
0
        public MainWindow()
        {
            _mobileConnect = MobileConnectFactory.MobileConnect;
            _config        = MobileConnectFactory.Config;

            InitializeComponent();
        }
Exemple #3
0
 static MobileConnectFactory()
 {
     _client         = new RestClient();
     _discovery      = new Discovery.Discovery(null, _client);
     _authentication = new Authentication.Authentication(_client);
     _config         = CreateConfig();
     _mobileConnect  = new MobileConnectInterface(_discovery, _authentication, _config);
 }
Exemple #4
0
        //[TestCase("r2-ref")]
        public async Task MobileConnectInterfaceShouldRejectIncorrectState(string configKey)
        {
            RestClient      restClient     = new RestClient();
            IDiscoveryCache cache          = null;
            IDiscovery      discovery      = new GSMA.MobileConnect.Discovery.Discovery(cache, restClient);
            IAuthentication authentication = new GSMA.MobileConnect.Authentication.Authentication(restClient);

            var testConfig             = TestConfig.GetConfig(configKey);
            MobileConnectConfig config = new MobileConnectConfig()
            {
                DiscoveryUrl = testConfig.DiscoveryUrl,
                ClientId     = testConfig.ClientId,
                ClientSecret = testConfig.ClientSecret,
                RedirectUrl  = testConfig.RedirectUrl
            };

            MobileConnectRequestOptions blankOptions  = new MobileConnectRequestOptions();
            MobileConnectInterface      mobileConnect = new MobileConnectInterface(discovery, authentication, config);

            //Attempt discovery
            var status = await mobileConnect.AttemptDiscoveryAsync(testConfig.ValidMSISDN, null, null, blankOptions);

            Assert.AreEqual(MobileConnectResponseType.StartAuthorization, status.ResponseType);

            var discoveryResponse = status.DiscoveryResponse;
            var encryptedMsisdn   = status.DiscoveryResponse.ResponseData.subscriber_id;
            var state             = "zmxncbvalskdjfhgqpwoeiruty";
            var nonce             = "qpwoeirutyalskdjfhgzmxncbv";

            //Start Authorization
            status = mobileConnect.StartAuthorization(discoveryResponse, encryptedMsisdn, state, nonce, blankOptions);

            Assert.AreEqual(MobileConnectResponseType.Authorization, status.ResponseType);

            //Inconclusive at this point because the sandbox no longer allows us to follow redirects easily
            Assert.Inconclusive("Can't follow redirects in sandbox");

            //Authorization
            var redirectedUrl = await FollowRedirects(status.Url, _basicRequestHeaders, testConfig.RedirectUrl);

            Assert.That(() => redirectedUrl.AbsoluteUri.StartsWith(testConfig.RedirectUrl));
            Assert.AreEqual(state, HttpUtils.ExtractQueryValue(redirectedUrl.Query, "state"));

            //Handle auth redirect and request token
            status = await mobileConnect.HandleUrlRedirectAsync(redirectedUrl, discoveryResponse, "incorrectstate", nonce);

            Assert.AreEqual(MobileConnectResponseType.Error, status.ResponseType);
            Assert.AreEqual("invalid_state", status.ErrorCode);
            Assert.IsNotEmpty(status.ErrorMessage);
        }
Exemple #5
0
        public void Setup(RestClient client)
        {
            _restClient = client;
            _cache      = new ConcurrentCache();

            _config = new MobileConnectConfig()
            {
                DiscoveryUrl = _testConfig.DiscoveryUrl,
                ClientId     = _testConfig.ClientId,
                ClientSecret = _testConfig.ClientSecret,
                RedirectUrl  = _testConfig.RedirectUrl,
            };

            _mobileConnect = new MobileConnectInterface(_config, _cache, _restClient);
        }
        public void Setup(RestClient client)
        {
            _restClient     = client;
            _cache          = new ConcurrentDiscoveryCache();
            _discovery      = new GSMA.MobileConnect.Discovery.Discovery(_cache, _restClient);
            _authentication = new GSMA.MobileConnect.Authentication.Authentication(_restClient);

            _config = new MobileConnectConfig()
            {
                DiscoveryUrl = _testConfig.DiscoveryUrl,
                ClientId     = _testConfig.ClientId,
                ClientSecret = _testConfig.ClientSecret,
                RedirectUrl  = _testConfig.RedirectUrl,
            };

            _mobileConnect = new MobileConnectInterface(_discovery, _authentication, _config);
        }
Exemple #7
0
        public void Setup()
        {
            _restClient     = new MockRestClient();
            _cache          = new ConcurrentCache();
            _discovery      = new DiscoveryService(_cache, _restClient);
            _authentication = new GSMA.MobileConnect.Authentication.AuthenticationService(_restClient);
            _identity       = new GSMA.MobileConnect.Identity.IdentityService(_restClient);
            _jwks           = new GSMA.MobileConnect.Authentication.JWKeysetService(_restClient, _cache);

            _discoveryResponse = new DiscoveryResponse(_responses["authentication"]);
            _discoveryResponse.ProviderMetadata = JsonConvert.DeserializeObject <ProviderMetadata>(_responses["provider-metadata"].Content);

            _config = new MobileConnectConfig
            {
                ClientId     = "zxcvbnm",
                ClientSecret = "asdfghjkl",
                DiscoveryUrl = "qwertyuiop",
                RedirectUrl  = "http://qwertyuiop",
            };

            _mobileConnect = new MobileConnectInterface(_config, _discovery, _authentication, _identity, _jwks);
        }
Exemple #8
0
 static MobileConnectFactory()
 {
     _config        = CreateConfig();
     _mobileConnect = new MobileConnectInterface(_config, null);
 }