Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mmoayyed committed Sep 5, 2024
1 parent 2595fde commit 44aa77b
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ public Pair<String, String> buildSelfSignedSigningCert(final Optional<SamlRegist

@Override
protected String writeMetadata(final String metadata, final Optional<SamlRegisteredService> registeredService) throws Throwable {
val metadataFile = getConfigurationContext().getSamlIdPMetadataLocator().resolveMetadata(registeredService).getFile();
val metadataResource = getConfigurationContext().getSamlIdPMetadataLocator().resolveMetadata(registeredService);
val metadataFile = metadataResource.getFile();
LOGGER.info("Writing SAML2 metadata to [{}]", metadataFile);

val mdProps = getConfigurationContext().getCasProperties().getAuthn().getSamlIdp().getMetadata();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.springframework.context.support.StaticApplicationContext;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.FileSystemResource;
import org.springframework.test.context.TestPropertySource;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
Expand All @@ -40,6 +41,7 @@
* @since 5.0.0
*/
@Tag("SAML2")
@TestPropertySource(properties = "cas.authn.saml-idp.metadata.file-system.location=${#systemProperties['java.io.tmpdir']}/saml33182")
class SamlRegisteredServiceTests extends BaseSamlIdPConfigurationTests {

private static final ObjectMapper MAPPER = JacksonObjectMapperFactory.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@
* @since 6.3.0
*/
@Tag("SAML2")
@TestPropertySource(properties = "cas.tgc.crypto.enabled=false")
@TestPropertySource(properties = {
"cas.authn.saml-idp.metadata.file-system.location=${#systemProperties['java.io.tmpdir']}/saml22182",
"cas.tgc.crypto.enabled=false"
})
class SamlResponseArtifactEncoderTests extends BaseSamlIdPConfigurationTests {
@Test
void verifyOperation() throws Throwable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,12 @@
import org.apereo.cas.config.CasCoreSamlAutoConfiguration;
import org.apereo.cas.config.CasSamlIdPAutoConfiguration;
import org.apereo.cas.support.saml.OpenSamlConfigBean;
import org.apereo.cas.support.saml.idp.metadata.locator.FileSystemSamlIdPMetadataLocator;
import org.apereo.cas.support.saml.idp.metadata.locator.SamlIdPMetadataLocator;
import org.apereo.cas.support.saml.services.SamlRegisteredService;
import org.apereo.cas.support.saml.services.idp.metadata.SamlIdPMetadataDocument;
import org.apereo.cas.support.saml.services.idp.metadata.SamlRegisteredServiceMetadataAdaptor;
import org.apereo.cas.support.saml.services.idp.metadata.cache.SamlRegisteredServiceCachingMetadataResolver;
import org.apereo.cas.support.saml.web.idp.profile.builders.enc.SamlIdPObjectSigner;
import org.apereo.cas.test.CasTestExtension;
import org.apereo.cas.util.crypto.CipherExecutor;
import com.github.benmanes.caffeine.cache.Cache;
import lombok.val;
import org.apache.commons.io.FileUtils;
import org.junit.jupiter.api.extension.ExtendWith;
import org.opensaml.messaging.context.MessageContext;
import org.opensaml.saml.common.xml.SAMLConstants;
Expand All @@ -24,11 +18,6 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;
import org.springframework.core.io.FileSystemResource;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.util.UUID;
Expand All @@ -40,7 +29,6 @@
* @author Misagh Moayyed
* @since 6.2.0
*/
@Import(BaseSamlIdPWebflowTests.SamlIdPMetadataTestConfiguration.class)
@ImportAutoConfiguration({
CasCoreSamlAutoConfiguration.class,
CasSamlIdPAutoConfiguration.class
Expand Down Expand Up @@ -82,22 +70,6 @@ protected static AuthnRequest getAuthnRequestFor(final String service) {
when(authnRequest.getIssuer()).thenReturn(issuer);
return authnRequest;
}

@TestConfiguration(value = "SamlIdPMetadataTestConfiguration", proxyBeanMethods = false)
static class SamlIdPMetadataTestConfiguration {
@Autowired
@Qualifier("samlIdPMetadataCache")
private Cache<String, SamlIdPMetadataDocument> samlIdPMetadataCache;

@Bean
public SamlIdPMetadataLocator samlIdPMetadataLocator(
final ConfigurableApplicationContext applicationContext) throws Exception {
return new FileSystemSamlIdPMetadataLocator(
CipherExecutor.noOpOfStringToString(),
new FileSystemResource(FileUtils.getTempDirectory()),
samlIdPMetadataCache, applicationContext);
}
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import org.springframework.test.context.TestPropertySource;
import java.util.List;
import java.util.UUID;
import static org.junit.jupiter.api.Assertions.*;
Expand All @@ -31,6 +32,7 @@
*/
@Tag("SAML2")
@ImportAutoConfiguration(CasConsentCoreAutoConfiguration.class)
@TestPropertySource(properties = "cas.authn.saml-idp.metadata.file-system.location=${#systemProperties['java.io.tmpdir']}/saml12182")
class SamlIdPConsentSingleSignOnParticipationStrategyTests extends BaseSamlIdPWebflowTests {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ server.jetty.threads.min=20
server.jetty.connection-idle-timeout=15000
server.jetty.accesslog.enabled=true
server.jetty.accesslog.file-date-format=yyyy-MM-dd
server.jetty.accesslog.filename=build/jetty-requests.log
server.jetty.accesslog.filename=jetty-requests.log
server.jetty.accesslog.retention-period=2

##
Expand Down

0 comments on commit 44aa77b

Please sign in to comment.