Search in sources :

Example 11 with TestConfiguration

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"));
}
Also used : TestConfiguration(net.nemerosa.ontrack.extension.api.support.TestConfiguration) Test(org.junit.Test)

Example 12 with TestConfiguration

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);
}
Also used : TestConfiguration(net.nemerosa.ontrack.extension.api.support.TestConfiguration) Event(net.nemerosa.ontrack.model.events.Event) Test(org.junit.Test)

Example 13 with TestConfiguration

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;
    });
}
Also used : TestConfiguration(net.nemerosa.ontrack.extension.api.support.TestConfiguration) GlobalSettings(net.nemerosa.ontrack.model.security.GlobalSettings) Test(org.junit.Test)

Example 14 with TestConfiguration

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);
}
Also used : TestConfiguration(net.nemerosa.ontrack.extension.api.support.TestConfiguration) Test(org.junit.Test)

Example 15 with TestConfiguration

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);
}
Also used : TestConfiguration(net.nemerosa.ontrack.extension.api.support.TestConfiguration) Event(net.nemerosa.ontrack.model.events.Event) Test(org.junit.Test)

Aggregations

TestConfiguration (net.nemerosa.ontrack.extension.api.support.TestConfiguration)17 Test (org.junit.Test)16 GlobalSettings (net.nemerosa.ontrack.model.security.GlobalSettings)10 Event (net.nemerosa.ontrack.model.events.Event)3 PreparedStatement (java.sql.PreparedStatement)1 TestPropertyType (net.nemerosa.ontrack.extension.api.support.TestPropertyType)1 ProjectEdit (net.nemerosa.ontrack.model.security.ProjectEdit)1 ProjectView (net.nemerosa.ontrack.model.security.ProjectView)1 Project (net.nemerosa.ontrack.model.structure.Project)1 ConnectionResult (net.nemerosa.ontrack.model.support.ConnectionResult)1