use of org.fakekoji.core.AccessibleSettings in project jenkins-scm-koji-plugin by judovana.
the class BumperApiTest method addVariantWithMissingName.
@Test
public void addVariantWithMissingName() throws IOException {
final DataGenerator.FolderHolder folderHolder = DataGenerator.initFolders(temporaryFolder);
final AccessibleSettings settings = DataGenerator.getSettings(folderHolder);
final BumperAPI bumperApi = new BumperAPI(settings);
DataGenerator.createProjectJobs(settings);
final Result<BumpResult, OToolError> result = bumperApi.addTaskVariant(createParamsMap(new String[][] { { "type", Task.Type.BUILD.getValue() }, { "defaultValue", defaultValue }, { "values", defaultValue + ",ijklmnopq,rstuvwxyz" } }));
Assert.assertTrue(result.isError());
}
use of org.fakekoji.core.AccessibleSettings in project jenkins-scm-koji-plugin by judovana.
the class BumperApiTest method addVariantWithExistingName.
@Test
public void addVariantWithExistingName() throws IOException {
final DataGenerator.FolderHolder folderHolder = DataGenerator.initFolders(temporaryFolder);
final AccessibleSettings settings = DataGenerator.getSettings(folderHolder);
final BumperAPI bumperApi = new BumperAPI(settings);
DataGenerator.createProjectJobs(settings);
final Result<BumpResult, OToolError> result = bumperApi.addTaskVariant(createParamsMap(new String[][] { { "name", DataGenerator.JVM }, { "type", Task.Type.BUILD.getValue() }, { "defaultValue", defaultValue }, { "values", defaultValue + ",ijklmnopq,rstuvwxyz" } }));
Assert.assertTrue(result.isError());
}
use of org.fakekoji.core.AccessibleSettings in project jenkins-scm-koji-plugin by judovana.
the class BumperApiTest method addVariantWithMissingDefaultValue.
@Test
public void addVariantWithMissingDefaultValue() throws IOException {
final DataGenerator.FolderHolder folderHolder = DataGenerator.initFolders(temporaryFolder);
final AccessibleSettings settings = DataGenerator.getSettings(folderHolder);
final BumperAPI bumperApi = new BumperAPI(settings);
DataGenerator.createProjectJobs(settings);
final Result<BumpResult, OToolError> result = bumperApi.addTaskVariant(createParamsMap(new String[][] { { "name", taskVariantId }, { "type", Task.Type.BUILD.getValue() }, { "values", defaultValue + ",ijklmnopq,rstuvwxyz" } }));
Assert.assertTrue(result.isError());
}
use of org.fakekoji.core.AccessibleSettings in project jenkins-scm-koji-plugin by judovana.
the class BumperApiTest method removeBuildVariant.
@Test
public void removeBuildVariant() throws IOException {
final String taskVariantId = JRE_SDK;
final DataGenerator.FolderHolder folderHolder = DataGenerator.initFolders(temporaryFolder);
final AccessibleSettings settings = DataGenerator.getSettings(folderHolder);
DataGenerator.initBuildsRoot(settings.getDbFileRoot());
final File jobsRoot = settings.getJenkinsJobsRoot();
DataGenerator.createProjectJobs(settings);
final BumperAPI bumperApi = new BumperAPI(settings);
final Map<String, List<String>> params = Stream.of(new String[][] { { "name", taskVariantId }, { EXECUTE, "true" } }).collect(Collectors.toMap(data -> data[0], data -> Collections.singletonList(data[1])));
final Set<String> taskIds = DataGenerator.getTasks().stream().map(Task::getId).collect(Collectors.toSet());
final Result<BumpResult, OToolError> result = bumperApi.removeTaskVariant(params);
Assert.assertFalse(result.isError());
Assert.assertFalse(settings.getConfigManager().taskVariantManager.contains(taskVariantId));
final JobUpdateResults results = result.getValue().getJobResults();
Assert.assertEquals(47, results.jobsCreated.size());
Assert.assertTrue(results.jobsArchived.isEmpty());
Assert.assertTrue(results.jobsRevived.isEmpty());
Assert.assertTrue(results.jobsRewritten.isEmpty());
for (final JobUpdateResult jobResult : results.jobsCreated) {
final String[] parts = jobResult.message.split(" ");
final String prevJobName = parts[2];
final String currJobName = parts[4];
final String prevJobTaskId = prevJobName.split("-")[0];
final String currJobTaskId = currJobName.split("-")[0];
Assert.assertTrue(jobResult.success);
Assert.assertEquals(prevJobTaskId, currJobTaskId);
Assert.assertTrue(taskIds.contains(prevJobTaskId));
Assert.assertEquals(prevJobName.replace("." + SDK, ""), currJobName);
Assert.assertTrue(new File(jobsRoot, currJobName).exists());
Assert.assertFalse(new File(jobsRoot, prevJobName).exists());
}
Assert.assertEquals(Utils.readResource("org/fakekoji/api/http/rest/post-remove-variant-builds-tree"), toTree(settings.getDbFileRoot()));
}
use of org.fakekoji.core.AccessibleSettings in project jenkins-scm-koji-plugin by judovana.
the class TestSshApi method startSshdServer.
@BeforeClass
public static void startSshdServer() throws IOException, GeneralSecurityException {
final FolderHolder folderHolder = DataGenerator.initFolders(temporaryFolder);
final AccessibleSettings settings = DataGenerator.getSettings(folderHolder);
ServerSocket s = new ServerSocket(settings.getSshPort());
port = s.getLocalPort();
final File keys = File.createTempFile("ssh-fake-koji.", ".TestKeys");
keys.delete();
keys.mkdir();
priv = new File(keys, "id_rsa");
pub = new File(keys, "id_rsa.pub");
createFile(priv, IDS_RSA);
createFile(pub, IDS_RSA_PUB);
Set<PosixFilePermission> perms = new HashSet<>();
Files.setPosixFilePermissions(pub.toPath(), perms);
Files.setPosixFilePermissions(priv.toPath(), perms);
perms.add(PosixFilePermission.OWNER_READ);
perms.add(PosixFilePermission.OWNER_WRITE);
Files.setPosixFilePermissions(pub.toPath(), perms);
Files.setPosixFilePermissions(priv.toPath(), perms);
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
priv.delete();
pub.delete();
keys.delete();
}
});
s.close();
kojiDb = settings.getDbFileRoot();
server = new ScpService(settings, "tester=" + pub.getAbsolutePath());
server.start();
sources = File.createTempFile("ssh-fake-koji.", ".sources");
sources.delete();
sources.mkdir();
sources.deleteOnExit();
secondDir = File.createTempFile("ssh-fake-koji.", ".secondDir");
secondDir.delete();
secondDir.mkdir();
secondDir.deleteOnExit();
}
Aggregations