Search in sources :

Example 6 with KMSConfig

use of com.github.ambry.config.KMSConfig in project ambry by linkedin.

the class CryptoJobHandlerTest method testDecryptionFailure.

/**
 * Tests {@link CryptoJobHandler} for failures during decryption
 * @throws InterruptedException
 * @throws GeneralSecurityException
 */
@Test
public void testDecryptionFailure() throws InterruptedException, GeneralSecurityException {
    cryptoJobHandler.close();
    MockCryptoService mockCryptoService = new MockCryptoService(new CryptoServiceConfig(verifiableProperties));
    mockCryptoService.exceptionOnDecryption.set(new GeneralSecurityException("Exception to test", new IllegalStateException()));
    cryptoJobHandler = new CryptoJobHandler(DEFAULT_THREAD_COUNT);
    SecretKeySpec perBlobSecretKey = kms.getRandomKey();
    testFailureOnDecryption(perBlobSecretKey, null, false, mockCryptoService, kms);
    mockCryptoService.clearStates();
    cryptoJobHandler.close();
    MockKeyManagementService mockKms = new MockKeyManagementService(new KMSConfig(verifiableProperties), defaultKey);
    cryptoJobHandler = new CryptoJobHandler(DEFAULT_THREAD_COUNT);
    testFailureOnDecryption(perBlobSecretKey, mockKms, true, cryptoService, mockKms);
}
Also used : KMSConfig(com.github.ambry.config.KMSConfig) CryptoServiceConfig(com.github.ambry.config.CryptoServiceConfig) SecretKeySpec(javax.crypto.spec.SecretKeySpec) GeneralSecurityException(java.security.GeneralSecurityException) Test(org.junit.Test)

Aggregations

KMSConfig (com.github.ambry.config.KMSConfig)6 CryptoServiceConfig (com.github.ambry.config.CryptoServiceConfig)4 VerifiableProperties (com.github.ambry.config.VerifiableProperties)4 Test (org.junit.Test)4 BlobProperties (com.github.ambry.messageformat.BlobProperties)3 Properties (java.util.Properties)3 SecretKeySpec (javax.crypto.spec.SecretKeySpec)3 LoggingNotificationSystem (com.github.ambry.commons.LoggingNotificationSystem)2 ResponseHandler (com.github.ambry.commons.ResponseHandler)2 RouterConfig (com.github.ambry.config.RouterConfig)2 GeneralSecurityException (java.security.GeneralSecurityException)2 InMemAccountService (com.github.ambry.account.InMemAccountService)1 MockClusterMap (com.github.ambry.clustermap.MockClusterMap)1 ReplicaId (com.github.ambry.clustermap.ReplicaId)1 BlobId (com.github.ambry.commons.BlobId)1 ByteBufferReadableStreamChannel (com.github.ambry.commons.ByteBufferReadableStreamChannel)1 SocketNetworkClient (com.github.ambry.network.SocketNetworkClient)1 ServerErrorCode (com.github.ambry.server.ServerErrorCode)1 MockTime (com.github.ambry.utils.MockTime)1 ByteBuf (io.netty.buffer.ByteBuf)1