@Test
public void matchesCanary_shouldReturnTrue_IfTheCanaryDecryptsToTheCanaryValue() throws Exception {

  when(encryptionKeyCanary.getEncryptedCanaryValue()).thenReturn("value".getBytes(UTF_8));
  when(encryptionKeyCanary.getNonce()).thenReturn("nonce".getBytes(UTF_8));
  when(encryptionKeyMetadata.getEncryptionKeyName()).thenReturn("name");
  when(encryptionProvider.decrypt(any(), any(), any())).thenReturn(EncryptionKeyCanaryMapper.CANARY_VALUE);
  subject = new ExternalKeyProxy(encryptionKeyMetadata, encryptionProvider);
  assertTrue(subject.matchesCanary(encryptionKeyCanary));
  final ArgumentCaptor<EncryptionKey> argument = ArgumentCaptor.forClass(EncryptionKey.class);
  verify(encryptionProvider).decrypt(argument.capture(), eq("value".getBytes(UTF_8)), eq("nonce".getBytes(UTF_8)));
  assertEquals(encryptionProvider, argument.getValue().getProvider());
  assertEquals("name", argument.getValue().getEncryptionKeyName());
}