@Test
public void respectsClientAuthConfig() {

  ApiDate now = ApiDate.now();
  Client otherClient =
      new Client(2345L, "other-client", "desc", null, now, "automatic", now, "automatic",
          null, null, true, false
      );
  when(clientDAO.getClientByName(clientName)).thenReturn(Optional.of(client));
  when(clientDAO.getClientBySpiffeId(clientSpiffe)).thenReturn(
      Optional.of(otherClient));
  // Retrieve the client using the client name only
  when(clientAuthTypeConfig.useCommonName()).thenReturn(true);
  when(clientAuthTypeConfig.useSpiffeId()).thenReturn(false);
  assertThat(authenticator.authenticate(certPrincipal, false)).isEqualTo(Optional.of(client));
  // Retrieve the client using the SPIFFE ID only
  when(clientAuthTypeConfig.useCommonName()).thenReturn(false);
  when(clientAuthTypeConfig.useSpiffeId()).thenReturn(true);
  assertThat(authenticator.authenticate(certPrincipal, false)).isEqualTo(
      Optional.of(otherClient));
}