use of com.thoughtworks.go.server.domain.PluginSettings in project gocd by gocd.
the class PluginServiceTest method shouldGetSettingsFromConfigurationIfItDoesNotExistInDB.
@Test
public void shouldGetSettingsFromConfigurationIfItDoesNotExistInDB() {
PluginSettings pluginSettings = pluginService.getPluginSettingsFor("plugin-id-2");
assertThat(pluginSettings.getPluginSettingsKeys().size(), is(3));
assertThat(pluginSettings.getValueFor("p2-k1"), is(""));
assertThat(pluginSettings.getValueFor("p2-k2"), is(""));
assertThat(pluginSettings.getValueFor("p2-k3"), is(""));
}
use of com.thoughtworks.go.server.domain.PluginSettings in project gocd by gocd.
the class PluginServiceTest method shouldPopulateSettingsMapFromKeyValueMap.
@Test
public void shouldPopulateSettingsMapFromKeyValueMap() {
Map<String, String> parameterMap = new HashMap<>();
parameterMap.put("p3-k1", "v1");
parameterMap.put("p3-k2", "");
parameterMap.put("p3-k3", null);
PluginSettings pluginSettings = pluginService.getPluginSettingsFor("plugin-id-3", parameterMap);
assertThat(pluginSettings.getPluginSettingsKeys().size(), is(3));
assertThat(pluginSettings.getValueFor("p3-k1"), is("v1"));
assertThat(pluginSettings.getValueFor("p3-k2"), is(""));
assertThat(pluginSettings.getValueFor("p3-k3"), is(nullValue()));
}
use of com.thoughtworks.go.server.domain.PluginSettings in project gocd by gocd.
the class PluginServiceTest method shouldReturnPluginSettingsFromDbIfItExists.
@Test
public void shouldReturnPluginSettingsFromDbIfItExists() {
PluginSettings pluginSettings = pluginService.loadStoredPluginSettings("plugin-id-1");
assertThat(pluginSettings.getPluginSettingsKeys().size(), is(3));
assertThat(pluginSettings.getValueFor("p1-k1"), is("v1"));
assertThat(pluginSettings.getValueFor("p1-k2"), is(""));
assertThat(pluginSettings.getValueFor("p1-k3"), is(nullValue()));
}
use of com.thoughtworks.go.server.domain.PluginSettings in project gocd by gocd.
the class PluginServiceTest method shouldNotSavePluginSettingsIfUserIsNotAnAdmin.
@Test
public void shouldNotSavePluginSettingsIfUserIsNotAnAdmin() {
PluginSettings pluginSettings = new PluginSettings("some-plugin");
Username currentUser = new Username("non-admin");
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
when(securityService.isUserAdmin(currentUser)).thenReturn(false);
pluginService.savePluginSettings(currentUser, result, pluginSettings);
assertThat(result.httpCode(), is(401));
assertThat(result.toString(), containsString("UNAUTHORIZED_TO_EDIT"));
}
use of com.thoughtworks.go.server.domain.PluginSettings in project gocd by gocd.
the class PluginServiceTest method shouldNotifyTheExtensionWhichHandlesSettingsInAPluginWithMultipleExtensions_WhenPluginSettingsHaveChanged.
@Test
public void shouldNotifyTheExtensionWhichHandlesSettingsInAPluginWithMultipleExtensions_WhenPluginSettingsHaveChanged() {
String pluginId = "plugin-id-2";
Map<String, String> parameterMap = m("p2-k1", "v1");
PluginSettings pluginSettings = new PluginSettings(pluginId).populateSettingsMap(parameterMap);
Username currentUser = new Username("admin");
when(securityService.isUserAdmin(currentUser)).thenReturn(true);
when(configRepoExtension.canHandlePlugin(pluginId)).thenReturn(true);
when(configRepoExtension.validatePluginSettings(eq(pluginId), any(PluginSettingsConfiguration.class))).thenReturn(new ValidationResult());
pluginService.savePluginSettings(currentUser, new HttpLocalizedOperationResult(), pluginSettings);
verify(configRepoExtension).notifyPluginSettingsChange(pluginId, pluginSettings.getSettingsAsKeyValuePair());
verify(scmExtension, never()).canHandlePlugin(pluginId);
verify(scmExtension, never()).notifyPluginSettingsChange(pluginId, pluginSettings.getSettingsAsKeyValuePair());
verify(taskExtension, never()).notifyPluginSettingsChange(pluginId, pluginSettings.getSettingsAsKeyValuePair());
verify(notificationExtension, never()).notifyPluginSettingsChange(pluginId, pluginSettings.getSettingsAsKeyValuePair());
verify(packageRepositoryExtension, never()).notifyPluginSettingsChange(pluginId, pluginSettings.getSettingsAsKeyValuePair());
}
Aggregations