Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

integration tests for DBus Unregister call #3484

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions integration-tests/test_unregister.py
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
1 change: 0 additions & 1 deletion systemtest/tests/integration/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ EOF
./integration-tests/scripts/run-local-candlepin.sh

# create testing data in local candlepin
./integration-tests/scripts/post-activation-keys.sh
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not against of removing this line as a part of this PR, but please add some meaningful commit message to related commit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok next time I will add it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change should be part of different commit or please remove this change from this PR.

./integration-tests/scripts/post-environments.sh

# There is a problem with SELinux in current version of selinux-roles (for rhsm.service)
Expand Down
Loading