Skip to content

Commit

Permalink
cockpit: serialize BridgeConfig using __dict__
Browse files Browse the repository at this point in the history
A Bridgeconfig does not serialise to JSON by default.

Closes: #19319
  • Loading branch information
jelly authored and allisonkarlitskaya committed Sep 18, 2023
1 parent 3cc32e4 commit 5e0ac45
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/cockpit/bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ def main(*, beipack: bool = False) -> None:
print(f'Version: {__version__}\nProtocol: 1')
return
elif args.bridges:
print(json.dumps(Packages().get_bridge_configs(), indent=2))
print(json.dumps([config.__dict__ for config in Packages().get_bridge_configs()], indent=2))
return

# The privileged bridge doesn't need ssh-agent, but the main one does
Expand Down
11 changes: 11 additions & 0 deletions test/verify/check-connection
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
# along with Cockpit; If not, see <http://www.gnu.org/licenses/>.

import base64
import json
import os
import subprocess
import time
Expand Down Expand Up @@ -1194,6 +1195,16 @@ UnixPath=/run/cockpit/session
self.assertRegex(packages, r"(^|\n)base1\s+.*/usr/share/cockpit/base1")
self.assertRegex(packages, r"(^|\n)system\s+.*/usr/share/cockpit/systemd")

if self.is_pybridge():
bridges = json.loads(m.execute("cockpit-bridge --bridges").strip())
bridge_names = [b['name'] for b in bridges]
self.assertGreater(len(bridges), 0)
self.assertIn('sudo', bridge_names)

# OStree has no PCP bridge
if not m.ostree_image:
self.assertIn(f'{self.libexecdir}/cockpit-pcp', bridge_names)


@testlib.skipDistroPackage()
class TestReverseProxy(testlib.MachineCase):
Expand Down

0 comments on commit 5e0ac45

Please sign in to comment.