From 1da06b4089aa546a55fc6ecd947424d2c5d69888 Mon Sep 17 00:00:00 2001 From: Tristan Cacqueray Date: Tue, 27 Aug 2019 19:41:49 +0000 Subject: [PATCH] web: fix connections list github base_url The toDict() method of the github connection should use base_url instead of baseurl to prevent an AttributeError exception being through as baseurl doesn't exists in the GithubConnection object. Change-Id: I2fa7a2bfde781371816da533530beb81c188bc9c --- tests/unit/test_web.py | 23 +++++++++++++++++++++++ zuul/driver/github/githubconnection.py | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/tests/unit/test_web.py b/tests/unit/test_web.py index 1b0c4df32a..7e2085311a 100644 --- a/tests/unit/test_web.py +++ b/tests/unit/test_web.py @@ -1539,3 +1539,26 @@ class TestTenantScopedWebApiWithAuthRules(BaseTestWeb): json=change) self.assertEqual(200, req.status_code, req.text) self.waitUntilSettled() + + +class TestWebMulti(BaseTestWeb): + config_file = 'zuul-gerrit-github.conf' + + def test_web_connections_list_multi(self): + data = self.get_url('api/connections').json() + gerrit_connection = { + 'driver': 'gerrit', + 'name': 'gerrit', + 'baseurl': 'https://review.example.com', + 'canonical_hostname': 'review.example.com', + 'server': 'review.example.com', + 'port': 29418, + } + github_connection = { + 'baseurl': 'https://api.github.com', + 'canonical_hostname': 'github.com', + 'driver': 'github', + 'name': 'github', + 'server': 'github.com', + } + self.assertEqual([gerrit_connection, github_connection], data) diff --git a/zuul/driver/github/githubconnection.py b/zuul/driver/github/githubconnection.py index 67d7932601..ad6d651753 100644 --- a/zuul/driver/github/githubconnection.py +++ b/zuul/driver/github/githubconnection.py @@ -771,7 +771,7 @@ class GithubConnection(BaseConnection): def toDict(self): d = super().toDict() d.update({ - "baseurl": self.baseurl, + "baseurl": self.base_url, "canonical_hostname": self.canonical_hostname, "server": self.server, })