I have a class that looks like this
@Component
public class SecurityUtility {
private final String SALT = "salt";
@Bean
public BCryptPasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder(12, new SecureRandom(SALT.getBytes()));
}
@Bean
public String randomPassword() {
String SALTCHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
StringBuilder salt = new StringBuilder();
Random rnd = new Random();
while (salt.length() < 18) {
int index = (int) (rnd.nextFloat() * SALTCHARS.length());
salt.append(SALTCHARS.charAt(index));
}
String saltStr = salt.toString();
return saltStr;
}
}
What can I do to test such a class and how do I go about it , normally I have been doing unit tests but this class , don't know what type of test or how to go about it . Thank you in advance for any suggestion
Aucun commentaire:
Enregistrer un commentaire