public async void SuccessfullyGetAccessToken() { OidcClient client = new OidcClient(new OktaConfig("testoktaid", "https://dev-00000.oktapreview.com", "com.test:/redirect", "com.test:/logout")); HttpMessageHandlerMock mockHttpClient = new HttpMessageHandlerMock(); mockHttpClient.Responder = (request) => { string url = request.Item1; Dictionary <string, string> data = request.Item2; return(new Tuple <System.Net.HttpStatusCode, string>( System.Net.HttpStatusCode.OK, @"{ ""access_token"": ""access_token_example"", ""token_type"": ""testing""}")); }; client.SetHttpMock(mockHttpClient); client.OnLaunchBrowser = new Action <string>(url => OidcClient.CaptureRedirectUrl(new Uri(client.Config.RedirectUri + "?code=12345&state=" + client.State_Internal))); OktaState state = await client.SignInWithBrowserAsync(); Assert.Equal("access_token_example", state.AccessToken); Assert.True(state.IsAuthenticated); }
public void CorrectlySetIsAuthenticated() { OktaState stateWithNoToken = new OktaState(null, "test"); Assert.False(stateWithNoToken.IsAuthenticated); OktaState stateWithTokenAndExpInPast = new OktaState("test", "test", null, null, -100); Assert.False(stateWithTokenAndExpInPast.IsAuthenticated); OktaState stateWithNoExp = new OktaState("test", "test"); Assert.True(stateWithNoExp.IsAuthenticated); OktaState stateWithExpInFuture = new OktaState("test", "test", null, null, 100); Assert.True(stateWithExpInFuture.IsAuthenticated); }
protected void OnSignOutCompleted(object sender, EventArgs e) { this.StateManager = ((SignOutEventArgs)e).StateManager; }