|
4 | 4 | import com.google.gson.JsonObject; |
5 | 5 | import org.junit.jupiter.api.Test; |
6 | 6 | import org.junit.jupiter.params.ParameterizedTest; |
7 | | -import org.junit.jupiter.params.provider.Arguments; |
8 | | -import org.junit.jupiter.params.provider.CsvSource; |
9 | | -import org.junit.jupiter.params.provider.MethodSource; |
10 | | -import org.junit.jupiter.params.provider.ValueSource; |
| 7 | +import org.junit.jupiter.params.provider.*; |
11 | 8 |
|
12 | 9 | import java.time.Duration; |
13 | 10 | import java.time.Instant; |
14 | 11 | import java.time.temporal.ChronoUnit; |
15 | 12 | import java.util.Arrays; |
| 13 | +import java.util.Base64; |
16 | 14 | import java.util.stream.Stream; |
17 | 15 |
|
18 | 16 | import static com.uid2.client.EncryptionTestsV4.validateAdvertisingToken; |
@@ -288,6 +286,26 @@ public void tokenExpiryAndCustomNow() throws Exception { |
288 | 286 | assertEquals(EXAMPLE_UID, res.getUid()); |
289 | 287 | } |
290 | 288 |
|
| 289 | + @ParameterizedTest |
| 290 | + @EnumSource(IdentityScope.class) |
| 291 | + void decryptV4TokenEncodedAsBase64(IdentityScope identityScope) throws Exception { |
| 292 | + refresh(keyBidstreamResponse(identityScope, MASTER_KEY, SITE_KEY)); |
| 293 | + |
| 294 | + String advertisingToken; |
| 295 | + do { |
| 296 | + advertisingToken = AdvertisingTokenBuilder.builder() |
| 297 | + .withVersion(TokenVersionForTesting.V4) |
| 298 | + .withScope(identityScope) |
| 299 | + .build(); |
| 300 | + |
| 301 | + byte[] tokenAsBytes = Uid2Base64UrlCoder.decode(advertisingToken); |
| 302 | + advertisingToken = Base64.getEncoder().encodeToString(tokenAsBytes); |
| 303 | + } |
| 304 | + while (!advertisingToken.contains("=") || !advertisingToken.contains("/") || !advertisingToken.contains("+")); |
| 305 | + |
| 306 | + decryptAndAssertSuccess(advertisingToken, TokenVersionForTesting.V4); |
| 307 | + } |
| 308 | + |
291 | 309 | private void refresh(String json) { |
292 | 310 | RefreshResponse refreshResponse = bidstreamClient.refreshJson(json); |
293 | 311 | assertTrue(refreshResponse.isSuccess()); |
|
0 commit comments