summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2022-06-28 16:08:45 +0000
committerGerrit Code Review <review@openstack.org>2022-06-28 16:08:45 +0000
commit6b167dd2f17d49dafec1a9756b04494ea77eea7d (patch)
treee5ce612ce668efa0932c9ffbfce9a0dc97f0c8ce /tests
parentbb0af6dec1b33a41b4a2be0adec016a9451cf7bd (diff)
parent595fb3e9eff9103a3cd1cd3286908a5e4dd982ef (diff)
downloadzuul-6b167dd2f17d49dafec1a9756b04494ea77eea7d.tar.gz
Merge "Add ssh_server option to Gerrit driver"
Diffstat (limited to 'tests')
-rw-r--r--tests/fixtures/zuul-gerrit-ssh.conf38
-rw-r--r--tests/unit/test_gerrit.py19
-rw-r--r--tests/unit/test_web.py4
3 files changed, 60 insertions, 1 deletions
diff --git a/tests/fixtures/zuul-gerrit-ssh.conf b/tests/fixtures/zuul-gerrit-ssh.conf
new file mode 100644
index 000000000..2f414032c
--- /dev/null
+++ b/tests/fixtures/zuul-gerrit-ssh.conf
@@ -0,0 +1,38 @@
+[statsd]
+# note, use 127.0.0.1 rather than localhost to avoid getting ipv6
+# see: https://github.com/jsocol/pystatsd/issues/61
+server=127.0.0.1
+
+[scheduler]
+tenant_config=main.yaml
+
+[merger]
+git_dir=/tmp/zuul-test/merger-git
+git_user_email=zuul@example.com
+git_user_name=zuul
+
+[executor]
+git_dir=/tmp/zuul-test/executor-git
+load_multiplier=100
+
+[connection gerrit]
+driver=gerrit
+server=review.example.com
+ssh_server=ssh-review.example.com
+user=jenkins
+sshkey=fake_id_rsa_path
+password=badpassword
+
+[connection github]
+driver=github
+webhook_token=0000000000000000000000000000000000000000
+
+[connection smtp]
+driver=smtp
+server=localhost
+port=25
+default_from=zuul@example.com
+default_to=you@example.com
+
+[database]
+dburi=$MYSQL_FIXTURE_DBURI$
diff --git a/tests/unit/test_gerrit.py b/tests/unit/test_gerrit.py
index bcb8f7bc8..0bb78d9ff 100644
--- a/tests/unit/test_gerrit.py
+++ b/tests/unit/test_gerrit.py
@@ -148,6 +148,25 @@ class TestGerrit(BaseTestCase):
'ssh://gerrit@localhost:29418/org/project',
url)
+ def test_ssh_server_getGitURL(self):
+ gerrit_config = {
+ 'user': 'gerrit',
+ 'server': 'otherserver',
+ 'password': '1/badpassword',
+ 'ssh_server': 'localhost',
+ 'git_over_ssh': 'true',
+ }
+ # The 1/ in the password ensures we test the url encoding
+ # path; this is the format of password we get from
+ # googlesource.com.
+ driver = GerritDriver()
+ gerrit = GerritConnection(driver, 'review_gerrit', gerrit_config)
+ project = gerrit.source.getProject('org/project')
+ url = gerrit.source.getGitUrl(project)
+ self.assertEqual(
+ 'ssh://gerrit@localhost:29418/org/project',
+ url)
+
class TestGerritWeb(ZuulTestCase):
config_file = 'zuul-gerrit-web.conf'
diff --git a/tests/unit/test_web.py b/tests/unit/test_web.py
index bbed5f426..4bbde2b41 100644
--- a/tests/unit/test_web.py
+++ b/tests/unit/test_web.py
@@ -316,6 +316,7 @@ class TestWeb(BaseTestWeb):
'baseurl': 'https://review.example.com',
'canonical_hostname': 'review.example.com',
'server': 'review.example.com',
+ 'ssh_server': 'review.example.com',
'port': 29418,
}
self.assertEqual([connection], data)
@@ -2954,7 +2955,7 @@ class TestHeldAttributeInBuildInfo(BaseTestWeb):
class TestWebMulti(BaseTestWeb):
- config_file = 'zuul-gerrit-github.conf'
+ config_file = 'zuul-gerrit-ssh.conf'
def test_web_connections_list_multi(self):
data = self.get_url('api/connections').json()
@@ -2966,6 +2967,7 @@ class TestWebMulti(BaseTestWeb):
'baseurl': url,
'canonical_hostname': 'review.example.com',
'server': 'review.example.com',
+ 'ssh_server': 'ssh-review.example.com',
'port': 29418,
}
github_connection = {