use of com.thoughtworks.go.config.registry.NoPluginsInstalled in project gocd by gocd.
the class ConfigElementImplementationRegistryMother method withNoPlugins.
public static ConfigElementImplementationRegistry withNoPlugins() {
ConfigElementImplementationRegistry registry = new ConfigElementImplementationRegistry(new NoPluginsInstalled());
new ConfigElementImplementationRegistrar(registry).initialize();
return registry;
}
use of com.thoughtworks.go.config.registry.NoPluginsInstalled in project gocd by gocd.
the class ConfigUtilTest method shouldGetAllTasks.
@Test
public void shouldGetAllTasks() {
ConfigElementImplementationRegistry registry = new ConfigElementImplementationRegistry(new NoPluginsInstalled());
registry.registerImplementer(Task.class, AntTask.class, ExecTask.class, NantTask.class, RakeTask.class, FetchTask.class, FetchPluggableArtifactTask.class);
List<String> tasks = ConfigUtil.allTasks(registry);
assertThat(tasks.size(), is(5));
assertThat(tasks, hasItem("ant"));
assertThat(tasks, hasItem("exec"));
assertThat(tasks, hasItem("nant"));
assertThat(tasks, hasItem("rake"));
assertThat(tasks, hasItem("fetchartifact"));
}
use of com.thoughtworks.go.config.registry.NoPluginsInstalled in project gocd by gocd.
the class GoConfigFileHelper method saveFullConfig.
public void saveFullConfig(String configFileContent, boolean shouldMigrate) throws Exception {
if (shouldMigrate) {
configFileContent = ConfigMigrator.migrate(configFileContent);
}
ConfigElementImplementationRegistry registry = new ConfigElementImplementationRegistry(new NoPluginsInstalled());
new ConfigElementImplementationRegistrar(registry).initialize();
MagicalGoConfigXmlLoader magicalGoConfigXmlLoader = new MagicalGoConfigXmlLoader(new ConfigCache(), registry);
CruiseConfig configToBeWritten = magicalGoConfigXmlLoader.deserializeConfig(configFileContent);
cachedGoConfig.writeFullConfigWithLock(new FullConfigUpdateCommand(configToBeWritten, cachedGoConfig.loadForEditing().getMd5()));
}
use of com.thoughtworks.go.config.registry.NoPluginsInstalled in project gocd by gocd.
the class ConfigCipherUpdaterTest method setUp.
@Before
public void setUp() throws Exception {
systemEnvironment.setProperty(SystemEnvironment.CONFIG_DIR_PROPERTY, temporaryFolder.newFolder().getAbsolutePath());
final Date currentTime = new DateTime().toDate();
timestamp = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss").format(currentTime);
updater = new ConfigCipherUpdater(systemEnvironment, new TimeProvider() {
@Override
public Date currentTime() {
return currentTime;
}
});
configCache = new ConfigCache();
registry = new ConfigElementImplementationRegistry(new NoPluginsInstalled());
ConfigElementImplementationRegistrar registrar = new ConfigElementImplementationRegistrar(registry);
registrar.initialize();
magicalGoConfigXmlLoader = new MagicalGoConfigXmlLoader(configCache, registry);
File configFileEncryptedWithFlawedCipher = new ClassPathResource("cruise-config-with-encrypted-with-flawed-cipher.xml").getFile();
FileUtils.writeStringToFile(systemEnvironment.getCipherFile(), ConfigCipherUpdater.FLAWED_VALUE, UTF_8);
ReflectionUtil.setStaticField(CipherProvider.class, "cachedKey", null);
String xml = ConfigMigrator.migrate(FileUtils.readFileToString(configFileEncryptedWithFlawedCipher, UTF_8));
originalConfigFile = new File(systemEnvironment.getCruiseConfigFile());
FileUtils.writeStringToFile(originalConfigFile, xml, UTF_8);
}
use of com.thoughtworks.go.config.registry.NoPluginsInstalled in project gocd by gocd.
the class GoFileConfigDataSourceTest method setup.
@Before
public void setup() throws Exception {
systemEnvironment = new SystemEnvironment();
systemEnvironment.setProperty(SystemEnvironment.OPTIMIZE_FULL_CONFIG_SAVE.propertyName(), "false");
configHelper = new GoConfigFileHelper();
configHelper.onSetUp();
configRepository = new ConfigRepository(systemEnvironment);
configRepository.initialize();
timeProvider = mock(TimeProvider.class);
fullConfigSaveMergeFlow = mock(FullConfigSaveMergeFlow.class);
fullConfigSaveNormalFlow = mock(FullConfigSaveNormalFlow.class);
when(timeProvider.currentTime()).thenReturn(new Date());
ServerVersion serverVersion = new ServerVersion();
ConfigElementImplementationRegistry registry = ConfigElementImplementationRegistryMother.withNoPlugins();
ServerHealthService serverHealthService = new ServerHealthService();
cachedGoPartials = new CachedGoPartials(serverHealthService);
dataSource = new GoFileConfigDataSource(new GoConfigMigration(new GoConfigMigration.UpgradeFailedHandler() {
public void handle(Exception e) {
throw new RuntimeException(e);
}
}, configRepository, new TimeProvider(), configCache, registry), configRepository, systemEnvironment, timeProvider, configCache, serverVersion, registry, mock(ServerHealthService.class), cachedGoPartials, fullConfigSaveMergeFlow, fullConfigSaveNormalFlow);
dataSource.upgradeIfNecessary();
CachedGoConfig cachedGoConfig = new CachedGoConfig(serverHealthService, dataSource, mock(CachedGoPartials.class), null, null);
cachedGoConfig.loadConfigIfNull();
goConfigDao = new GoConfigDao(cachedGoConfig);
configHelper.load();
configHelper.usingCruiseConfigDao(goConfigDao);
GoConfigWatchList configWatchList = new GoConfigWatchList(cachedGoConfig, mock(GoConfigService.class));
ConfigElementImplementationRegistry configElementImplementationRegistry = new ConfigElementImplementationRegistry(new NoPluginsInstalled());
GoConfigPluginService configPluginService = new GoConfigPluginService(mock(ConfigRepoExtension.class), new ConfigCache(), configElementImplementationRegistry, cachedGoConfig);
repoConfig = new ConfigRepoConfig(new GitMaterialConfig("url"), "plugin");
configHelper.addConfigRepo(repoConfig);
SecurityContext context = SecurityContextHolder.getContext();
context.setAuthentication(new UsernamePasswordAuthenticationToken(new User("loser_boozer", "pass", true, true, true, true, new GrantedAuthority[] {}), null));
}
Aggregations