@Test
    void verifyOperation() throws Throwable {
        val registeredService = Optional.<SamlRegisteredService>empty();
        samlIdPMetadataGenerator.generate(registeredService);
        samlIdPMetadataCache.invalidateAll();

        /*
         * Tamper with metadata manually.
         */
        val bucketNameToUse = AmazonS3SamlIdPMetadataUtils.determineBucketNameFor(registeredService,
            casProperties.getAuthn().getSamlIdp().getMetadata().getAmazonS3().getIdpMetadataBucketName(), amazonS3Client);
        val document = new SamlIdPMetadataDocument();
        document.setId(RandomUtils.nextLong());
        AmazonS3SamlIdPMetadataUtils.putSamlIdPMetadataIntoBucket(amazonS3Client, document, bucketNameToUse);
        assertThrows(IllegalArgumentException.class, () -> samlIdPMetadataGenerator.generate(registeredService));
        samlIdPMetadataCache.invalidateAll();
        assertEquals(ResourceUtils.EMPTY_RESOURCE, samlIdPMetadataLocator.resolveMetadata(registeredService));

        samlIdPMetadataGenerator.generate(registeredService);
        assertNotNull(samlIdPMetadataLocator.resolveMetadata(registeredService));
        assertNotNull(samlIdPMetadataLocator.resolveEncryptionCertificate(registeredService));
        assertNotNull(samlIdPMetadataLocator.resolveEncryptionKey(registeredService));
        assertNotNull(samlIdPMetadataLocator.resolveSigningCertificate(registeredService));
        assertNotNull(samlIdPMetadataLocator.resolveSigningKey(registeredService));
    }
This is {@link AmazonS3SamlIdPMetadataGeneratorTests}.

@author Misagh Moayyed
@since 6.0.0
support/cas-server-support-saml-idp-metadata-aws-s3/src/test/java/org/apereo/cas/support/saml/idp/metadata/AmazonS3SamlIdPMetadataGeneratorTests.java