From d24179f90949ff6768f89eea0073f65990d0765a Mon Sep 17 00:00:00 2001 From: Martin Bonato Date: Wed, 21 Jan 2015 16:55:53 +0100 Subject: Add unit initial unit tests. --- .../moa/id/config/auth/AuthConfigurationProvider.java | 15 ++++++++++++--- .../moa/id/config/auth/NewAuthConfigurationProvider.java | 13 +++++++++---- 2 files changed, 21 insertions(+), 7 deletions(-) (limited to 'id/server/idserverlib/src/main/java') diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/auth/AuthConfigurationProvider.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/auth/AuthConfigurationProvider.java index a143eb636..087b331b5 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/auth/AuthConfigurationProvider.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/auth/AuthConfigurationProvider.java @@ -273,6 +273,12 @@ public class AuthConfigurationProvider extends ConfigurationProvider implements load(fileName); } + /** + * Protected constructor. Used by unit tests. + */ + protected AuthConfigurationProvider() { + } + /** * Load the configuration data from XML file with the given name and build * the internal data structures representing the MOA ID configuration. @@ -493,12 +499,15 @@ public class AuthConfigurationProvider extends ConfigurationProvider implements throw new ConfigurationException("config.02", null, t); } } - + + protected MOAIDConfiguration loadDataBaseConfig() { + return ConfigurationDBRead.getMOAIDConfiguration(); + } + public synchronized void reloadDataBaseConfig() throws ConfigurationException { Logger.info("Read MOA-ID 2.0 configuration from database."); - //moaidconfig = ConfigurationDBRead.getMOAIDConfiguration(); - moaidconfig = NewConfigurationDBRead.getMOAIDConfiguration(); + moaidconfig = loadDataBaseConfig(); Logger.info("MOA-ID 2.0 is loaded."); if (moaidconfig == null) { diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/auth/NewAuthConfigurationProvider.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/auth/NewAuthConfigurationProvider.java index 77a9f032c..0ee143a1a 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/auth/NewAuthConfigurationProvider.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/auth/NewAuthConfigurationProvider.java @@ -54,10 +54,12 @@ import com.datentechnik.moa.id.conf.persistence.Configuration; */ public class NewAuthConfigurationProvider extends ConfigurationProvider implements AuthConfiguration { - @Autowired private Configuration configuration; private final Properties properties = new Properties(); + + public NewAuthConfigurationProvider() { + } public NewAuthConfigurationProvider(String fileName) throws ConfigurationException { File propertiesFile = new File(fileName); @@ -71,6 +73,11 @@ public class NewAuthConfigurationProvider extends ConfigurationProvider implemen throw new ConfigurationException("config.03", null, e); } } + + @Autowired + public void setConfiguration(Configuration configuration) { + this.configuration = configuration; + } private Properties getProperties() { return properties; @@ -105,11 +112,9 @@ public class NewAuthConfigurationProvider extends ConfigurationProvider implemen } catch (ConfigurationException e) { return null; } - ProtocolAllowed allowedProtcols = new ProtocolAllowed(); Protocols protocols = authComponentGeneral.getProtocols(); if (protocols != null) { - allowedProtcols = new ProtocolAllowed(); - + ProtocolAllowed allowedProtcols = new ProtocolAllowed(); if (protocols.getSAML1() != null) { allowedProtcols.setSAML1Active(protocols.getSAML1().isIsActive()); } -- cgit v1.2.3