Enhance OAuth client to support scope options and update related tests
This commit is contained in:
parent
1a9f924764
commit
bebf99d826
5 changed files with 80 additions and 15 deletions
|
|
@ -33,3 +33,19 @@ def test_get_valid_token_reuses_unexpired_token() -> None:
|
|||
token = client.get_valid_token(scopes=["scope.a"])
|
||||
|
||||
assert token.access_token == "cached-token"
|
||||
|
||||
|
||||
def test_get_valid_token_reuses_token_when_any_scope_option_matches() -> None:
|
||||
config = EbayOAuthConfig(client_id="client-id", client_secret="client-secret")
|
||||
store = InMemoryTokenStore()
|
||||
store.set_token(OAuthToken(access_token="cached-token", scope="scope.base scope.write"))
|
||||
client = EbayOAuthClient(config, token_store=store)
|
||||
|
||||
token = client.get_valid_token(
|
||||
scope_options=[
|
||||
["scope.base", "scope.read"],
|
||||
["scope.base", "scope.write"],
|
||||
]
|
||||
)
|
||||
|
||||
assert token.access_token == "cached-token"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue