public MainWindow() { _mobileConnect = MobileConnectFactory.MobileConnect; _config = MobileConnectFactory.Config; InitializeComponent(); }
public MainPage() { _mobileConnect = MobileConnectFactory.MobileConnect; _config = MobileConnectFactory.Config; this.InitializeComponent(); }
static MobileConnectFactory() { _client = new RestClient(); _discovery = new Discovery.Discovery(null, _client); _authentication = new Authentication.Authentication(_client); _config = CreateConfig(); _mobileConnect = new MobileConnectInterface(_discovery, _authentication, _config); }
public void Setup() { _restClient = new MockRestClient(); _authentication = new MobileConnect.Authentication.AuthenticationService(this._restClient); _config = new MobileConnectConfig() { ClientId = "1234567890", ClientSecret = "1234567890", DiscoveryUrl = "http://localhost:8080/v2/discovery/" }; }
private void Setup(IDiscoveryCache cache) { _restClient = new MockRestClient(); _cache = cache; _discovery = new MobileConnect.Discovery.Discovery(cache, this._restClient); _config = new MobileConnectConfig() { ClientId = "1234567890", ClientSecret = "1234567890", DiscoveryUrl = "http://localhost:8080/v2/discovery/" }; }
//[TestCase("r2-ref")] public async Task MobileConnectWebInterfaceShouldWorkEndToEndWithCache(string configKey) { RestClient restClient = new RestClient(); IDiscoveryCache cache = new ConcurrentDiscoveryCache(); 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(); MobileConnectWebInterface mobileConnect = new MobileConnectWebInterface(discovery, authentication, config); //Attempt discovery var request = new HttpRequestMessage(); var status = await mobileConnect.AttemptDiscoveryAsync(request, testConfig.ValidMSISDN, null, null, true, blankOptions); Assert.AreEqual(MobileConnectResponseType.StartAuthorization, status.ResponseType); var session = status.SDKSession; var encryptedMsisdn = status.DiscoveryResponse.ResponseData.subscriber_id; var state = "zmxncbvalskdjfhgqpwoeiruty"; var nonce = "qpwoeirutyalskdjfhgzmxncbv"; //Start Authorization request = new HttpRequestMessage(); status = await mobileConnect.StartAuthorization(request, session, 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 request = new HttpRequestMessage(); 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 request = new HttpRequestMessage(); status = await mobileConnect.HandleUrlRedirectAsync(request, redirectedUrl, session, state, nonce); Assert.AreEqual(MobileConnectResponseType.Complete, status.ResponseType); Assert.IsNotEmpty(status.TokenResponse.ResponseData.AccessToken); }
public async Task MobileConnectWebInterfaceShouldWorkEndToEndHeadlessWithRevoke(string configKey) { RestClient restClient = new RestClient(); ICache cache = null; IDiscoveryService discovery = new GSMA.MobileConnect.Discovery.DiscoveryService(cache, restClient); IAuthenticationService authentication = new GSMA.MobileConnect.Authentication.AuthenticationService(restClient); IIdentityService identity = new GSMA.MobileConnect.Identity.IdentityService(restClient); IJWKeysetService jwks = new GSMA.MobileConnect.Authentication.JWKeysetService(restClient, cache); 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(); MobileConnectWebInterface mobileConnect = new MobileConnectWebInterface(discovery, authentication, identity, jwks, config); //Attempt discovery var request = new HttpRequestMessage(); var status = await mobileConnect.AttemptDiscoveryAsync(request, testConfig.ValidMSISDN, null, null, true, false, blankOptions); Assert.AreEqual(MobileConnectResponseType.StartAuthentication, status.ResponseType, $"{status.ErrorCode} - {status.ErrorMessage}"); var discoveryResponse = status.DiscoveryResponse; var encryptedMsisdn = status.DiscoveryResponse.ResponseData.subscriber_id; var state = "zmxncbvalskdjfhgqpwoeiruty"; var nonce = "qpwoeirutyalskdjfhgzmxncbv"; //Start Authorization var authOptions = new MobileConnectRequestOptions { Scope = "mc_authz", BindingMessage = "auth test", Context = "test" }; request = new HttpRequestMessage(); status = await mobileConnect.RequestHeadlessAuthenticationAsync(request, discoveryResponse, encryptedMsisdn, state, nonce, authOptions); Assert.AreEqual(MobileConnectResponseType.Complete, status.ResponseType, $"{status.ErrorCode} - {status.ErrorMessage}"); Assert.IsNotEmpty(status.TokenResponse.ResponseData.AccessToken); Assert.IsNotEmpty(status.TokenResponse.ResponseData.IdToken); //Revoke Token status = await mobileConnect.RevokeTokenAsync(request, status.TokenResponse.ResponseData.AccessToken, null, discoveryResponse); Assert.AreEqual(MobileConnectResponseType.TokenRevoked, status.ResponseType, $"{status.ErrorCode} - {status.ErrorMessage}"); }
private void GetParameters() { OperatorParams = ReadAndParseFiles.ReadFile(Utils.Constants.WithoutDiscoveryFilePath); ApiVersion = OperatorParams.apiVersion; IncludeRequestIp = OperatorParams.includeRequestIP.Equals("True"); MobileConnectConfig = new MobileConnectConfig() { ClientId = OperatorParams.clientID, ClientSecret = OperatorParams.clientSecret, DiscoveryUrl = OperatorParams.discoveryURL, RedirectUrl = OperatorParams.redirectURL, XRedirect = OperatorParams.xRedirect.Equals("True") ? "APP" : "False" }; }
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 GetParameters(string clientID = "", string clientSecret = "", string discoveryURL = "", string redirectURL = "", string xRedirect = "", string scope = "") { _cache = new ConcurrentCache(); _restClient = new RestClient(); mobileConnectConfig = new MobileConnectConfig() { ClientId = clientID, ClientSecret = clientSecret, DiscoveryUrl = discoveryURL, RedirectUrl = redirectURL, XRedirect = xRedirect }; _mobileConnect = new MobileConnectWebInterface(mobileConnectConfig, _cache, _restClient); }
public void Setup() { _restClient = new RestClient(); _cache = new ConcurrentCache(); _testConfig = TestConfig.GetConfig(TestConfig.DEFAULT_TEST_CONFIG); _config = new MobileConnectConfig() { DiscoveryUrl = _testConfig.DiscoveryUrl, ClientId = _testConfig.ClientId, ClientSecret = _testConfig.ClientSecret, RedirectUrl = _testConfig.RedirectUrl, }; _mobileConnect = new MobileConnectWebInterface(_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); }
public void Setup() { _restClient = new RestClient(); _cache = new ConcurrentDiscoveryCache(); _discovery = new GSMA.MobileConnect.Discovery.Discovery(_cache, _restClient); _authentication = new GSMA.MobileConnect.Authentication.Authentication(_restClient); _testConfig = TestConfig.GetConfig(TestConfig.DEFAULT_TEST_CONFIG); _config = new MobileConnectConfig() { DiscoveryUrl = _testConfig.DiscoveryUrl, ClientId = _testConfig.ClientId, ClientSecret = _testConfig.ClientSecret, RedirectUrl = _testConfig.RedirectUrl, }; _mobileConnect = new MobileConnectWebInterface(_discovery, _authentication, _config); }
public void Endpoints(string authURL = "", string tokenURL = "", string userInfoURl = "", string metadata = "", string discoveryURL = "", string redirectURL = "") { _operatorUrLs = new OperatorUrls() { AuthorizationUrl = authURL, UserInfoUrl = userInfoURl, RequestTokenUrl = tokenURL, ProviderMetadataUrl = metadata, }; _cache = new ConcurrentCache(); _restClient = new RestClient(); MobileConnectConfig mobileConnectConfig = new MobileConnectConfig() { DiscoveryUrl = discoveryURL, RedirectUrl = redirectURL }; _mobileConnect = new MobileConnectWebInterface(mobileConnectConfig, _cache, _restClient); }
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); }
public void Setup() { _restClient = new MockRestClient(); _cache = new ConcurrentCache(); _discovery = new GSMA.MobileConnect.Discovery.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 MobileConnect.Discovery.DiscoveryResponse(_responses["authentication"]); _cache.Add(_validSdkSession, _discoveryResponse); _config = new MobileConnectConfig { ClientId = "zxcvbnm", ClientSecret = "asdfghjkl", DiscoveryUrl = "qwertyuiop", RedirectUrl = "http://qwertyuiop", }; _mobileConnect = new MobileConnectWebInterface(_discovery, _authentication, _identity, _jwks, _config); }
static MobileConnectFactory() { _config = CreateConfig(); _mobileConnect = new MobileConnectInterface(_config, null); }