-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Card-ID: CCT-738, integration tests for DBus Unregister call
- Loading branch information
Showing
2 changed files
with
60 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Copyright (c) 2024 Red Hat, Inc. | ||
# | ||
# This software is licensed to you under the GNU General Public | ||
# License as published by the Free Software Foundation; either version | ||
# 2 of the License (GPLv2) or (at your option) any later version. | ||
# There is NO WARRANTY for this software, express or implied, | ||
# including the implied warranties of MERCHANTABILITY, | ||
# NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should | ||
# have received a copy of GPLv2 along with this software; if not, see | ||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. | ||
# | ||
|
||
|
||
import pytest | ||
from utils import loop_until | ||
from constants import RHSM, RHSM_UNREGISTER | ||
|
||
import logging | ||
from functools import partial | ||
from dasbus.error import DBusError | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
locale = "en_US.UTF-8" | ||
|
||
# Tests describe a case when an application unregisters a system. | ||
# | ||
# The API should handle even wrong cases friendly | ||
# - ie. when a system is not registered the API should provide usefull feedback | ||
|
||
|
||
def test_unregister(any_candlepin, subman, test_config): | ||
""" | ||
https://www.candlepinproject.org/docs/subscription-manager/dbus_objects.html#unregister | ||
""" | ||
candlepin_config = partial(test_config.get, "candlepin") | ||
subman.register( | ||
username=candlepin_config("username"), | ||
password=candlepin_config("password"), | ||
org=candlepin_config("org"), | ||
) | ||
loop_until(lambda: subman.is_registered) | ||
|
||
proxy = RHSM.get_proxy(RHSM_UNREGISTER, interface_name=RHSM_UNREGISTER) | ||
response = proxy.Unregister({}, locale) | ||
assert response is None | ||
assert not subman.is_registered | ||
|
||
|
||
def test_unregister_when_system_is_not_registered(any_candlepin, subman, test_config): | ||
""" | ||
https://www.candlepinproject.org/docs/subscription-manager/dbus_objects.html#unregister | ||
""" | ||
proxy = RHSM.get_proxy(RHSM_UNREGISTER, interface_name=RHSM_UNREGISTER) | ||
with pytest.raises(DBusError) as excinfo: | ||
proxy.Unregister({}, locale) | ||
|
||
logger.debug(f"exception from dbus Unregister call: {excinfo}") | ||
assert "This object requires the consumer to be registered before it can be used." in str(excinfo.value) | ||
assert not subman.is_registered |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters