Skip to content

Commit bb77b62

Browse files
committed
adding test
1 parent 3eac8c7 commit bb77b62

File tree

5 files changed

+28
-4
lines changed

5 files changed

+28
-4
lines changed

google_auth_oauthlib/helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def credentials_from_session(session, client_config=None):
145145
client_id=client_config.get("client_id"),
146146
client_secret=client_config.get("client_secret"),
147147
scopes=session.scope,
148-
granted_scopes=session.token.get("scope")
148+
granted_scopes=session.token.get("scope"),
149149
)
150150
credentials.expiry = datetime.datetime.utcfromtimestamp(session.token["expires_at"])
151151
return credentials

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
TOOL_DEPENDENCIES = "click>=6.0.0"
2222

23-
DEPENDENCIES = ("google-auth>=2.14.0", "requests-oauthlib>=0.7.0")
23+
DEPENDENCIES = ("google-auth>=2.15.0", "requests-oauthlib>=0.7.0")
2424

2525

2626
with io.open("README.rst", "r") as fh:

testing/constraints-3.6.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
#
66
# e.g., if setup.py has "foo >= 1.14.0, < 2.0.0dev",
77
# Then this file should have foo==1.14.0
8-
google-auth==2.14.0
8+
google-auth==2.15.0
99
requests-oauthlib==0.7.0
1010
click==6.0.0

testing/constraints-3.7.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
#
66
# e.g., if setup.py has "foo >= 1.14.0, < 2.0.0dev",
77
# Then this file should have foo==1.14.0
8-
google-auth==2.14.0
8+
google-auth==2.15.0
99
requests-oauthlib==0.7.0
1010
click==6.0.0

tests/unit/test_helpers.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,30 @@ def test_credentials_from_session(session):
9898
assert credentials.scopes == session.scope
9999

100100

101+
def test_credentials_from_session_granted_scopes(session):
102+
granted_scopes = ["scope1", "scope2"]
103+
session.token = {
104+
"access_token": mock.sentinel.access_token,
105+
"refresh_token": mock.sentinel.refresh_token,
106+
"id_token": mock.sentinel.id_token,
107+
"expires_at": 643969200.0,
108+
"scope": granted_scopes,
109+
}
110+
111+
credentials = helpers.credentials_from_session(session, CLIENT_SECRETS_INFO["web"])
112+
113+
assert isinstance(credentials, google.oauth2.credentials.Credentials)
114+
assert credentials.token == mock.sentinel.access_token
115+
assert credentials.expiry == datetime.datetime(1990, 5, 29, 8, 20, 0)
116+
assert credentials._refresh_token == mock.sentinel.refresh_token
117+
assert credentials.id_token == mock.sentinel.id_token
118+
assert credentials._client_id == CLIENT_SECRETS_INFO["web"]["client_id"]
119+
assert credentials._client_secret == CLIENT_SECRETS_INFO["web"]["client_secret"]
120+
assert credentials._token_uri == CLIENT_SECRETS_INFO["web"]["token_uri"]
121+
assert credentials.scopes == session.scope
122+
assert credentials.granted_scopes == granted_scopes
123+
124+
101125
def test_credentials_from_session_3pi(session):
102126
session.token = {
103127
"access_token": mock.sentinel.access_token,

0 commit comments

Comments
 (0)