From 9e0e04d90b62c14941832f634b0a01c79eb1a4c5 Mon Sep 17 00:00:00 2001 From: Didier Roche Date: Thu, 9 Dec 2021 15:57:27 +0000 Subject: [PATCH] subscription support mode for docker system container We now support subscription modes for mocking enabling/disabling in integration tests. Co-authored-by: Jean-Baptiste Lallement --- cmd/integration_tests/adsys_test.go | 1 + cmd/integration_tests/systemdaemons/dbus.conf | 9 +++++++++ .../systemdaemons/systemdaemons.sh | 14 ++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/cmd/integration_tests/adsys_test.go b/cmd/integration_tests/adsys_test.go index 39baf3b4b..08aebd723 100644 --- a/cmd/integration_tests/adsys_test.go +++ b/cmd/integration_tests/adsys_test.go @@ -331,6 +331,7 @@ func runDaemons() (teardown func()) { "invalid_startup_time": filepath.Join(dir, "invalidstartuptime"), "no_nextrefresh_time": filepath.Join(dir, "nonextrefreshtime"), "invalid_nextrefresh_time": filepath.Join(dir, "invalidnextrefreshtime"), + "subcription_disabled": filepath.Join(dir, "subscriptiondisabled"), } systemSockets = make(map[string]string) diff --git a/cmd/integration_tests/systemdaemons/dbus.conf b/cmd/integration_tests/systemdaemons/dbus.conf index 6f0bbcb5f..5b2cae5a3 100644 --- a/cmd/integration_tests/systemdaemons/dbus.conf +++ b/cmd/integration_tests/systemdaemons/dbus.conf @@ -71,4 +71,13 @@ + + + + + + + + + diff --git a/cmd/integration_tests/systemdaemons/systemdaemons.sh b/cmd/integration_tests/systemdaemons/systemdaemons.sh index 0b657a79a..3a202b20f 100755 --- a/cmd/integration_tests/systemdaemons/systemdaemons.sh +++ b/cmd/integration_tests/systemdaemons/systemdaemons.sh @@ -23,6 +23,7 @@ fi # Add dbus registername main objects python3 -m dbusmock --system org.freedesktop.systemd1 /org/freedesktop/systemd1 org.freedesktop.systemd1.Manager & python3 -m dbusmock --system org.freedesktop.sssd.infopipe /org/freedesktop/sssd/infopipe/Domains/example_2ecom org.freedesktop.sssd.infopipe.Domains.Domain & +python3 -m dbusmock --system com.canonical.UbuntuAdvantage /com/canonical/UbuntuAdvantage/Services/esm_2dinfra com.canonical.UbuntuAdvantage.Service & sleep 3 # Handle systemd objects depending on the mode @@ -75,6 +76,19 @@ gdbus call --system -d org.freedesktop.sssd.infopipe -o /org/freedesktop/sssd/in gdbus call --system -d org.freedesktop.sssd.infopipe -o /org/freedesktop/sssd/infopipe/Domains/example_2ecom -m org.freedesktop.DBus.Mock.AddMethod '' ActiveServer 's' 's' 'ret = "adc.example.com"' gdbus call --system -d org.freedesktop.sssd.infopipe -o /org/freedesktop/sssd/infopipe/Domains/online_no_active_server -m org.freedesktop.DBus.Mock.AddMethod '' ActiveServer 's' 's' 'ret = ""' +# Ubuntu Advantage subcription state +case "${mode}" in + "subcription_disabled") + status="" + ;; + + *) + status="" + ;; +esac + +gdbus call --system -d com.canonical.UbuntuAdvantage -o /com/canonical/UbuntuAdvantage/Services/esm_2dinfra -m org.freedesktop.DBus.Mock.AddProperty com.canonical.UbuntuAdvantage.Service Status "${status}" + sleep 1 /usr/lib/policykit-1/polkitd \ No newline at end of file