1919import com .google .gson .JsonObject ;
2020import io .supertokens .ProcessState .EventAndException ;
2121import io .supertokens .ProcessState .PROCESS_STATE ;
22+ import io .supertokens .exceptions .AccessTokenPayloadError ;
2223import io .supertokens .exceptions .TryRefreshTokenException ;
2324import io .supertokens .pluginInterface .exceptions .StorageQueryException ;
2425import io .supertokens .pluginInterface .exceptions .StorageTransactionLogicException ;
@@ -72,7 +73,7 @@ public void beforeEach() {
7273 // * - create session with some data -> expire -> get access token without verifying, check payload is fine.
7374 @ Test
7475 public void testCreateSessionWithDataExpireGetAccessTokenAndCheckPayload () throws Exception {
75- String [] args = { "../" };
76+ String [] args = {"../" };
7677
7778 Utils .setValueInConfig ("access_token_validity" , "1" ); // 1 second validity
7879
@@ -105,10 +106,11 @@ public void testCreateSessionWithDataExpireGetAccessTokenAndCheckPayload() throw
105106 assertNotNull (process .checkOrWaitForEvent (PROCESS_STATE .STOPPED ));
106107
107108 }
109+
108110 // * - create session with some data -> expire -> get access token without verifying, check payload is fine.
109111 @ Test
110112 public void testCreateSessionV2WithDataExpireGetAccessTokenAndCheckPayload () throws Exception {
111- String [] args = { "../" };
113+ String [] args = {"../" };
112114
113115 Utils .setValueInConfig ("access_token_validity" , "1" ); // 1 second validity
114116
@@ -146,7 +148,7 @@ public void testCreateSessionV2WithDataExpireGetAccessTokenAndCheckPayload() thr
146148 // what you gave
147149 @ Test
148150 public void testSessionWithOldExpiryTimeForAccessToken () throws Exception {
149- String [] args = { "../" };
151+ String [] args = {"../" };
150152
151153 TestingProcess process = TestingProcessManager .start (args );
152154 assertNotNull (process .checkOrWaitForEvent (PROCESS_STATE .STARTED ));
@@ -181,7 +183,7 @@ public void testSessionWithOldExpiryTimeForAccessToken() throws Exception {
181183 // what you gave
182184 @ Test
183185 public void testSessionWithOldExpiryTimeForAccessTokenV2 () throws Exception {
184- String [] args = { "../" };
186+ String [] args = {"../" };
185187
186188 TestingProcess process = TestingProcessManager .start (args );
187189 assertNotNull (process .checkOrWaitForEvent (PROCESS_STATE .STARTED ));
@@ -215,7 +217,7 @@ public void testSessionWithOldExpiryTimeForAccessTokenV2() throws Exception {
215217 // * - create access token version 2 -> get version -> should be 2
216218 @ Test
217219 public void testCreateAccessTokenVersion2AndCheck () throws Exception {
218- String [] args = { "../" };
220+ String [] args = {"../" };
219221
220222 TestingProcess process = TestingProcessManager .start (args );
221223 assertNotNull (process .checkOrWaitForEvent (PROCESS_STATE .STARTED ));
@@ -244,7 +246,7 @@ public void testCreateAccessTokenVersion2AndCheck() throws Exception {
244246 // good case test
245247 @ Test
246248 public void inputOutputTest () throws Exception {
247- String [] args = { "../" };
249+ String [] args = {"../" };
248250 TestingProcess process = TestingProcessManager .start (args );
249251 EventAndException e = process .checkOrWaitForEvent (PROCESS_STATE .STARTED );
250252 assertNotNull (e );
@@ -254,25 +256,27 @@ public void inputOutputTest() throws Exception {
254256 // db key
255257 long expiryTime = System .currentTimeMillis () + 1000 ;
256258 TokenInfo newToken = AccessToken .createNewAccessToken (process .getProcess (), "sessionHandle" , "userId" ,
257- "refreshTokenHash1" , "parentRefreshTokenHash1" , jsonObj , "antiCsrfToken" , expiryTime , AccessToken .VERSION .V3 , false );
259+ "refreshTokenHash1" , "parentRefreshTokenHash1" , jsonObj , "antiCsrfToken" , expiryTime ,
260+ AccessToken .VERSION .V3 , false );
258261 AccessTokenInfo info = AccessToken .getInfoFromAccessToken (process .getProcess (), newToken .token , true );
259262 assertEquals ("sessionHandle" , info .sessionHandle );
260263 assertEquals ("userId" , info .userId );
261264 assertEquals ("refreshTokenHash1" , info .refreshTokenHash1 );
262265 assertEquals ("parentRefreshTokenHash1" , info .parentRefreshTokenHash1 );
263266 assertEquals ("value" , info .userData .get ("key" ).getAsString ());
264267 assertEquals ("antiCsrfToken" , info .antiCsrfToken );
265- assertEquals (expiryTime / 1000 * 1000 , info .expiryTime );
268+ assertEquals (expiryTime / 1000 * 1000 , info .expiryTime );
266269
267270 JWT .JWTPreParseInfo jwtInfo = JWT .preParseJWTInfo (newToken .token );
268271 assertNotNull (jwtInfo .kid );
269272 assertEquals (jwtInfo .version , AccessToken .VERSION .V3 );
270273
271274 process .kill ();
272275 }
276+
273277 @ Test
274278 public void inputOutputTestStatic () throws Exception {
275- String [] args = { "../" };
279+ String [] args = {"../" };
276280 TestingProcess process = TestingProcessManager .start (args );
277281 EventAndException e = process .checkOrWaitForEvent (PROCESS_STATE .STARTED );
278282 assertNotNull (e );
@@ -282,15 +286,16 @@ public void inputOutputTestStatic() throws Exception {
282286 // db key
283287 long expiryTime = System .currentTimeMillis () + 1000 ;
284288 TokenInfo newToken = AccessToken .createNewAccessToken (process .getProcess (), "sessionHandle" , "userId" ,
285- "refreshTokenHash1" , "parentRefreshTokenHash1" , jsonObj , "antiCsrfToken" , expiryTime , AccessToken .VERSION .V3 , true );
289+ "refreshTokenHash1" , "parentRefreshTokenHash1" , jsonObj , "antiCsrfToken" , expiryTime ,
290+ AccessToken .VERSION .V3 , true );
286291 AccessTokenInfo info = AccessToken .getInfoFromAccessToken (process .getProcess (), newToken .token , true );
287292 assertEquals ("sessionHandle" , info .sessionHandle );
288293 assertEquals ("userId" , info .userId );
289294 assertEquals ("refreshTokenHash1" , info .refreshTokenHash1 );
290295 assertEquals ("parentRefreshTokenHash1" , info .parentRefreshTokenHash1 );
291296 assertEquals ("value" , info .userData .get ("key" ).getAsString ());
292297 assertEquals ("antiCsrfToken" , info .antiCsrfToken );
293- assertEquals (expiryTime / 1000 * 1000 , info .expiryTime );
298+ assertEquals (expiryTime / 1000 * 1000 , info .expiryTime );
294299
295300 JWT .JWTPreParseInfo jwtInfo = JWT .preParseJWTInfo (newToken .token );
296301 assertNotNull (jwtInfo .kid );
@@ -300,7 +305,7 @@ public void inputOutputTestStatic() throws Exception {
300305
301306 @ Test
302307 public void inputOutputTestV2 () throws Exception {
303- String [] args = { "../" };
308+ String [] args = {"../" };
304309 TestingProcess process = TestingProcessManager .start (args );
305310 EventAndException e = process .checkOrWaitForEvent (PROCESS_STATE .STARTED );
306311 assertNotNull (e );
@@ -310,7 +315,8 @@ public void inputOutputTestV2() throws Exception {
310315 // db key
311316 long expiryTime = System .currentTimeMillis () + 1000 ;
312317 TokenInfo newToken = AccessToken .createNewAccessToken (process .getProcess (), "sessionHandle" , "userId" ,
313- "refreshTokenHash1" , "parentRefreshTokenHash1" , jsonObj , "antiCsrfToken" , expiryTime , AccessToken .VERSION .V2 , false );
318+ "refreshTokenHash1" , "parentRefreshTokenHash1" , jsonObj , "antiCsrfToken" , expiryTime ,
319+ AccessToken .VERSION .V2 , false );
314320 AccessTokenInfo info = AccessToken .getInfoFromAccessToken (process .getProcess (), newToken .token , true );
315321 assertEquals ("sessionHandle" , info .sessionHandle );
316322 assertEquals ("userId" , info .userId );
@@ -325,8 +331,8 @@ public void inputOutputTestV2() throws Exception {
325331 @ Test
326332 public void inputOutputTestv1 () throws InterruptedException , InvalidKeyException , NoSuchAlgorithmException ,
327333 StorageQueryException , StorageTransactionLogicException , TryRefreshTokenException ,
328- UnsupportedEncodingException , InvalidKeySpecException , SignatureException {
329- String [] args = { "../" };
334+ UnsupportedEncodingException , InvalidKeySpecException , SignatureException , AccessTokenPayloadError {
335+ String [] args = {"../" };
330336 TestingProcess process = TestingProcessManager .start (args );
331337 EventAndException e = process .checkOrWaitForEvent (PROCESS_STATE .STARTED );
332338 assertNotNull (e );
@@ -352,7 +358,7 @@ public void signingKeyShortInterval()
352358 throws InterruptedException , StorageQueryException , StorageTransactionLogicException , IOException {
353359 Utils .setValueInConfig ("access_token_dynamic_signing_key_update_interval" , "0.00027" ); // 1 second
354360
355- String [] args = { "../" };
361+ String [] args = {"../" };
356362 TestingProcess process = TestingProcessManager .start (args );
357363 EventAndException e = process .checkOrWaitForEvent (PROCESS_STATE .STARTED );
358364 assertNotNull (e );
@@ -368,7 +374,7 @@ public void signingKeyShortInterval()
368374 public void signingKeyChangeDoesNotThrow () throws Exception {
369375 Utils .setValueInConfig ("access_token_dynamic_signing_key_update_interval" , "0.00027" ); // 1 second
370376
371- String [] args = { "../" };
377+ String [] args = {"../" };
372378 TestingProcess process = TestingProcessManager .start (args );
373379 EventAndException e = process .checkOrWaitForEvent (PROCESS_STATE .STARTED );
374380 assertNotNull (e );
@@ -394,7 +400,7 @@ public void accessTokenShortLifetimeThrowsRefreshTokenError()
394400 throws Exception {
395401 Utils .setValueInConfig ("access_token_validity" , "1" ); // 1 second
396402
397- String [] args = { "../" };
403+ String [] args = {"../" };
398404 TestingProcess process = TestingProcessManager .start (args );
399405 EventAndException e = process .checkOrWaitForEvent (PROCESS_STATE .STARTED );
400406 assertNotNull (e );
@@ -421,7 +427,7 @@ public void accessTokenShortLifetimeThrowsRefreshTokenError()
421427 @ Test
422428 public void verifyRandomAccessTokenFailure ()
423429 throws InterruptedException , StorageQueryException , StorageTransactionLogicException {
424- String [] args = { "../" };
430+ String [] args = {"../" };
425431 TestingProcess process = TestingProcessManager .start (args );
426432 assertNotNull (process .checkOrWaitForEvent (PROCESS_STATE .STARTED ));
427433
@@ -439,7 +445,7 @@ public void keyChangeThreadSafetyTest() throws Exception {
439445 Utils .setValueInConfig ("access_token_dynamic_signing_key_update_interval" , "0.00027" ); // 1 second
440446 Utils .setValueInConfig ("access_token_validity" , "1" ); // 1 second
441447
442- String [] args = { "../" };
448+ String [] args = {"../" };
443449 TestingProcess process = TestingProcessManager .start (args );
444450 EventAndException e = process .checkOrWaitForEvent (PROCESS_STATE .STARTED );
445451 assertNotNull (e );
0 commit comments