Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

token refresh offset #12136

Merged
merged 33 commits into from
Jul 17, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update
  • Loading branch information
xiangyan99 committed Jul 17, 2020
commit 533ab8c8fe171ff0721613712300f8302c64c2f3
21 changes: 0 additions & 21 deletions sdk/identity/azure-identity/tests/test_aad_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,24 +223,3 @@ def test_should_refresh():
client._last_refresh_time = now - DEFAULT_TOKEN_REFRESH_RETRY_DELAY + 1
should_refresh = client.should_refresh(token)
assert not should_refresh


def test_token_refresh_kwargs():
client = AadClient("test", "test")
now = int(time.time())

# do not need refresh
token = AccessToken("token", now + DEFAULT_REFRESH_OFFSET + 1)
should_refresh = client.should_refresh(token)
assert not should_refresh

# need refresh
token = AccessToken("token", now + DEFAULT_REFRESH_OFFSET - 1)
should_refresh = client.should_refresh(token)
assert should_refresh

# not exceed cool down time, do not refresh
token = AccessToken("token", now + DEFAULT_REFRESH_OFFSET - 1)
client._last_refresh_time = now - DEFAULT_TOKEN_REFRESH_RETRY_DELAY + 1
should_refresh = client.should_refresh(token)
assert not should_refresh
21 changes: 0 additions & 21 deletions sdk/identity/azure-identity/tests/test_aad_client_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,24 +230,3 @@ async def test_should_refresh():
client._last_refresh_time = now - DEFAULT_TOKEN_REFRESH_RETRY_DELAY + 1
should_refresh = client.should_refresh(token)
assert not should_refresh


async def test_token_refresh_kwargs():
client = AadClient("test", "test")
now = int(time.time())

# do not need refresh
token = AccessToken("token", now + DEFAULT_REFRESH_OFFSET + 1)
should_refresh = client.should_refresh(token)
assert not should_refresh

# need refresh
token = AccessToken("token", now + DEFAULT_REFRESH_OFFSET - 1)
should_refresh = client.should_refresh(token)
assert should_refresh

# not exceed cool down time, do not refresh
token = AccessToken("token", now + DEFAULT_REFRESH_OFFSET - 1)
client._last_refresh_time = now - DEFAULT_TOKEN_REFRESH_RETRY_DELAY + 1
should_refresh = client.should_refresh(token)
assert not should_refresh
21 changes: 0 additions & 21 deletions sdk/identity/azure-identity/tests/test_authn_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,24 +254,3 @@ def test_should_refresh():
client._last_refresh_time = now - DEFAULT_TOKEN_REFRESH_RETRY_DELAY + 1
should_refresh = client.should_refresh(token)
assert not should_refresh


def test_token_refresh_kwargs():
client = AuthnClient(endpoint="http://foo")
now = int(time.time())

# do not need refresh
token = AccessToken("token", now + DEFAULT_REFRESH_OFFSET + 1)
should_refresh = client.should_refresh(token)
assert not should_refresh

# need refresh
token = AccessToken("token", now + DEFAULT_REFRESH_OFFSET - 1)
should_refresh = client.should_refresh(token)
assert should_refresh

# not exceed cool down time, do not refresh
token = AccessToken("token", now + DEFAULT_REFRESH_OFFSET - 1)
client._last_refresh_time = now - DEFAULT_TOKEN_REFRESH_RETRY_DELAY + 1
should_refresh = client.should_refresh(token)
assert not should_refresh
21 changes: 0 additions & 21 deletions sdk/identity/azure-identity/tests/test_authn_client_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,24 +58,3 @@ async def test_should_refresh():
client._last_refresh_time = now - DEFAULT_TOKEN_REFRESH_RETRY_DELAY + 1
should_refresh = client.should_refresh(token)
assert not should_refresh


async def test_token_refresh_kwargs():
client = AsyncAuthnClient(endpoint="http://foo")
now = int(time.time())

# do not need refresh
token = AccessToken("token", now + DEFAULT_REFRESH_OFFSET + 1)
should_refresh = client.should_refresh(token)
assert not should_refresh

# need refresh
token = AccessToken("token", now + DEFAULT_REFRESH_OFFSET - 1)
should_refresh = client.should_refresh(token)
assert should_refresh

# not exceed cool down time, do not refresh
token = AccessToken("token", now + DEFAULT_REFRESH_OFFSET - 1)
client._last_refresh_time = now - DEFAULT_TOKEN_REFRESH_RETRY_DELAY + 1
should_refresh = client.should_refresh(token)
assert not should_refresh