use of com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration in project gocd by gocd.
the class PackageConfigurationTest method shouldSortPackageConfigurationByDisplayOrder.
@Test
public void shouldSortPackageConfigurationByDisplayOrder() throws Exception {
PackageConfiguration p1 = new PackageConfiguration("k1").with(PackageConfiguration.DISPLAY_ORDER, 1);
PackageConfiguration p2 = new PackageConfiguration("k2").with(PackageConfiguration.DISPLAY_ORDER, 3);
assertThat(p2.compareTo(p1), Is.is(2));
}
use of com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration in project gocd by gocd.
the class PackageDefinitionServiceTest method setUp.
@Before
public void setUp() throws Exception {
initMocks(this);
when(localizer.localize(eq("MANDATORY_CONFIGURATION_FIELD_WITH_NAME"), anyString())).thenReturn("mandatory field");
service = new PackageDefinitionService(packageRepositoryExtension, localizer, entityHashingService, goConfigService);
PackageConfigurations configurations = new PackageConfigurations();
configurations.add(new PackageConfiguration("required").with(PackageConfiguration.REQUIRED, true));
configurations.add(new PackageConfiguration("required_secure").with(PackageConfiguration.REQUIRED, true).with(PackageConfiguration.SECURE, true));
configurations.add(new PackageConfiguration("secure").with(PackageConfiguration.SECURE, true).with(PackageConfiguration.REQUIRED, false));
configurations.add(new PackageConfiguration("not_required_not_secure").with(PackageConfiguration.REQUIRED, false));
configurations.add(new PackageConfiguration("spec"));
String pluginId = "yum";
PackageMetadataStore.getInstance().addMetadataFor(pluginId, configurations);
packageRepository = PackageRepositoryMother.create("1", "repo", pluginId, "1", new Configuration());
}
use of com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration in project gocd by gocd.
the class PackageRepositoryServiceTest method shouldPerformPluginValidationsUsingMetaDataBeforeSavingPackageRepository.
@Test
public void shouldPerformPluginValidationsUsingMetaDataBeforeSavingPackageRepository() throws Exception {
//metadata setup
String pluginId = "yum";
PackageConfigurations repositoryConfiguration = new PackageConfigurations();
repositoryConfiguration.add(new PackageConfiguration("required").with(PackageConfiguration.REQUIRED, true));
repositoryConfiguration.add(new PackageConfiguration("required_secure").with(PackageConfiguration.REQUIRED, true).with(PackageConfiguration.SECURE, true));
repositoryConfiguration.add(new PackageConfiguration("secure").with(PackageConfiguration.SECURE, true).with(PackageConfiguration.REQUIRED, false));
repositoryConfiguration.add(new PackageConfiguration("not_required_not_secure"));
RepositoryMetadataStore.getInstance().addMetadataFor(pluginId, repositoryConfiguration);
PackageRepository packageRepository = new PackageRepository();
packageRepository.setPluginConfiguration(new PluginConfiguration(pluginId, "1.0"));
packageRepository.getConfiguration().add(ConfigurationPropertyMother.create("required", false, ""));
packageRepository.getConfiguration().add(ConfigurationPropertyMother.create("required_secure", true, ""));
packageRepository.getConfiguration().add(ConfigurationPropertyMother.create("secure", true, ""));
packageRepository.getConfiguration().add(ConfigurationPropertyMother.create("not_required_not_secure", false, ""));
when(packageRepositoryExtension.isRepositoryConfigurationValid(eq(pluginId), any(RepositoryConfiguration.class))).thenReturn(new ValidationResult());
when(pluginManager.getPluginDescriptorFor(pluginId)).thenReturn(new GoPluginDescriptor(pluginId, "1.0", null, null, null, true));
when(localizer.localize("MANDATORY_CONFIGURATION_FIELD")).thenReturn("mandatory field");
service.performPluginValidationsFor(packageRepository);
assertThat(packageRepository.getConfiguration().get(0).getConfigurationValue().errors().getAllOn("value"), is(Arrays.asList("mandatory field")));
assertThat(packageRepository.getConfiguration().get(1).getEncryptedConfigurationValue().errors().getAllOn("value"), is(Arrays.asList("mandatory field")));
}
use of com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration in project gocd by gocd.
the class PackageViewModelBuilderTest method setUp.
@Before
public void setUp() {
initMocks(this);
builder = new PackageViewModelBuilder(manager);
yumPoller = new GoPluginDescriptor("yum.poller", "version1", new GoPluginDescriptor.About("Yum Poller", "1.0", null, null, null, null), null, null, false);
npmPoller = new GoPluginDescriptor("npm.poller", "version1", new GoPluginDescriptor.About("NPM Poller", "2.0", null, null, null, null), null, null, false);
PackageConfigurations packageConfigurations = new PackageConfigurations();
packageConfigurations.add(new PackageConfiguration("key1"));
packageConfigurations.add(new PackageConfiguration("key2"));
PackageConfigurations repositoryConfigurations = new PackageConfigurations();
repositoryConfigurations.add(new PackageConfiguration("key1"));
PackageMetadataStore.getInstance().addMetadataFor(yumPoller.id(), packageConfigurations);
PackageMetadataStore.getInstance().addMetadataFor(npmPoller.id(), new PackageConfigurations());
RepositoryMetadataStore.getInstance().addMetadataFor(yumPoller.id(), repositoryConfigurations);
}
use of com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration in project gocd by gocd.
the class PackageDefinition method getSecureKeyInfoProvider.
private SecureKeyInfoProvider getSecureKeyInfoProvider() {
PackageMetadataStore packageMetadataStore = PackageMetadataStore.getInstance();
final PackageConfigurations metadata = packageMetadataStore.getMetadata(pluginId());
if (metadata == null) {
return null;
}
return new SecureKeyInfoProvider() {
@Override
public boolean isSecure(String key) {
PackageConfiguration packageConfiguration = metadata.get(key);
return packageConfiguration.getOption(PackageConfiguration.SECURE);
}
};
}
Aggregations