use of com.nexblocks.authguard.service.config.JwtConfig in project AuthGuard by AuthGuard.
the class TokenEncryptorAdapterTest method initializeWithUnsupportedAlgorithm.
@Test
void initializeWithUnsupportedAlgorithm() {
final JwtConfig jwtConfig = JwtConfig.builder().encryption(EncryptionConfig.builder().algorithm("unknown").build()).build();
assertThatThrownBy(() -> new TokenEncryptorAdapter(jwtConfig)).isInstanceOf(ConfigurationException.class);
}
use of com.nexblocks.authguard.service.config.JwtConfig in project AuthGuard by AuthGuard.
the class TokenEncryptorAdapterTest method encryptAndDecryptNotEnabled.
@Test
void encryptAndDecryptNotEnabled() {
final JwtConfig jwtConfig = JwtConfig.builder().build();
final TokenEncryptorAdapter encryptor = new TokenEncryptorAdapter(jwtConfig);
assertThat(encryptor.encryptAndEncode("").isLeft()).isTrue();
assertThat(encryptor.decryptEncoded("").isLeft()).isTrue();
}
use of com.nexblocks.authguard.service.config.JwtConfig in project AuthGuard by AuthGuard.
the class TokenEncryptorAdapterTest method encryptAndDecryptAes.
@Test
void encryptAndDecryptAes() {
final JwtConfig jwtConfig = JwtConfig.builder().encryption(EncryptionConfig.builder().algorithm("AES_CBC").privateKey("src/test/resources/aes128.txt").build()).build();
final TokenEncryptorAdapter encryptor = new TokenEncryptorAdapter(jwtConfig);
final String encrypted = encryptor.encryptAndEncode(TOKEN).get();
final String decrypted = encryptor.decryptEncoded(encrypted).get();
assertThat(decrypted).isEqualTo(TOKEN);
}
Aggregations