use of net.nemerosa.ontrack.extension.api.support.TestConfiguration in project ontrack by nemerosa.
the class ConfigurationServiceTest method replace_configuration_different_not_authorised.
@Test(expected = ConfigurationNotFoundException.class)
public void replace_configuration_different_not_authorised() {
TestConfiguration config = config("test");
when(securityService.isGlobalFunctionGranted(GlobalSettings.class)).thenReturn(false);
configurationService.replaceConfiguration(config, s -> s.replaceAll("test", "new"));
}
use of net.nemerosa.ontrack.extension.api.support.TestConfiguration in project ontrack by nemerosa.
the class ConfigurationServiceTest method event_on_update_configuration.
@Test
public void event_on_update_configuration() {
TestConfiguration config = config("test");
Event event = Event.of(EventFactory.UPDATE_CONFIGURATION).with("configuration", "test").get();
when(eventFactory.updateConfiguration(config)).thenReturn(event);
when(configurationRepository.find(TestConfiguration.class, "test")).thenReturn(Optional.of(config));
configurationService.updateConfiguration("test", config);
verify(eventPostService).post(event);
}
use of net.nemerosa.ontrack.extension.api.support.TestConfiguration in project ontrack by nemerosa.
the class ConfigurationServiceIT method validate_ok_on_updated_configuration_with_old_password.
@Test
public void validate_ok_on_updated_configuration_with_old_password() throws Exception {
// Creates a configuration
String name = uid("T");
TestConfiguration configuration = new TestConfiguration(name, "check", "test");
asUser().with(GlobalSettings.class).call(() -> configurationService.newConfiguration(configuration));
// Updates the configuration and fills the password
TestConfiguration updatedConfiguration = new TestConfiguration(name, "check", "test");
asUser().with(GlobalSettings.class).call(() -> {
configurationService.updateConfiguration(name, updatedConfiguration);
return null;
});
}
use of net.nemerosa.ontrack.extension.api.support.TestConfiguration in project ontrack by nemerosa.
the class ConfigurationServiceTest method replace_configuration_different_authorised.
@Test
public void replace_configuration_different_authorised() {
TestConfiguration config = config("test");
when(securityService.isGlobalFunctionGranted(GlobalSettings.class)).thenReturn(true);
TestConfiguration replacedConfig = configurationService.replaceConfiguration(config, s -> s.replaceAll("test", "new"));
assertEquals(config("new").withPassword(""), replacedConfig);
}
use of net.nemerosa.ontrack.extension.api.support.TestConfiguration in project ontrack by nemerosa.
the class ConfigurationServiceTest method event_on_new_configuration.
@Test
public void event_on_new_configuration() {
TestConfiguration config = config("test");
Event event = Event.of(EventFactory.NEW_CONFIGURATION).with("configuration", "test").get();
when(eventFactory.newConfiguration(config)).thenReturn(event);
configurationService.newConfiguration(config);
verify(eventPostService).post(event);
}
Aggregations