@Test
void manipulatedMetadataThrowsSignatureException() throws Exception
{

  EidasMetadataService eidasMetadataService = getEidasMetadataService();
  EidasSigner signer = new EidasSigner(keyPair.getKey(), keyPair.getCert());
  byte[] metadataByteArray = eidasMetadataService.generate(signer);
  String metadataString = new String(metadataByteArray);
  String manipulatedString = metadataString.replace("entityID", "newEntityID");
  byte[] manipulatedStringBytes = manipulatedString.getBytes(StandardCharsets.UTF_8);
  EntityDescriptor entityDescriptor = getEntityDescriptor(manipulatedStringBytes);
  SAMLSignatureProfileValidator samlSignatureProfileValidator = new SAMLSignatureProfileValidator();
  samlSignatureProfileValidator.validate(entityDescriptor.getSignature());
  Credential credential = new BasicX509Credential(keyPair.getCert());
  Signature sig = entityDescriptor.getSignature();
  Assertions.assertThrows(SignatureException.class, () -> SignatureValidator.validate(sig, credential));
}