use of jetbrains.buildServer.util.TestFor in project teamcity-git by JetBrains.
the class SshAuthenticationTest method ssh_git_rsa_key_file_with_no_lf_on_end.
@TestFor(issues = "TW-75138")
@Test(dataProvider = "true,false")
public void ssh_git_rsa_key_file_with_no_lf_on_end(boolean nativeOperationsEnabled) throws Exception {
final File key = dataFile("keys/id_rsa");
final File wrong_key = myTempFiles.createTempFile((FileUtil.readText(key, "UTF-8").trim()));
do_ssh_test(nativeOperationsEnabled, true, "ssh://git@%s:%s/home/git/repo.git", "", null, "keys/id_rsa.pub", b -> b.withAuthMethod(AuthenticationMethod.PRIVATE_KEY_FILE).withPrivateKeyPath(wrong_key.getAbsolutePath()));
}
use of jetbrains.buildServer.util.TestFor in project teamcity-git by JetBrains.
the class GitVcsSupportTest method should_create_teamcity_config_in_root_with_custom_path.
/*
* Repository cloned by hand could have no teamcity.remote config, we should create it otherwise we can see 'null' as remote url in error messages
* (see log in the issue for details).
*/
@TestFor(issues = "TW-15564")
@Test(dataProvider = "doFetchInSeparateProcess", dataProviderClass = FetchOptionsDataProvider.class)
public void should_create_teamcity_config_in_root_with_custom_path(boolean fetchInSeparateProcess) throws IOException, VcsException {
setInternalProperty(Constants.CUSTOM_CLONE_PATH_ENABLED, "true");
System.setProperty("teamcity.git.fetch.separate.process", String.valueOf(fetchInSeparateProcess));
File customRootDir = new File(myTmpDir, "custom-dir");
VcsRootImpl root = (VcsRootImpl) getRoot("master");
root.addProperty(Constants.PATH, customRootDir.getAbsolutePath());
getSupport().getCurrentState(root);
File configFile = new File(customRootDir, "config");
String config = FileUtil.readText(configFile);
Pattern pattern = Pattern.compile("(.*)\\[teamcity\\]\\s+remote = " + Pattern.quote(GitUtils.toURL(myMainRepositoryDir)) + "\\s*(.*)", Pattern.DOTALL);
Matcher matcher = pattern.matcher(config);
assertTrue(matcher.matches(), "config is " + config);
// erase teamcity.remote config
String newConfig = matcher.group(1) + matcher.group(2);
writeFile(configFile, newConfig);
getSupport().getCurrentState(root);
config = FileUtil.readText(configFile);
assertTrue(pattern.matcher(config).matches());
}
use of jetbrains.buildServer.util.TestFor in project teamcity-git by JetBrains.
the class HttpAuthTest method quote_in_password.
@TestFor(issues = "TW-51968")
public void quote_in_password(@NotNull GitExec git) throws Exception {
File repo = copyRepository(myTempFiles, dataFile("repo_for_fetch.1"), "repo.git");
final String user = "user";
final String password = "pass'word";
myServer = new GitHttpServer(git.getPath(), repo);
myServer.setCredentials(user, password);
myServer.start();
VcsRootImpl root = vcsRoot().withFetchUrl(myServer.getRepoUrl()).withAuthMethod(AuthenticationMethod.PASSWORD).withUsername(user).withPassword(password).withBranch("master").build();
File buildDir = myTempFiles.createTempDir();
AgentRunningBuild build = runningBuild().sharedEnvVariable(Constants.TEAMCITY_AGENT_GIT_PATH, git.getPath()).withAgentConfiguration(myAgentConfiguration).addRoot(root).withCheckoutDir(buildDir).build();
Checkout checkout = new Checkout(root, "add81050184d3c818560bdd8839f50024c188586", buildDir, build);
checkout.run(TimeUnit.SECONDS.toMillis(10));
assertTrue(checkout.success());
}
use of jetbrains.buildServer.util.TestFor in project teamcity-git by JetBrains.
the class GitPatchTest method patch_from_unknown_commit_excluded_root_dir.
@TestFor(issues = "TW-40689")
@Test
public void patch_from_unknown_commit_excluded_root_dir() throws Exception {
VcsRoot root = getRoot("rename-test");
String unknownCommit = "hahahahahahahahahahahahahahahahahahahaha";
checkPatch(root, "patch3", unknownCommit, "1837cf38309496165054af8bf7d62a9fe8997202", new CheckoutRules(asList(// this rule caused NPE
"-:.", "+:dir with space=>dir with space", "+:dir1=>dir1", "+:file_in_branch.txt")));
}
use of jetbrains.buildServer.util.TestFor in project teamcity-git by JetBrains.
the class GitPatchTest method excluded_broken_submodule.
@TestFor(issues = "TW-49782")
@Test(dataProvider = "patchInSeparateProcess")
public void excluded_broken_submodule(boolean patchInSeparateProcess) throws Exception {
myConfigBuilder.setSeparateProcessForPatch(patchInSeparateProcess);
VcsRoot root = getRoot("reference-wrong-commit", true);
// 7253d358a2490321a1808a1c20561b4027d69f77 references wrong submodule commit, but it is excluded by checkout rules, patch should succeed
checkPatch(root, "excluded_broken_submodule", null, "7253d358a2490321a1808a1c20561b4027d69f77", new CheckoutRules("+:dir"));
}
Aggregations