Search in sources :

Example 76 with TestFor

use of jetbrains.buildServer.util.TestFor in project teamcity-rest by JetBrains.

the class AgentFinderTest method testLocatorCompatibleBuildSpecific.

@Test
@TestFor(issues = { "TW-49934" })
public void testLocatorCompatibleBuildSpecific() throws Exception {
    ProjectEx project10 = createProject("project10", "project 10");
    BuildTypeEx bt10 = project10.createBuildType("bt10", "bt 10");
    bt10.addParameter(new SimpleParameter("a", "%b%"));
    checkAgents(null, myAgent1, myAgent2);
    checkAgents("compatible:(buildType:(id:" + bt10.getExternalId() + "))");
    {
        SQueuedBuild queuedBuild = build().in(bt10).addToQueue();
        checkAgents("compatible:(build:(id:" + queuedBuild.getItemId() + "))");
        queuedBuild.removeFromQueue(null, null);
    }
    {
        SQueuedBuild queuedBuild = build().in(bt10).parameter("b", "value").addToQueue();
        checkAgents("compatible:(build:(id:" + queuedBuild.getItemId() + "))", myAgent1);
    }
}
Also used : ProjectEx(jetbrains.buildServer.serverSide.impl.ProjectEx) Test(org.testng.annotations.Test) TestFor(jetbrains.buildServer.util.TestFor)

Example 77 with TestFor

use of jetbrains.buildServer.util.TestFor in project teamcity-git by JetBrains.

the class ServerPluginConfigTest method test_modern_proxy_settings.

@TestFor(issues = "TW-57178")
public void test_modern_proxy_settings() {
    final String httpProxyHost = "some.org";
    final String httpProxyPort = "3128";
    final String httpNonProxyHosts = "localhost|*.mydomain.com";
    final String httpsProxyPort = "3129";
    final String httpsProxyHost = "other.org";
    System.setProperty("teamcity.http.proxyHost", httpProxyHost);
    System.setProperty("teamcity.http.proxyPort", httpProxyPort);
    System.setProperty("teamcity.http.nonProxyHosts", httpNonProxyHosts);
    System.setProperty("teamcity.https.proxyHost", httpsProxyHost);
    System.setProperty("teamcity.https.proxyPort", httpsProxyPort);
    ServerPluginConfig config = new PluginConfigImpl(myServerPaths);
    assertEquals(asList("-Dhttp.proxyHost=" + httpProxyHost, "-Dhttp.proxyPort=" + httpProxyPort, SystemInfo.isUnix ? "-Dhttp.nonProxyHosts=" + httpNonProxyHosts : "-Dhttp.nonProxyHosts=\"" + httpNonProxyHosts + "\"", "-Dhttps.proxyHost=" + httpsProxyHost, "-Dhttps.proxyPort=" + httpsProxyPort), config.getOptionsForSeparateProcess());
    assertNull(config.getJschProxy());
}
Also used : PluginConfigImpl(jetbrains.buildServer.buildTriggers.vcs.git.PluginConfigImpl) ServerPluginConfig(jetbrains.buildServer.buildTriggers.vcs.git.ServerPluginConfig) TestFor(jetbrains.buildServer.util.TestFor)

Example 78 with TestFor

use of jetbrains.buildServer.util.TestFor in project teamcity-git by JetBrains.

the class SshAuthenticationTest method ssh_git_wrong_key_file_local_rsa_encrypted_key.

@TestFor(issues = "TW-73578")
@Test(dataProvider = "true,false")
public void ssh_git_wrong_key_file_local_rsa_encrypted_key(boolean nativeOperationsEnabled) throws Exception {
    final File key = dataFile("keys/id_ecdsa");
    withSubstitutedLocalKeys("id_rsa_encrypted", () -> {
        try {
            do_ssh_test(nativeOperationsEnabled, false, "ssh://git@%s:%s/home/git/repo.git", "PasswordAuthentication yes\nPubkeyAuthentication yes\n", null, "keys/id_rsa_encrypted.pub", b -> b.withAuthMethod(AuthenticationMethod.PRIVATE_KEY_FILE).withPrivateKeyPath(key.getAbsolutePath()));
            fail("Exception was expected");
        } catch (Exception e) {
            final String msg = e.getMessage();
            if (msg.contains("Permission denied") || msg.contains("Auth fail") || msg.contains("Too many authentication failures"))
                return null;
            throw e;
        }
        return null;
    });
}
Also used : GitTestUtil.dataFile(jetbrains.buildServer.buildTriggers.vcs.git.tests.GitTestUtil.dataFile) File(java.io.File) SkipException(org.testng.SkipException) IOException(java.io.IOException) Test(org.testng.annotations.Test) TestFor(jetbrains.buildServer.util.TestFor)

Example 79 with TestFor

use of jetbrains.buildServer.util.TestFor in project teamcity-git by JetBrains.

the class SshAuthenticationTest method ssh_git_rsa_key_file_with_cr_lf.

@TestFor(issues = "TW-75138")
@Test(dataProvider = "true,false")
public void ssh_git_rsa_key_file_with_cr_lf(boolean nativeOperationsEnabled) throws Exception {
    final File key = dataFile("keys/id_rsa");
    final File wrong_key = myTempFiles.createTempFile(FileUtil.readText(key, "UTF-8").replace("\n", "\r\n"));
    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 80 with TestFor

use of jetbrains.buildServer.util.TestFor in project teamcity-git by JetBrains.

the class TestConnectionTest method test_not_existing_local_repository.

@TestFor(issues = "TW-9933")
public void test_not_existing_local_repository() throws Exception {
    File notExisting = new File(myTempFiles.createTempDir(), "not-existing");
    String url = GitUtils.toURL(notExisting);
    VcsRootImpl root = vcsRoot().withFetchUrl(url).build();
    try {
        myGit.testConnection(root);
        fail("Should throw an exception for not-existing repository");
    } catch (VcsException e) {
        TeamCityAsserts.assertContainsAny(e.getMessage(), "Cannot access the '" + url + "' repository", "Please make sure you have the correct access rights and the repository exists");
        assertFalse(e.getMessage().endsWith("\n"));
    }
}
Also used : VcsRootImpl(jetbrains.buildServer.vcs.impl.VcsRootImpl) VcsException(jetbrains.buildServer.vcs.VcsException) File(java.io.File) 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