Skip to content

Commit 61242a4

Browse files
test util improvements
1 parent 6f74636 commit 61242a4

File tree

1 file changed

+6
-3
lines changed
  • tests/test_planet_auth/unit/auth

1 file changed

+6
-3
lines changed

tests/test_planet_auth/unit/auth/util.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,10 @@ def _construct_oidc_access_token(self, username: str, ttl: int, extra_claims, re
6969
"sub": username,
7070
"aud": self.audience,
7171
"iat": now,
72-
"exp": now + ttl,
7372
"jti": str(uuid.uuid4()),
7473
}
74+
if ttl:
75+
unsigned_jwt["exp"] = now + ttl
7576
unsigned_jwt.update(extra_claims)
7677
if remove_claims:
7778
for remove_claim in remove_claims:
@@ -118,9 +119,10 @@ def construct_oidc_id_token(self, client_id: str, ttl: int, extra_claims=None, r
118119
"sub": client_id,
119120
"aud": client_id,
120121
"iat": now,
121-
"exp": now + ttl,
122122
"jti": str(uuid.uuid4()),
123123
}
124+
if ttl:
125+
unsigned_jwt["exp"] = now + ttl
124126
if extra_claims:
125127
# Note: this is clobbering of the claims above! might be fine
126128
# for this test class, but be warned if you copy-paste somewhere.
@@ -322,9 +324,10 @@ def _construct_oidc_credential(
322324

323325
credential_data = {
324326
"token_type": "Bearer",
325-
"expires_in": self._mock_client_config.stub_authority_ttl,
326327
"scope": " ".join(requested_scopes),
327328
}
329+
if self._mock_client_config.stub_authority_ttl:
330+
credential_data["expires_in"] = self._mock_client_config.stub_authority_ttl
328331
if get_access_token:
329332
credential_data["access_token"] = jwt_access_token
330333
if get_id_token:

0 commit comments

Comments
 (0)