Search in sources :

Example 1 with EncryptedValueDataService

use of org.cloudfoundry.credhub.data.EncryptedValueDataService in project credhub by cloudfoundry-incubator.

the class EncryptionKeyRotatorTest method beforeEach.

@Before
public void beforeEach() {
    oldUuid = UUID.randomUUID();
    UUID activeUuid = UUID.randomUUID();
    encryptedValueDataService = mock(EncryptedValueDataService.class);
    keySet = new EncryptionKeySet();
    keySet.add(new EncryptionKey(mock(EncryptionService.class), oldUuid, mock(Key.class)));
    keySet.add(new EncryptionKey(mock(EncryptionService.class), activeUuid, mock(Key.class)));
    keySet.setActive(activeUuid);
    encryptedValue1 = mock(EncryptedValue.class);
    encryptedValue2 = mock(EncryptedValue.class);
    encryptedValue3 = mock(EncryptedValue.class);
    encryptionKeyCanaryMapper = mock(EncryptionKeyCanaryMapper.class);
    inactiveCanaries = newArrayList(oldUuid);
    when(encryptedValueDataService.findByCanaryUuids(inactiveCanaries)).thenReturn(new SliceImpl<>(asList(encryptedValue1, encryptedValue2))).thenReturn(new SliceImpl<>(asList(encryptedValue3))).thenReturn(new SliceImpl<>(new ArrayList<>()));
    final EncryptionKeyRotator encryptionKeyRotator = new EncryptionKeyRotator(encryptedValueDataService, encryptionKeyCanaryMapper, keySet);
    encryptionKeyRotator.rotate();
}
Also used : ArrayList(java.util.ArrayList) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) UUID(java.util.UUID) EncryptedValue(org.cloudfoundry.credhub.entity.EncryptedValue) EncryptedValueDataService(org.cloudfoundry.credhub.data.EncryptedValueDataService) SliceImpl(org.springframework.data.domain.SliceImpl) Before(org.junit.Before)

Aggregations

Lists.newArrayList (com.google.common.collect.Lists.newArrayList)1 ArrayList (java.util.ArrayList)1 UUID (java.util.UUID)1 EncryptedValueDataService (org.cloudfoundry.credhub.data.EncryptedValueDataService)1 EncryptedValue (org.cloudfoundry.credhub.entity.EncryptedValue)1 Before (org.junit.Before)1 SliceImpl (org.springframework.data.domain.SliceImpl)1