@Test
void validateMetadataWithWrongCredentialsThrowsSignatureException() throws Exception
{

  EidasMetadataService eidasMetadataService = getEidasMetadataService();
  EidasSigner signer = new EidasSigner(keyPair.getKey(), keyPair.getCert());
  byte[] metadataByteArray = eidasMetadataService.generate(signer);
  EntityDescriptor entityDescriptor = getEntityDescriptor(metadataByteArray);
  SAMLSignatureProfileValidator samlSignatureProfileValidator = new SAMLSignatureProfileValidator();
  samlSignatureProfileValidator.validate(entityDescriptor.getSignature());
  X509Certificate x509Certificate = Utils.readCert(EidasMetadataServiceTest.class.getResourceAsStream("/WrongSignerCert.cer"));
  Signature sig = entityDescriptor.getSignature();
  BasicCredential bc = new BasicX509Credential(x509Certificate);
  Assertions.assertThrows(SignatureException.class, () -> SignatureValidator.validate(sig, bc));
}