Пример #1
0
        public async Task MultipleRefreshesWork()
        {
            var api     = new OAuthTestApi(OAuthData.SignInDataWithRefresh);
            var account = await api.Authenticate();

            Assert.IsTrue(account.IsValid());
            await Task.Delay(6000);

            Assert.IsFalse(account.IsValid());


            await api.Authenticate();

            Assert.IsTrue(api.CurrentAccount.IsValid());

            await Task.Delay(6000);

            Assert.IsFalse(api.CurrentAccount.IsValid());


            await api.Get("test");

            Assert.IsTrue(api.CurrentAccount.IsValid());

            //Make sure Show authenticator was called
            Assert.IsTrue(api.CurrentShowAuthenticatorCallCount == 1);
        }
Пример #2
0
        public async Task AuthenticatedCallsSendAuthHeader()
        {
            var api     = new OAuthTestApi(OAuthData.SignInDataWithRefresh);
            var account = await api.Authenticate();

            Assert.IsTrue(account.IsValid());
            await api.Get("authenticated");
        }
Пример #3
0
        public async Task RefreshTokenOnUnauthorized()
        {
            var api     = new OAuthTestApi(OAuthData.SignInBadAccessTokenRefresh);
            var account = await api.Authenticate();

            Assert.IsTrue((api.CurrentAccount as OAuthAccount).Token == "badAccessToken");
            Assert.IsTrue(account.IsValid());
            await api.Get("authenticated");

            Assert.IsTrue((api.CurrentAccount as OAuthAccount).Token == "accessToken");
        }
Пример #4
0
        public async Task AuthenticatedApiRequestsRefreshTokens()
        {
            var api     = new OAuthTestApi(OAuthData.SignInDataWithRefresh);
            var account = await api.Authenticate();

            Assert.IsTrue(account.IsValid());
            await Task.Delay(6000);

            Assert.IsFalse(account.IsValid());

            await api.Get("test");

            Assert.IsTrue(api.CurrentAccount.IsValid());
        }
Пример #5
0
        public async Task NonAuthenticatedCallsDoNotRefreshAccounts()
        {
            var api     = new OAuthTestApi(OAuthData.SignInDataWithRefresh);
            var account = await api.Authenticate();

            Assert.IsTrue(account.IsValid());
            await Task.Delay(6000);

            Assert.IsFalse(account.IsValid());


            await api.Authenticate();

            Assert.IsTrue(api.CurrentAccount.IsValid());

            await Task.Delay(6000);

            Assert.IsFalse(api.CurrentAccount.IsValid());


            await api.Get("test", authenticated : false);

            Assert.IsFalse(api.CurrentAccount.IsValid());
        }