Search in sources :

Example 86 with TestFor

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()));
}
Also used : GitTestUtil.dataFile(jetbrains.buildServer.buildTriggers.vcs.git.tests.GitTestUtil.dataFile) File(java.io.File) Test(org.testng.annotations.Test) TestFor(jetbrains.buildServer.util.TestFor)

Example 87 with TestFor

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());
}
Also used : Pattern(java.util.regex.Pattern) VcsRootImpl(jetbrains.buildServer.vcs.impl.VcsRootImpl) Matcher(java.util.regex.Matcher) GitTestUtil.dataFile(jetbrains.buildServer.buildTriggers.vcs.git.tests.GitTestUtil.dataFile) FileUtil.writeFile(jetbrains.buildServer.util.FileUtil.writeFile) File(java.io.File) LockFile(org.eclipse.jgit.internal.storage.file.LockFile) Test(org.testng.annotations.Test) TestFor(jetbrains.buildServer.util.TestFor)

Example 88 with TestFor

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());
}
Also used : AgentRunningBuild(jetbrains.buildServer.agent.AgentRunningBuild) VcsRootImpl(jetbrains.buildServer.vcs.impl.VcsRootImpl) GitTestUtil.dataFile(jetbrains.buildServer.buildTriggers.vcs.git.tests.GitTestUtil.dataFile) File(java.io.File) TestFor(jetbrains.buildServer.util.TestFor)

Example 89 with TestFor

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")));
}
Also used : CheckoutRules(jetbrains.buildServer.vcs.CheckoutRules) VcsRoot(jetbrains.buildServer.vcs.VcsRoot) Test(org.testng.annotations.Test) TestFor(jetbrains.buildServer.util.TestFor)

Example 90 with TestFor

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"));
}
Also used : CheckoutRules(jetbrains.buildServer.vcs.CheckoutRules) VcsRoot(jetbrains.buildServer.vcs.VcsRoot) Test(org.testng.annotations.Test) TestFor(jetbrains.buildServer.util.TestFor)

Aggregations

TestFor (jetbrains.buildServer.util.TestFor)129 Test (org.testng.annotations.Test)81 File (java.io.File)65 GitTestUtil.dataFile (jetbrains.buildServer.buildTriggers.vcs.git.tests.GitTestUtil.dataFile)56 VcsRootImpl (jetbrains.buildServer.vcs.impl.VcsRootImpl)26 CheckoutRules (jetbrains.buildServer.vcs.CheckoutRules)21 VcsRoot (jetbrains.buildServer.vcs.VcsRoot)17 SFinishedBuild (jetbrains.buildServer.serverSide.SFinishedBuild)12 VcsException (jetbrains.buildServer.vcs.VcsException)11 URIish (org.eclipse.jgit.transport.URIish)11 Repository (org.eclipse.jgit.lib.Repository)9 BaseFinderTest (jetbrains.buildServer.server.rest.data.BaseFinderTest)7 AfterMethod (org.testng.annotations.AfterMethod)7 BeforeMethod (org.testng.annotations.BeforeMethod)7 Method (java.lang.reflect.Method)6 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)6 GitTestUtil.copyRepository (jetbrains.buildServer.buildTriggers.vcs.git.tests.GitTestUtil.copyRepository)6 Build (jetbrains.buildServer.server.rest.model.build.Build)6 BuildTypeImpl (jetbrains.buildServer.serverSide.impl.BuildTypeImpl)6 FileUtil.writeFile (jetbrains.buildServer.util.FileUtil.writeFile)6