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

test: Unregistration should be always explicit #345

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
2 changes: 2 additions & 0 deletions integration-tests/constants.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import pathlib

HOST_DETAILS: str = "/var/lib/insights/host-details.json"
REGISTERED_FILE: str = "/etc/insights-client/.registered"
UNREGISTERED_FILE: str = "/etc/insights-client/.unregistered"
MACHINE_ID_FILE: str = "/etc/insights-client/machine-id"
TAGS_FILE = pathlib.Path("/etc/insights-client/tags.yaml")
29 changes: 28 additions & 1 deletion integration-tests/test_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
:upstream: Yes
"""

import conftest
from constants import REGISTERED_FILE, UNREGISTERED_FILE, MACHINE_ID_FILE
import contextlib
import os
import pytest
from pytest_client_tools.util import Version
from time import sleep
import conftest

pytestmark = pytest.mark.usefixtures("register_subman")

Expand Down Expand Up @@ -45,6 +47,31 @@ def test_status_registered(external_candlepin, insights_client):
assert "This host is registered.\n" == registration_status.stdout


def test_status_registered_only_locally(
external_candlepin, insights_client, external_inventory
):
"""
:title: Test insights-client --status when registered only locally
"""
insights_client.config.legacy_upload = False
insights_client.register()
assert conftest.loop_until(lambda: insights_client.is_registered)
# Adding a small wait to ensure inventory is up-to-date
sleep(5)
external_inventory.delete(path=f"hosts/{external_inventory.this_system()['id']}")
response = external_inventory.get(path=f"hosts?insights_id={insights_client.uuid}")
assert response.json()["total"] == 0

registration_status = insights_client.run("--status", check=False)
if insights_client.core_version >= Version(3, 5, 6):
assert "This host is registered.\n" == registration_status.stdout
assert os.path.exists(REGISTERED_FILE)
assert not os.path.exists(UNREGISTERED_FILE)
assert os.path.exists(MACHINE_ID_FILE)
else:
assert "This host is unregistered.\n" == registration_status.stdout


def test_status_unregistered(external_candlepin, insights_client):
"""
:id: aa37831a-a581-44db-a7c9-de8161767c7e
Expand Down
Loading