Skip to content

Commit

Permalink
Apply getAndValidateCurrentUser renaming for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbalakirev committed Oct 27, 2024
1 parent 5a897c4 commit d95ed11
Showing 1 changed file with 44 additions and 3 deletions.
47 changes: 44 additions & 3 deletions src/test/java/com/corbado/unit/SessionServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,17 @@ void test_getCurrentUser(final String jwt, final Class<Exception> e)
throws StandardException, IncorrectClaimException, JWTVerificationException, JwkException {

if (e != null) {
assertThrows(e, () -> sessionService.getAndValidateCurrentUser(jwt));
assertThrows(e, () -> sessionService.validateToken(jwt));
} else {
final SessionValidationResult validationResult =
sessionService.getAndValidateCurrentUser(jwt);
final SessionValidationResult validationResult = sessionService.validateToken(jwt);
assertEquals(TEST_NAME, validationResult.getFullName());
assertEquals(TEST_USER_ID, validationResult.getUserID());
}
/**
* Inits the parameters test data.
*
* @return the stream
*/
}

// ------------------ Test data --------------------- //
Expand All @@ -213,6 +217,13 @@ static Stream<Object[]> initParametersTestData() {
new Object[] {"s", "", "name", false},
// Test empty short_session_cookie_name
new Object[] {"s", "2", "", false});
/**
* Provide jwts.
*
* @return the list
* @throws InvalidKeySpecException the invalid key spec exception
* @throws NoSuchAlgorithmException the no such algorithm exception
*/
}

/**
Expand Down Expand Up @@ -275,6 +286,15 @@ static List<Object[]> provideJwts() throws InvalidKeySpecException, NoSuchAlgori
});

return testData;
/**
* Read private key.
*
* @param privateKeyPath the private key path
* @return the RSA private key
* @throws IOException Signals that an I/O exception has occurred.
* @throws NoSuchAlgorithmException the no such algorithm exception
* @throws InvalidKeySpecException the invalid key spec exception
*/
}

// ------------------ Utility functions--------------------- //
Expand Down Expand Up @@ -302,6 +322,16 @@ private static RSAPrivateKey readPrivateKey(final String privateKeyPath)
final KeyFactory keyFactory = KeyFactory.getInstance("RSA");
final PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(encoded);
return (RSAPrivateKey) keyFactory.generatePrivate(keySpec);
/**
* Generate jwt.
*
* @param iss the iss
* @param exp the exp
* @param nbf the nbf
* @return the string
* @throws InvalidKeySpecException the invalid key spec exception
* @throws NoSuchAlgorithmException the no such algorithm exception
*/
}

/**
Expand Down Expand Up @@ -329,6 +359,11 @@ private static String generateJwt(final String iss, final long exp, final long n
.withClaim("email", TEST_EMAIL)
.withClaim("phone_number", TEST_PHONE_NUMBER)
.sign(algorithm);
/**
* Creates the session service.
*
* @return the session service
*/
}

/**
Expand All @@ -342,6 +377,12 @@ private static SessionService createSessionService() {
"https://example_uri.com",
10,
false); // URLs do not matter, url access is mocked
/**
* Read jwks.
*
* @return the json array
* @throws FileNotFoundException the file not found exception
*/
}

/**
Expand Down

0 comments on commit d95ed11

Please sign in to comment.