diff --git a/voms-admin-server/src/main/java/org/glite/security/voms/admin/integration/cern/HrDbProperties.java b/voms-admin-server/src/main/java/org/glite/security/voms/admin/integration/cern/HrDbProperties.java index 91cdc645..0ca06762 100644 --- a/voms-admin-server/src/main/java/org/glite/security/voms/admin/integration/cern/HrDbProperties.java +++ b/voms-admin-server/src/main/java/org/glite/security/voms/admin/integration/cern/HrDbProperties.java @@ -187,7 +187,8 @@ public static final HrDbProperties fromProperties(Properties properties) { } if (properties.containsKey(MEMBERSHIP_CHECK_ENABLED_KEY)) { - config.getMembershipCheck().setEnabled(Boolean.parseBoolean(MEMBERSHIP_CHECK_ENABLED_KEY)); + config.getMembershipCheck() + .setEnabled(Boolean.parseBoolean(properties.getProperty(MEMBERSHIP_CHECK_ENABLED_KEY))); } config.getApi().setEndpoint(properties.getProperty(API_ENDPOINT_KEY)); diff --git a/voms-admin-server/src/test/java/integration/hr/HrDbConfiguratorTests.java b/voms-admin-server/src/test/java/integration/hr/HrDbConfiguratorTests.java index b4eccbe6..59543dc5 100644 --- a/voms-admin-server/src/test/java/integration/hr/HrDbConfiguratorTests.java +++ b/voms-admin-server/src/test/java/integration/hr/HrDbConfiguratorTests.java @@ -99,19 +99,37 @@ public void setup() { configurator.setUserDao(dao); configurator.setClock(CLOCK); - when(vomsConfig.getConfigurationDirectoryPath()).thenReturn("src/test/resources/cern/config"); - when(vomsConfig.getExternalValidatorProperty(eq("orgdb"), anyString(), anyString())) - .thenReturn("src/test/resources/cern/config/orgdb.properties"); + when(vomsConfig.getConfigurationDirectoryPath()) + .thenReturn("src/test/resources/cern/disabled-task"); + when(vomsConfig.getExternalValidatorProperty(eq("orgdb"), eq("configFile"), anyString())) + .thenReturn("src/test/resources/cern/disabled-task/hr.properties"); when(apiFactory.newHrDbApiService(any())).thenReturn(api); when(validatorFactory.newHrDbRequestValidator(any(), any())).thenReturn(validator); when(syncTaskFactory.buildSyncTask(any(), any(), any(), any())).thenReturn(syncTask); } @Test - public void testConfigurationFileIsFoundAndParsed() throws VOMSPluginConfigurationException { + public void testDisabledConfigurationFileIsFoundAndParsed() + throws VOMSPluginConfigurationException { + configurator.configure(); + verifyZeroInteractions(executorService);// no interactions as periodic sync is disabled + verifyZeroInteractions(syncTaskFactory);// no interactions as periodic sync is disabled + verify(manager).setRequestValidationContext(Mockito.eq(validator)); + } + + @Test + public void testEnabledConfigurationFileIsFoundAndParsed() + throws VOMSPluginConfigurationException { + when(vomsConfig.getConfigurationDirectoryPath()) + .thenReturn("src/test/resources/cern/enabled-task"); + when(vomsConfig.getExternalValidatorProperty(eq("orgdb"), eq("configFile"), anyString())) + .thenReturn("src/test/resources/cern/enabled-task/hr.properties"); configurator.configure(); - verifyZeroInteractions(executorService); - verifyZeroInteractions(syncTaskFactory); + + verify(executorService).scheduleAtFixedRate(isA(DatabaseTransactionTaskWrapper.class), + Mockito.anyLong(), Mockito.eq(TimeUnit.HOURS.toSeconds(12)), + Mockito.eq(TimeUnit.SECONDS)); + verify(manager).setRequestValidationContext(Mockito.eq(validator)); } diff --git a/voms-admin-server/src/test/java/integration/hr/HrDbPropertiesTest.java b/voms-admin-server/src/test/java/integration/hr/HrDbPropertiesTest.java index 53fca7f3..3ce72f94 100644 --- a/voms-admin-server/src/test/java/integration/hr/HrDbPropertiesTest.java +++ b/voms-admin-server/src/test/java/integration/hr/HrDbPropertiesTest.java @@ -71,6 +71,12 @@ public void testValueParsing() { assertThat(hrConfig.getMembershipCheck().getPeriodInSeconds(), is(86400L)); } + + @Test + public void testFileParsing() { + + } + @Test public void testApiTimeoutChecks() { Properties props = new Properties(); diff --git a/voms-admin-server/src/test/resources/cern/config/orgdb.properties b/voms-admin-server/src/test/resources/cern/disabled-task/hr.properties similarity index 100% rename from voms-admin-server/src/test/resources/cern/config/orgdb.properties rename to voms-admin-server/src/test/resources/cern/disabled-task/hr.properties diff --git a/voms-admin-server/src/test/resources/cern/enabled-task/hr.properties b/voms-admin-server/src/test/resources/cern/enabled-task/hr.properties new file mode 100644 index 00000000..6556749f --- /dev/null +++ b/voms-admin-server/src/test/resources/cern/enabled-task/hr.properties @@ -0,0 +1,8 @@ + experiment=cms + membership_check.enabled=true + membership_check.start_hour=4 + membership_check.run_at_startup=false + api.endpoint=http://localhost:8080 + api.username=user + api.password=password + api.timeout_secs=2 \ No newline at end of file