@@ -77,17 +77,35 @@ def decrypt_and_assert_success(self, token, token_version, scope):
7777 decrypted = self ._client .decrypt_token_into_raw_uid (token )
7878 self ._test_bidstream_client .assert_success (decrypted , token_version , scope )
7979
80- def test_smoke_test (self ): # SmokeTest
80+ def test_smoke_test_for_sharing (self ): # SmokeTestForSharing
8181 for expected_scope , expected_version in test_cases_all_scopes_all_versions :
8282 with self .subTest (expected_scope = expected_scope , expected_version = expected_version ):
83- token = generate_uid_token (expected_scope , expected_version )
83+ token = generate_uid_token (expected_scope , expected_version ,
84+ identity_established_at = now - dt .timedelta (days = 120 ),
85+ generated_at = YESTERDAY , expires_at = now + dt .timedelta (days = 29 ))
8486 refresh_response = self ._client ._refresh_json (key_sharing_response_json_default_keys (
8587 expected_scope ))
8688 self .assertTrue (refresh_response .success )
8789 self .decrypt_and_assert_success (token , expected_version , expected_scope )
8890
91+ def test_token_lifetime_too_long_for_sharing_but_remaining_lifetime_allowed (self ): # TokenLifetimeTooLongForSharingButRemainingLifetimeAllowed
92+ generated = YESTERDAY
93+ expires_in_sec = generated + dt .timedelta (days = 31 )
94+ for expected_scope , expected_version in test_cases_all_scopes_all_versions :
95+ with self .subTest (expected_scope = expected_scope , expected_version = expected_version ):
96+ token = generate_uid_token (expected_scope , expected_version , generated_at = generated ,
97+ expires_at = expires_in_sec )
98+ refresh_response = self ._client ._refresh_json (key_sharing_response_json_default_keys (
99+ expected_scope ))
100+ self .assertTrue (refresh_response .success )
101+ result = self ._client .decrypt_token_into_raw_uid (token )
102+ if expected_version == AdvertisingTokenVersion .ADVERTISING_TOKEN_V2 :
103+ self ._test_bidstream_client .assert_success (result , expected_version , expected_scope )
104+ else :
105+ self ._test_bidstream_client .assert_fails (result , expected_version , expected_scope )
106+
89107 def test_token_lifetime_too_long_for_sharing (self ): # TokenLifetimeTooLongForSharing
90- expires_in_sec = dt .datetime . now ( tz = timezone . utc ) + dt .timedelta (days = 31 )
108+ expires_in_sec = now + dt .timedelta ( days = 30 ) + dt .timedelta (minutes = 1 )
91109 for expected_scope , expected_version in test_cases_all_scopes_all_versions :
92110 with self .subTest (expected_scope = expected_scope , expected_version = expected_version ):
93111 token = generate_uid_token (expected_scope , expected_version , expires_at = expires_in_sec )
@@ -277,7 +295,8 @@ def test_expiry_in_token_matches_expiry_in_response(self): # ExpiryInTokenMatch
277295 self .assertTrue (result .status )
278296 self .assertEqual (example_uid , result .uid )
279297
280- future_decryption_result = self ._client ._decrypt_token_into_raw_uid (encryption_data_response .encrypted_data , now + dt .timedelta (seconds = 3 ))
298+ future_decryption_result = self ._client ._decrypt_token_into_raw_uid (encryption_data_response .encrypted_data ,
299+ now + dt .timedelta (seconds = 3 ))
281300 self .assertFalse (future_decryption_result .success )
282301 self .assertEqual (DecryptionStatus .EXPIRED_TOKEN , future_decryption_result .status )
283302 self .assertEqual (now + dt .timedelta (seconds = 2 ), future_decryption_result .expiry )
0 commit comments