use of com.thoughtworks.go.domain.packagerepository.PackageRepositories in project gocd by gocd.
the class UpdatePackageRepositoryCommand method update.
@Override
public void update(CruiseConfig modifiedConfig) {
PackageRepository oldRepo = modifiedConfig.getPackageRepositories().find(newRepo.getRepoId());
this.newRepo.setPackages(oldRepo.getPackages());
PackageRepositories repositories = modifiedConfig.getPackageRepositories();
repositories.replace(oldRepo, newRepo);
modifiedConfig.setPackageRepositories(repositories);
updatePackageRepositoryConfigurationOnAssociatedPipelines(modifiedConfig);
}
use of com.thoughtworks.go.domain.packagerepository.PackageRepositories in project gocd by gocd.
the class PackageDefinitionServiceIntegrationTest method setup.
@BeforeEach
public void setup() throws Exception {
cachedGoPartials.clear();
configHelper = new GoConfigFileHelper();
dbHelper.onSetUp();
configHelper.usingCruiseConfigDao(goConfigDao);
configHelper.onSetUp();
goConfigService.forceNotifyListeners();
user = new Username(new CaseInsensitiveString("current"));
final PackageRepository npmRepo = new PackageRepository();
PluginConfiguration pluginConfiguration = new PluginConfiguration();
pluginConfiguration.setId("npm");
pluginConfiguration.setVersion("1");
npmRepo.setPluginConfiguration(pluginConfiguration);
repoId = "repoId";
npmRepo.setId(repoId);
npmRepo.setName(repoId);
Configuration configuration = new Configuration();
configuration.add(new ConfigurationProperty(new ConfigurationKey("PACKAGE_ID"), new ConfigurationValue("prettyjson")));
npmRepo.setConfiguration(configuration);
goConfigService.updateConfig(new UpdateConfigCommand() {
@Override
public CruiseConfig update(CruiseConfig cruiseConfig) throws Exception {
cruiseConfig.setPackageRepositories(new PackageRepositories(npmRepo));
return cruiseConfig;
}
});
UpdateConfigCommand command = goConfigService.modifyAdminPrivilegesCommand(asList(user.getUsername().toString()), new TriStateSelection(Admin.GO_SYSTEM_ADMIN, TriStateSelection.Action.add));
goConfigService.updateConfig(command);
}
use of com.thoughtworks.go.domain.packagerepository.PackageRepositories in project gocd by gocd.
the class PackageRepositoryServiceIntegrationTest method shouldReturnTheExactLocalizeMessageIfItFailsToDeletePackageRepository.
@Test
public void shouldReturnTheExactLocalizeMessageIfItFailsToDeletePackageRepository() throws Exception {
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
String repoId = "npm";
PackageRepository npmRepo = new PackageRepository();
npmRepo.setId(repoId);
goConfigService.getConfigForEditing().setPackageRepositories(new PackageRepositories(npmRepo));
HttpLocalizedOperationResult expectedResult = new HttpLocalizedOperationResult();
expectedResult.forbidden(EntityType.PackageRepository.forbiddenToDelete("npm", "UnauthorizedUser"), forbidden());
assertThat(goConfigService.getConfigForEditing().getPackageRepositories().size(), is(1));
assertThat(goConfigService.getConfigForEditing().getPackageRepositories().find(repoId), is(npmRepo));
service.deleteRepository(new Username("UnauthorizedUser"), npmRepo, result);
assertThat(result, is(expectedResult));
assertThat(goConfigService.getConfigForEditing().getPackageRepositories().size(), is(1));
assertThat(goConfigService.getConfigForEditing().getPackageRepositories().find(repoId), is(npmRepo));
}
use of com.thoughtworks.go.domain.packagerepository.PackageRepositories in project gocd by gocd.
the class PackageRepositoryServiceIntegrationTest method shouldDeleteTheSpecifiedPackageRepository.
@Test
public void shouldDeleteTheSpecifiedPackageRepository() throws Exception {
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
String repoId = "npm";
PackageRepository npmRepo = new PackageRepository();
npmRepo.setId(repoId);
goConfigService.getConfigForEditing().setPackageRepositories(new PackageRepositories(npmRepo));
assertThat(goConfigService.getConfigForEditing().getPackageRepositories().size(), is(1));
assertThat(goConfigService.getConfigForEditing().getPackageRepositories().find(repoId), is(npmRepo));
service.deleteRepository(username, npmRepo, result);
HttpLocalizedOperationResult expectedResult = new HttpLocalizedOperationResult();
expectedResult.setMessage(EntityType.PackageRepository.deleteSuccessful(npmRepo.getId()));
assertThat(result, is(expectedResult));
assertThat(goConfigService.getConfigForEditing().getPackageRepositories().size(), is(0));
assertNull(goConfigService.getConfigForEditing().getPackageRepositories().find(repoId));
}
use of com.thoughtworks.go.domain.packagerepository.PackageRepositories in project gocd by gocd.
the class PackageRepositoryServiceIntegrationTest method shouldReturnTheExactLocalizeMessageIfItFailsToCreatePackageRepository.
@Test
public void shouldReturnTheExactLocalizeMessageIfItFailsToCreatePackageRepository() throws Exception {
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
String repoId = "npm";
PackageRepository npmRepo = new PackageRepository();
npmRepo.setId(repoId);
goConfigService.getConfigForEditing().setPackageRepositories(new PackageRepositories(npmRepo));
HttpLocalizedOperationResult expectedResult = new HttpLocalizedOperationResult();
expectedResult.forbidden(EntityType.PackageRepository.forbiddenToEdit("npm", "UnauthorizedUser"), forbidden());
assertThat(goConfigService.getConfigForEditing().getPackageRepositories().size(), is(1));
assertThat(goConfigService.getConfigForEditing().getPackageRepositories().find(repoId), is(npmRepo));
service.createPackageRepository(npmRepo, new Username("UnauthorizedUser"), result);
assertThat(result, is(expectedResult));
assertThat(goConfigService.getConfigForEditing().getPackageRepositories().size(), is(1));
assertThat(goConfigService.getConfigForEditing().getPackageRepositories().find(repoId), is(npmRepo));
}
Aggregations