aboutsummaryrefslogtreecommitdiff
path: root/id/server/idserverlib/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'id/server/idserverlib/src/test')
-rw-r--r--id/server/idserverlib/src/test/java/at/gv/egovnerment/moa/id/config/auth/AuthConfigurationProviderLegacyCompatibilityTest.java110
-rw-r--r--id/server/idserverlib/src/test/java/at/gv/egovnerment/moa/id/config/auth/TestLegacyAuthConfigurationProvider.java31
-rw-r--r--id/server/idserverlib/src/test/resources/log4j.xml16
3 files changed, 157 insertions, 0 deletions
diff --git a/id/server/idserverlib/src/test/java/at/gv/egovnerment/moa/id/config/auth/AuthConfigurationProviderLegacyCompatibilityTest.java b/id/server/idserverlib/src/test/java/at/gv/egovnerment/moa/id/config/auth/AuthConfigurationProviderLegacyCompatibilityTest.java
new file mode 100644
index 000000000..bd997303a
--- /dev/null
+++ b/id/server/idserverlib/src/test/java/at/gv/egovnerment/moa/id/config/auth/AuthConfigurationProviderLegacyCompatibilityTest.java
@@ -0,0 +1,110 @@
+package at.gv.egovnerment.moa.id.config.auth;
+
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+
+import java.util.Collections;
+
+import org.junit.Test;
+import org.unitils.reflectionassert.ReflectionAssert;
+
+import at.gv.egovernment.moa.id.commons.db.MOAIDConfigurationConstants;
+import at.gv.egovernment.moa.id.commons.db.dao.config.AuthComponentGeneral;
+import at.gv.egovernment.moa.id.commons.db.dao.config.ChainingModes;
+import at.gv.egovernment.moa.id.commons.db.dao.config.GeneralConfiguration;
+import at.gv.egovernment.moa.id.commons.db.dao.config.MOAIDConfiguration;
+import at.gv.egovernment.moa.id.commons.db.dao.config.MOASP;
+import at.gv.egovernment.moa.id.commons.db.dao.config.OAuth;
+import at.gv.egovernment.moa.id.commons.db.dao.config.PVP2;
+import at.gv.egovernment.moa.id.commons.db.dao.config.Protocols;
+import at.gv.egovernment.moa.id.commons.db.dao.config.SAML1;
+import at.gv.egovernment.moa.id.commons.db.dao.config.SLRequestTemplates;
+import at.gv.egovernment.moa.id.commons.db.dao.config.SecurityLayer;
+import at.gv.egovernment.moa.id.commons.db.dao.config.TransformsInfoType;
+import at.gv.egovernment.moa.id.commons.db.dao.config.VerifyAuthBlock;
+import at.gv.egovernment.moa.id.commons.db.dao.config.VerifyIdentityLink;
+import at.gv.egovernment.moa.id.config.ConfigurationException;
+import at.gv.egovernment.moa.id.config.auth.NewAuthConfigurationProvider;
+import at.gv.egovernment.moa.id.config.auth.data.ProtocolAllowed;
+
+import com.datentechnik.moa.id.conf.persistence.Configuration;
+
+public class AuthConfigurationProviderLegacyCompatibilityTest {
+
+ private MOAIDConfiguration getMinimalMoaidConfiguration() {
+
+ MOAIDConfiguration moaidConfiguration = new MOAIDConfiguration();
+ AuthComponentGeneral authComponentGeneral = new AuthComponentGeneral();
+ MOASP moasp = new MOASP();
+ VerifyAuthBlock verifyAuthBlock = new VerifyAuthBlock();
+ moasp.setVerifyAuthBlock(verifyAuthBlock);
+ VerifyIdentityLink verifyIdentityLink = new VerifyIdentityLink();
+ moasp.setVerifyIdentityLink(verifyIdentityLink);
+ authComponentGeneral.setMOASP(moasp);
+ SecurityLayer securityLayer = new SecurityLayer();
+ TransformsInfoType transformsInfo = new TransformsInfoType();
+ transformsInfo.setFilename("transforms/TransformsInfoAuthBlockTable_DE.xml");
+ transformsInfo.setTransformation(new byte[] {});
+ securityLayer.setTransformsInfo(Collections.singletonList(transformsInfo));
+ authComponentGeneral.setSecurityLayer(securityLayer);
+ SLRequestTemplates slRequestTemplates = new SLRequestTemplates();
+ moaidConfiguration.setSLRequestTemplates(slRequestTemplates);
+ GeneralConfiguration generalConfiguration = new GeneralConfiguration();
+ generalConfiguration.setTrustManagerRevocationChecking(Boolean.FALSE);
+ generalConfiguration.setPublicURLPreFix("http://test.org");
+ authComponentGeneral.setGeneralConfiguration(generalConfiguration);
+ moaidConfiguration.setAuthComponentGeneral(authComponentGeneral);
+ ChainingModes chainingModes = new ChainingModes();
+ moaidConfiguration.setChainingModes(chainingModes);
+
+ return moaidConfiguration;
+ }
+
+ @Test
+ public void testGetAllowedProtocolls() throws ConfigurationException {
+ MOAIDConfiguration moaidConfiguration = getMinimalMoaidConfiguration();
+
+ testGetAllowedProtocolls(moaidConfiguration);
+ }
+
+ @Test
+ public void testGetAllowedProtocollsAll() throws ConfigurationException {
+ MOAIDConfiguration moaidConfiguration = getMinimalMoaidConfiguration();
+ Protocols protocols = new Protocols();
+ SAML1 saml1 = new SAML1();
+ saml1.setIsActive(Boolean.TRUE);
+ protocols.setSAML1(saml1);
+ PVP2 pvp2 = new PVP2();
+ pvp2.setIsActive(Boolean.FALSE);
+ protocols.setPVP2(pvp2);
+ OAuth oAuth = new OAuth();
+ oAuth.setIsActive(null);
+ protocols.setOAuth(oAuth);
+ moaidConfiguration.getAuthComponentGeneral().setProtocols(protocols);
+
+ testGetAllowedProtocolls(moaidConfiguration);
+ }
+
+ public void testGetAllowedProtocolls(MOAIDConfiguration moaidConfiguration) throws ConfigurationException {
+
+ TestLegacyAuthConfigurationProvider legacyAuthConfigurationProvider = new TestLegacyAuthConfigurationProvider(moaidConfiguration);
+ ProtocolAllowed expectedAllowedProtocols = legacyAuthConfigurationProvider.getAllowedProtocols();
+
+ Configuration configuration = createMock(Configuration.class);
+ NewAuthConfigurationProvider newAuthConfigurationProvider = new NewAuthConfigurationProvider();
+ newAuthConfigurationProvider.setConfiguration(configuration);
+
+ expect(configuration.get(MOAIDConfigurationConstants.AUTH_COMPONENT_GENERAL_KEY, AuthComponentGeneral.class)).andReturn(moaidConfiguration.getAuthComponentGeneral());
+
+ replay(configuration);
+
+ ProtocolAllowed actualAllowedProtocols = newAuthConfigurationProvider.getAllowedProtocols();
+
+ verify(configuration);
+
+ ReflectionAssert.assertLenientEquals(expectedAllowedProtocols, actualAllowedProtocols);
+ }
+
+}
diff --git a/id/server/idserverlib/src/test/java/at/gv/egovnerment/moa/id/config/auth/TestLegacyAuthConfigurationProvider.java b/id/server/idserverlib/src/test/java/at/gv/egovnerment/moa/id/config/auth/TestLegacyAuthConfigurationProvider.java
new file mode 100644
index 000000000..39c8ef310
--- /dev/null
+++ b/id/server/idserverlib/src/test/java/at/gv/egovnerment/moa/id/config/auth/TestLegacyAuthConfigurationProvider.java
@@ -0,0 +1,31 @@
+package at.gv.egovnerment.moa.id.config.auth;
+
+import at.gv.egovernment.moa.id.commons.db.dao.config.MOAIDConfiguration;
+import at.gv.egovernment.moa.id.config.ConfigurationException;
+import at.gv.egovernment.moa.id.config.auth.AuthConfigurationProvider;
+
+public class TestLegacyAuthConfigurationProvider extends
+ AuthConfigurationProvider {
+
+ private final MOAIDConfiguration moaidConfiguration;
+
+ public TestLegacyAuthConfigurationProvider(MOAIDConfiguration moaidConfiguration)
+ throws ConfigurationException {
+ super();
+ this.moaidConfiguration = moaidConfiguration;
+ reloadDataBaseConfig();
+ }
+
+ @SuppressWarnings("unused")
+ private TestLegacyAuthConfigurationProvider(String fileName)
+ throws ConfigurationException {
+ super();
+ moaidConfiguration = new MOAIDConfiguration();
+ }
+
+ @Override
+ protected MOAIDConfiguration loadDataBaseConfig() {
+ return this.moaidConfiguration;
+ }
+
+}
diff --git a/id/server/idserverlib/src/test/resources/log4j.xml b/id/server/idserverlib/src/test/resources/log4j.xml
new file mode 100644
index 000000000..6685c1e82
--- /dev/null
+++ b/id/server/idserverlib/src/test/resources/log4j.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+ <appender name="consoleAppender" class="org.apache.log4j.ConsoleAppender">
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d{dd MMM yyyy HH:mm:ss} %5p %c{1} - %m%n" />
+ </layout>
+ </appender>
+
+ <root>
+ <priority value="info" />
+ <appender-ref ref="consoleAppender" />
+ </root>
+
+</log4j:configuration>