Search in sources :

Example 1 with JenkinsConfiguration

use of net.nemerosa.ontrack.extension.jenkins.JenkinsConfiguration in project ontrack by nemerosa.

the class JenkinsServiceTest method update_blank_password.

@Test
public void update_blank_password() {
    when(encryptionService.encrypt("secret")).thenReturn("xxxxx");
    when(encryptionService.decrypt("xxxxx")).thenReturn("secret");
    when(configurationRepository.find(JenkinsConfiguration.class, "test")).thenReturn(Optional.of(new JenkinsConfiguration("test", "http://host", "user", "xxxxx")));
    jenkinsService.updateConfiguration("test", new JenkinsConfiguration("test", "http://host", "user", ""));
    verify(configurationRepository, times(1)).save(new JenkinsConfiguration("test", "http://host", "user", "xxxxx"));
}
Also used : JenkinsConfiguration(net.nemerosa.ontrack.extension.jenkins.JenkinsConfiguration) Test(org.junit.Test)

Example 2 with JenkinsConfiguration

use of net.nemerosa.ontrack.extension.jenkins.JenkinsConfiguration in project ontrack by nemerosa.

the class JenkinsConfigurationTest method obfuscate.

@Test
public void obfuscate() {
    JenkinsConfiguration config = new JenkinsConfiguration("Test", "http://host", "user", "secret");
    assertEquals("secret", config.getPassword());
    config = config.obfuscate();
    assertEquals("", config.getPassword());
}
Also used : JenkinsConfiguration(net.nemerosa.ontrack.extension.jenkins.JenkinsConfiguration) Test(org.junit.Test)

Example 3 with JenkinsConfiguration

use of net.nemerosa.ontrack.extension.jenkins.JenkinsConfiguration in project ontrack by nemerosa.

the class JenkinsServiceTest method update_new_password.

@Test
public void update_new_password() {
    when(encryptionService.encrypt("pwd")).thenReturn("xxxxx");
    when(configurationRepository.find(JenkinsConfiguration.class, "test")).thenReturn(Optional.of(new JenkinsConfiguration("test", "http://host", "user", "xxxxx")));
    jenkinsService.updateConfiguration("test", new JenkinsConfiguration("test", "http://host", "user", "pwd"));
    verify(configurationRepository, times(1)).save(new JenkinsConfiguration("test", "http://host", "user", "xxxxx"));
}
Also used : JenkinsConfiguration(net.nemerosa.ontrack.extension.jenkins.JenkinsConfiguration) Test(org.junit.Test)

Example 4 with JenkinsConfiguration

use of net.nemerosa.ontrack.extension.jenkins.JenkinsConfiguration in project ontrack by nemerosa.

the class JenkinsServiceTest method update_blank_password_for_different_user.

@Test
public void update_blank_password_for_different_user() {
    when(encryptionService.encrypt("")).thenReturn("xxxxx");
    when(configurationRepository.find(JenkinsConfiguration.class, "test")).thenReturn(Optional.of(new JenkinsConfiguration("test", "http://host", "user", "xxxxx")));
    jenkinsService.updateConfiguration("test", new JenkinsConfiguration("test", "http://host", "user1", ""));
    verify(configurationRepository, times(1)).save(new JenkinsConfiguration("test", "http://host", "user1", "xxxxx"));
}
Also used : JenkinsConfiguration(net.nemerosa.ontrack.extension.jenkins.JenkinsConfiguration) Test(org.junit.Test)

Aggregations

JenkinsConfiguration (net.nemerosa.ontrack.extension.jenkins.JenkinsConfiguration)4 Test (org.junit.Test)4