Search in sources :

Example 1 with NoPluginsInstalled

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;
}
Also used : ConfigElementImplementationRegistry(com.thoughtworks.go.config.registry.ConfigElementImplementationRegistry) ConfigElementImplementationRegistrar(com.thoughtworks.go.config.registry.ConfigElementImplementationRegistrar) NoPluginsInstalled(com.thoughtworks.go.config.registry.NoPluginsInstalled)

Example 2 with NoPluginsInstalled

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"));
}
Also used : ConfigElementImplementationRegistry(com.thoughtworks.go.config.registry.ConfigElementImplementationRegistry) NoPluginsInstalled(com.thoughtworks.go.config.registry.NoPluginsInstalled) Test(org.junit.jupiter.api.Test)

Example 3 with NoPluginsInstalled

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()));
}
Also used : ConfigElementImplementationRegistry(com.thoughtworks.go.config.registry.ConfigElementImplementationRegistry) FullConfigUpdateCommand(com.thoughtworks.go.config.update.FullConfigUpdateCommand) ConfigElementImplementationRegistrar(com.thoughtworks.go.config.registry.ConfigElementImplementationRegistrar) NoPluginsInstalled(com.thoughtworks.go.config.registry.NoPluginsInstalled)

Example 4 with NoPluginsInstalled

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);
}
Also used : TimeProvider(com.thoughtworks.go.util.TimeProvider) Date(java.util.Date) DateTime(org.joda.time.DateTime) ClassPathResource(org.springframework.core.io.ClassPathResource) ConfigElementImplementationRegistry(com.thoughtworks.go.config.registry.ConfigElementImplementationRegistry) ConfigElementImplementationRegistrar(com.thoughtworks.go.config.registry.ConfigElementImplementationRegistrar) NoPluginsInstalled(com.thoughtworks.go.config.registry.NoPluginsInstalled) SimpleDateFormat(java.text.SimpleDateFormat) File(java.io.File) Before(org.junit.Before)

Example 5 with NoPluginsInstalled

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));
}
Also used : ServerVersion(com.thoughtworks.go.server.util.ServerVersion) User(org.springframework.security.userdetails.User) ConfigRepository(com.thoughtworks.go.service.ConfigRepository) UsernamePasswordAuthenticationToken(org.springframework.security.providers.UsernamePasswordAuthenticationToken) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) ServerHealthService(com.thoughtworks.go.serverhealth.ServerHealthService) NoPluginsInstalled(com.thoughtworks.go.config.registry.NoPluginsInstalled) ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) ConfigFileHasChangedException(com.thoughtworks.go.config.exceptions.ConfigFileHasChangedException) GitAPIException(org.eclipse.jgit.api.errors.GitAPIException) GoConfigInvalidException(com.thoughtworks.go.config.exceptions.GoConfigInvalidException) ExpectedException(org.junit.rules.ExpectedException) ConfigMergeException(com.thoughtworks.go.config.exceptions.ConfigMergeException) IOException(java.io.IOException) GoConfigService(com.thoughtworks.go.server.service.GoConfigService) ConfigElementImplementationRegistry(com.thoughtworks.go.config.registry.ConfigElementImplementationRegistry) SecurityContext(org.springframework.security.context.SecurityContext) ConfigRepoExtension(com.thoughtworks.go.plugin.access.configrepo.ConfigRepoExtension) Before(org.junit.Before)

Aggregations

ConfigElementImplementationRegistry (com.thoughtworks.go.config.registry.ConfigElementImplementationRegistry)6 NoPluginsInstalled (com.thoughtworks.go.config.registry.NoPluginsInstalled)6 ConfigElementImplementationRegistrar (com.thoughtworks.go.config.registry.ConfigElementImplementationRegistrar)4 TimeProvider (com.thoughtworks.go.util.TimeProvider)2 File (java.io.File)2 SimpleDateFormat (java.text.SimpleDateFormat)2 Date (java.util.Date)2 DateTime (org.joda.time.DateTime)2 Before (org.junit.Before)2 ClassPathResource (org.springframework.core.io.ClassPathResource)2 ConfigFileHasChangedException (com.thoughtworks.go.config.exceptions.ConfigFileHasChangedException)1 ConfigMergeException (com.thoughtworks.go.config.exceptions.ConfigMergeException)1 GoConfigInvalidException (com.thoughtworks.go.config.exceptions.GoConfigInvalidException)1 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)1 ConfigRepoConfig (com.thoughtworks.go.config.remote.ConfigRepoConfig)1 FullConfigUpdateCommand (com.thoughtworks.go.config.update.FullConfigUpdateCommand)1 ConfigRepoExtension (com.thoughtworks.go.plugin.access.configrepo.ConfigRepoExtension)1 GoConfigService (com.thoughtworks.go.server.service.GoConfigService)1 ServerVersion (com.thoughtworks.go.server.util.ServerVersion)1 ServerHealthService (com.thoughtworks.go.serverhealth.ServerHealthService)1