From 71340d56cd8d3d00bddb48e115eb8ebe476ba565 Mon Sep 17 00:00:00 2001 From: Jiri Hnidek Date: Mon, 3 Jun 2024 12:54:16 +0200 Subject: [PATCH] feat: Removed D-Bus methods related to attach * Card ID: CCT-425 * Removed interface: com.redhat.RHSM1.Attach * Removed AutoAttach and PoolAttach * Modified Register method * Removed unit tests related to removed methods * Modified unit tests of register D-Bus methods --- src/rhsmlib/dbus/objects/__init__.py | 1 - src/rhsmlib/dbus/objects/attach.py | 141 ----------- src/rhsmlib/dbus/objects/register.py | 19 +- .../scripts/rhsm_service.py | 1 - test/rhsmlib/dbus/test_attach.py | 159 ------------- test/rhsmlib/dbus/test_register.py | 225 +----------------- 6 files changed, 10 insertions(+), 536 deletions(-) delete mode 100644 src/rhsmlib/dbus/objects/attach.py delete mode 100644 test/rhsmlib/dbus/test_attach.py diff --git a/src/rhsmlib/dbus/objects/__init__.py b/src/rhsmlib/dbus/objects/__init__.py index b1c3f9473c..77a1df4eea 100644 --- a/src/rhsmlib/dbus/objects/__init__.py +++ b/src/rhsmlib/dbus/objects/__init__.py @@ -14,7 +14,6 @@ from rhsmlib.dbus.objects.config import ConfigDBusObject # NOQA from rhsmlib.dbus.objects.main import Main # NOQA from rhsmlib.dbus.objects.register import RegisterDBusObject, DomainSocketRegisterDBusObject # NOQA -from rhsmlib.dbus.objects.attach import AttachDBusObject # NOQA from rhsmlib.dbus.objects.products import ProductsDBusObject # NOQA from rhsmlib.dbus.objects.unregister import UnregisterDBusObject # NOQA from rhsmlib.dbus.objects.entitlement import EntitlementDBusObject # NOQA diff --git a/src/rhsmlib/dbus/objects/attach.py b/src/rhsmlib/dbus/objects/attach.py deleted file mode 100644 index 6830670e8f..0000000000 --- a/src/rhsmlib/dbus/objects/attach.py +++ /dev/null @@ -1,141 +0,0 @@ -# Copyright (c) 2017 Red Hat, Inc. -# -# This software is licensed to you under the GNU General Public License, -# version 2 (GPLv2). There is NO WARRANTY for this software, express or -# implied, including the implied warranties of MERCHANTABILITY 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. -# -# Red Hat trademarks are not licensed under GPLv2. No permission is -# granted to use or replicate Red Hat trademarks that are incorporated -# in this software or its documentation. -from typing import List - -import dbus -import json -import logging - -from rhsm.connection import UEPConnection -from subscription_manager import entcertlib -from subscription_manager.i18n import Locale - -from rhsmlib.dbus import constants, base_object, util, dbus_utils -from rhsmlib.services.attach import AttachService - -from subscription_manager.injectioninit import init_dep_injection -from subscription_manager.utils import is_simple_content_access - -init_dep_injection() - -log = logging.getLogger(__name__) - - -class AttachDBusImplementation(base_object.BaseImplementation): - def auto_attach(self, service_level: str, proxy_options: dict) -> dict: - self.ensure_registered() - - uep: UEPConnection = self.build_uep(proxy_options, proxy_only=True) - - # TODO Change log.info() - # to raise dbus.DBusException('Auto-attaching is not allowed in simple content access mode') - # in next minor subscription-manager release - if is_simple_content_access(uep=uep): - log.info( - "Calling D-Bus method AutoAttach() is deprecated, when Simple Content Access mode " - "is used and it will be not be supported in the next minor release of " - "subscription-manager" - ) - - service = AttachService(uep) - try: - response: dict = service.attach_auto(service_level) - except Exception as exc: - log.exception(exc) - raise dbus.DBusException(str(exc)) - - # TODO This should probably be called only if something is actually attached - entcertlib.EntCertActionInvoker().update() - return response - - def pool_attach(self, pools: List[str], quantity: int, proxy_options: dict) -> List[dict]: - self.ensure_registered() - - if quantity < 1: - raise dbus.DBusException("Quantity must be a positive number.") - - uep: UEPConnection = self.build_uep(proxy_options, proxy_only=True) - - # TODO Change log.info() - # to raise dbus.DBusException('Auto-attaching is not allowed in simple content access mode') - # in next minor subscription-manager release - if is_simple_content_access(uep=uep): - log.info( - "Calling D-Bus method AutoAttach() is deprecated, when Simple Content Access mode " - "is used and it will be not be supported in the next minor release of " - "subscription-manager" - ) - - service = AttachService(uep) - try: - results: List[dict] = [] - for pool in pools: - response = service.attach_pool(pool, quantity) - results.append(response) - except Exception as exc: - log.exception(exc) - raise dbus.DBusException(str(exc)) - - # TODO This should probably be called only if something is actually attached - entcertlib.EntCertActionInvoker().update() - return results - - -class AttachDBusObject(base_object.BaseObject): - """ - A DBus object that interacts with subscription-manager to attach various - subscriptions. Results are either a JSON string or a list of JSON strings. - We don't return the JSON in an actual dictionary because deeply nested structures - are a nightmare in DBus land. See https://stackoverflow.com/questions/31658423/ - """ - - default_dbus_path = constants.ATTACH_DBUS_PATH - interface_name = constants.ATTACH_INTERFACE - - def __init__(self, conn=None, object_path=None, bus_name=None): - super(AttachDBusObject, self).__init__(conn=conn, object_path=object_path, bus_name=bus_name) - self.impl = AttachDBusImplementation() - - @util.dbus_service_method( - constants.ATTACH_INTERFACE, - in_signature="sa{sv}s", - out_signature="s", - ) - @util.dbus_handle_sender - @util.dbus_handle_exceptions - def AutoAttach(self, service_level, proxy_options, locale, sender=None): - service_level = dbus_utils.dbus_to_python(service_level, expected_type=str) or None - proxy_options = dbus_utils.dbus_to_python(proxy_options, expected_type=dict) - locale = dbus_utils.dbus_to_python(locale, expected_type=str) - Locale.set(locale) - - result: dict = self.impl.auto_attach(service_level, proxy_options) - return json.dumps(result) - - @util.dbus_service_method( - constants.ATTACH_INTERFACE, - in_signature="asia{sv}s", - out_signature="as", - ) - @util.dbus_handle_sender - @util.dbus_handle_exceptions - def PoolAttach(self, pools, quantity, proxy_options, locale, sender=None): - pools = dbus_utils.dbus_to_python(pools, expected_type=list) - quantity = dbus_utils.dbus_to_python(quantity, expected_type=int) - proxy_options = dbus_utils.dbus_to_python(proxy_options, expected_type=dict) - - locale = dbus_utils.dbus_to_python(locale, expected_type=str) - Locale.set(locale) - - result: List[dict] = self.impl.pool_attach(pools, quantity, proxy_options) - return [json.dumps(item) for item in result] diff --git a/src/rhsmlib/dbus/objects/register.py b/src/rhsmlib/dbus/objects/register.py index 3b03419606..f22d4b2efd 100644 --- a/src/rhsmlib/dbus/objects/register.py +++ b/src/rhsmlib/dbus/objects/register.py @@ -23,7 +23,6 @@ from rhsmlib.dbus import constants, exceptions, dbus_utils, base_object, server, util from rhsmlib.services.register import RegisterService from rhsmlib.services.unregister import UnregisterService -from rhsmlib.services.attach import AttachService from rhsmlib.services.entitlement import EntitlementService from rhsmlib.client_info import DBusSender from subscription_manager.cp_provider import CPProvider @@ -268,22 +267,12 @@ def _remove_enable_content_option(self, options: dict) -> bool: return bool(options.pop("enable_content")) def _enable_content(self, uep: "UEPConnection", consumer: dict) -> None: - """Try to enable content: Auto-attach in non-SCA or refresh in SCA mode.""" + """Try to enable content: refresh SCA entitlement certs in SCA mode.""" content_access: str = consumer["owner"]["contentAccessMode"] enabled_content = None if content_access == "entitlement": - log.debug("Auto-attaching since 'enable_content' is true.") - service = AttachService(uep) - enabled_content = service.attach_auto() - if len(enabled_content) > 0: - log.debug("Updating entitlement certificates") - # FIXME: The enabled_content contains all data necessary for generating entitlement - # certificate and private key. Thus we could save few REST API calls, when the data was used. - EntCertActionInvoker().update() - else: - log.debug("No content was enabled, entitlement certificates not updated.") - + log.error("Entitlement content access mode is not supported") elif content_access == "org_environment": log.debug("Refreshing since 'enable_content' is true.") service = EntitlementService(uep) @@ -409,8 +398,6 @@ def Register(self, org, username, password, options, connection_options, locale) used. Options is a dict of strings that modify the outcome of this method. - - Note this method is registration ONLY. Auto-attach is a separate process. """ org = dbus_utils.dbus_to_python(org, expected_type=str) connection_options = dbus_utils.dbus_to_python(connection_options, expected_type=dict) @@ -435,7 +422,7 @@ def Register(self, org, username, password, options, connection_options, locale) @util.dbus_handle_exceptions def RegisterWithActivationKeys(self, org, activation_keys, options, connection_options, locale): """ - Note this method is registration ONLY. Auto-attach is a separate process. + This method registers the system using organization and activation keys """ connection_options = dbus_utils.dbus_to_python(connection_options, expected_type=dict) options = dbus_utils.dbus_to_python(options, expected_type=dict) diff --git a/src/subscription_manager/scripts/rhsm_service.py b/src/subscription_manager/scripts/rhsm_service.py index 938c5dcb93..3ec839b6b5 100755 --- a/src/subscription_manager/scripts/rhsm_service.py +++ b/src/subscription_manager/scripts/rhsm_service.py @@ -33,7 +33,6 @@ def main(): object_classes = [ objects.ConfigDBusObject, objects.RegisterDBusObject, - objects.AttachDBusObject, objects.ProductsDBusObject, objects.UnregisterDBusObject, objects.EntitlementDBusObject, diff --git a/test/rhsmlib/dbus/test_attach.py b/test/rhsmlib/dbus/test_attach.py deleted file mode 100644 index c87c652184..0000000000 --- a/test/rhsmlib/dbus/test_attach.py +++ /dev/null @@ -1,159 +0,0 @@ -# Copyright (c) 2017 Red Hat, Inc. -# -# This software is licensed to you under the GNU General Public License, -# version 2 (GPLv2). There is NO WARRANTY for this software, express or -# implied, including the implied warranties of MERCHANTABILITY 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. -# -# Red Hat trademarks are not licensed under GPLv2. No permission is -# granted to use or replicate Red Hat trademarks that are incorporated -# in this software or its documentation. - -import dbus -from unittest import mock - -from rhsmlib.dbus.objects.attach import AttachDBusImplementation -from subscription_manager.i18n import Locale - -from test.rhsmlib.base import SubManDBusFixture -from test.rhsmlib.services.test_attach import CONTENT_JSON - - -class TestAttachDBusObject(SubManDBusFixture): - def setUp(self) -> None: - super().setUp() - self.impl = AttachDBusImplementation() - - is_simple_content_access_patch = mock.patch( - "rhsmlib.dbus.objects.attach.is_simple_content_access", - name="is_simple_content_access", - ) - self.patches["is_simple_content_access"] = is_simple_content_access_patch.start() - self.addCleanup(is_simple_content_access_patch.stop) - self.patches["is_simple_content_access"].return_value = False - - is_registered_patch = mock.patch( - "rhsmlib.dbus.objects.attach.AttachDBusImplementation.is_registered", - name="is_registered", - ) - self.patches["is_registered"] = is_registered_patch.start() - self.addCleanup(is_registered_patch.stop) - self.patches["is_registered"].return_value = True - - update_patch = mock.patch( - "subscription_manager.certlib.BaseActionInvoker.update", - name="update", - ) - self.patches["update"] = update_patch.start() - self.addCleanup(update_patch.stop) - self.patches["update"].return_value = None - - AttachService_patch = mock.patch( - "rhsmlib.dbus.objects.attach.AttachService", - name="AttachService", - autospec=True, - ) - self.mock_attach = AttachService_patch.start().return_value - self.addCleanup(AttachService_patch.stop) - - def tearDown(self): - Locale.set(self.LOCALE) - - def test_PoolAttach(self): - self.mock_attach.attach_pool.return_value = CONTENT_JSON - - expected = [CONTENT_JSON, CONTENT_JSON] - result = self.impl.pool_attach(["x", "y"], 1, {}) - self.assertEqual(result, expected) - - def test_PoolAttach__proxy(self): - self.mock_attach.attach_pool.return_value = CONTENT_JSON - - expected = [CONTENT_JSON, CONTENT_JSON] - result = self.impl.pool_attach( - ["x", "y"], - 1, - { - "proxy_hostname": "proxy.company.com", - "proxy_port": "3128", - "proxy_user": "user", - "proxy_password": "password", - }, - ) - self.assertEqual(result, expected) - - def test_PoolAttach__de(self): - self.mock_attach.attach_pool.return_value = CONTENT_JSON - Locale.set("de") - - expected = [CONTENT_JSON, CONTENT_JSON] - result = self.impl.pool_attach(["x", "y"], 1, {}) - self.assertEqual(expected, result) - - def test_PoolAttach__de_DE(self): - self.mock_attach.attach_pool.return_value = CONTENT_JSON - Locale.set("de_DE") - - expected = [CONTENT_JSON, CONTENT_JSON] - result = self.impl.pool_attach(["x", "y"], 1, {}) - self.assertEqual(expected, result) - - def test_PoolAttach__de_DE_utf8(self): - self.mock_attach.attach_pool.return_value = CONTENT_JSON - Locale.set("de_DE.utf-8") - - expected = [CONTENT_JSON, CONTENT_JSON] - result = self.impl.pool_attach(["x", "y"], 1, {}) - self.assertEqual(expected, result) - - def test_PoolAttach__de_DE_UTF8(self): - self.mock_attach.attach_pool.return_value = CONTENT_JSON - Locale.set("de_DE.UTF-8") - - expected = [CONTENT_JSON, CONTENT_JSON] - result = self.impl.pool_attach(["x", "y"], 1, {}) - self.assertEqual(expected, result) - - def test_PoolAttach__sca(self): - self.patches["is_simple_content_access"].return_value = True - self.mock_attach.attach_pool.return_value = CONTENT_JSON - Locale.set("de_DE.UTF-8") - - # TODO: Change to assertRaises when auto-attach is not supported in SCA mode - # BZ 2049101, BZ 2049620 - - expected = [CONTENT_JSON, CONTENT_JSON] - result = self.impl.pool_attach(["x", "y"], 1, {}) - self.assertEqual(expected, result) - - def test_PoolAttach__not_registered(self): - self.mock_attach.attach_pool.return_value = CONTENT_JSON - self.patches["is_registered"].return_value = False - - with self.assertRaisesRegex(dbus.DBusException, "requires the consumer to be registered"): - self.impl.pool_attach(["x", "y"], 1, {}) - - def test_AutoAttach(self): - self.mock_attach.attach_auto.return_value = CONTENT_JSON - - result = self.impl.auto_attach("service_level", {}) - self.assertEqual(CONTENT_JSON, result) - - def test_AutoAttach__sca(self): - self.patches["is_simple_content_access"].return_value = True - self.mock_attach.attach_auto.return_value = CONTENT_JSON - - # TODO: Change to assertRaises when auto-attach is not supported in SCA mode - # BZ 2049101, BZ 2049620 - - result = self.impl.auto_attach("service_level", {}) - self.assertEqual(CONTENT_JSON, result) - - def test_AutoAttach__not_registered(self): - self.mock_attach.attach_pool.return_value = CONTENT_JSON - self.patches["is_registered"].return_value = False - - with self.assertRaisesRegex(dbus.DBusException, "requires the consumer to be registered"): - self.impl.auto_attach("service level", {}) diff --git a/test/rhsmlib/dbus/test_register.py b/test/rhsmlib/dbus/test_register.py index e4934e8849..c9b5aceef7 100644 --- a/test/rhsmlib/dbus/test_register.py +++ b/test/rhsmlib/dbus/test_register.py @@ -26,45 +26,6 @@ from test.rhsmlib.base import SubManDBusFixture -CONSUMER_CONTENT_JSON = """{"hypervisorId": "foo", - "serviceLevel": "", - "autoheal": true, - "idCert": { - "key": "FAKE_KEY", - "cert": "FAKE_CERT", - "serial" : { - "id" : 5196045143213189102, - "revoked" : false, - "collected" : false, - "expiration" : "2033-04-25T18:03:06+0000", - "serial" : 5196045143213189102, - "created" : "2017-04-25T18:03:06+0000", - "updated" : "2017-04-25T18:03:06+0000" - }, - "id" : "8a8d011e5ba64700015ba647fbd20b88", - "created" : "2017-04-25T18:03:07+0000", - "updated" : "2017-04-25T18:03:07+0000" - }, - "owner": { - "href": "/owners/admin", - "displayName": "Admin Owner", - "id": "ff808081550d997c01550d9adaf40003", - "key": "admin", - "contentAccessMode": "entitlement" - }, - "href": "/consumers/c1b8648c-6f0a-4aa5-b34e-b9e62c0e4364", - "facts": {}, "id": "ff808081550d997c015511b0406d1065", - "uuid": "c1b8648c-6f0a-4aa5-b34e-b9e62c0e4364", - "guestIds": null, "capabilities": null, - "environment": null, "installedProducts": null, - "canActivate": false, "type": {"manifest": false, - "id": "1000", "label": "system"}, "annotations": null, - "username": "admin", "updated": "2016-06-02T15:16:51+0000", - "lastCheckin": null, "entitlementCount": 0, "releaseVer": - {"releaseVer": null}, "entitlementStatus": "valid", "name": - "test.example.com", "created": "2016-06-02T15:16:51+0000", - "contentTags": null, "dev": false}""" - CONSUMER_CONTENT_JSON_SCA = """{"hypervisorId": null, "serviceLevel": "", "autoheal": true, @@ -104,158 +65,6 @@ "test.example.com", "created": "2016-06-02T15:16:51+0000", "contentTags": null, "dev": false}""" -ENABLED_CONTENT = """[ { - "created" : "2022-06-30T13:24:33+0000", - "updated" : "2022-06-30T13:24:33+0000", - "id" : "16def3d98d6549f8a3649f723a76991c", - "consumer" : { - "id" : "4028face81aa047e0181b4c8e1170bdc", - "uuid" : "8503a41a-6ce2-480c-bc38-b67d6aa6dd20", - "name" : "thinkpad-t580", - "href" : "/consumers/8503a41a-6ce2-480c-bc38-b67d6aa6dd20" - }, - "pool" : { - "created" : "2022-06-28T11:14:35+0000", - "updated" : "2022-06-30T13:24:33+0000", - "id" : "4028face81aa047e0181aa052f740360", - "type" : "NORMAL", - "owner" : { - "id" : "4028face81aa047e0181aa0490e30002", - "key" : "admin", - "displayName" : "Admin Owner", - "href" : "/owners/admin", - "contentAccessMode" : "entitlement" - }, - "activeSubscription" : true, - "sourceEntitlement" : null, - "quantity" : 5, - "startDate" : "2022-06-23T13:14:26+0000", - "endDate" : "2023-06-23T13:14:26+0000", - "attributes" : [ ], - "restrictedToUsername" : null, - "contractNumber" : "0", - "accountNumber" : "6547096716", - "orderNumber" : "order-23226139", - "consumed" : 1, - "exported" : 0, - "branding" : [ ], - "calculatedAttributes" : { - "compliance_type" : "Standard" - }, - "upstreamPoolId" : "upstream-05736148", - "upstreamEntitlementId" : null, - "upstreamConsumerId" : null, - "productName" : "SP Server Standard (U: Development, R: SP Server)", - "productId" : "sp-server-dev", - "productAttributes" : [ { - "name" : "management_enabled", - "value" : "1" - }, { - "name" : "usage", - "value" : "Development" - }, { - "name" : "roles", - "value" : "SP Server" - }, { - "name" : "variant", - "value" : "ALL" - }, { - "name" : "sockets", - "value" : "128" - }, { - "name" : "support_level", - "value" : "Standard" - }, { - "name" : "support_type", - "value" : "L1-L3" - }, { - "name" : "arch", - "value" : "ALL" - }, { - "name" : "type", - "value" : "MKT" - }, { - "name" : "version", - "value" : "1.0" - } ], - "stackId" : null, - "stacked" : false, - "sourceStackId" : null, - "developmentPool" : false, - "href" : "/pools/4028face81aa047e0181aa052f740360", - "derivedProductAttributes" : [ ], - "derivedProductId" : null, - "derivedProductName" : null, - "providedProducts" : [ { - "productId" : "99000", - "productName" : "SP Server Bits" - } ], - "derivedProvidedProducts" : [ ], - "subscriptionSubKey" : "master", - "subscriptionId" : "srcsub-45255972", - "locked" : false - }, - "quantity" : 1, - "certificates" : [ { - "created" : "2022-06-30T13:24:33+0000", - "updated" : "2022-06-30T13:24:33+0000", - "id" : "4028face81aa047e0181b4c8e4b90be1", - "key" : "-----BEGIN PRIVATE KEY-----REDACTED-----END PRIVATE KEY-----", - "cert" : "-----BEGIN CERTIFICATE-----REDACTED-----END RSA SIGNATURE-----", - "serial" : { - "created" : "2022-06-30T13:24:33+0000", - "updated" : "2022-06-30T13:24:33+0000", - "id" : 3712610178651551557, - "serial" : 3712610178651551557, - "expiration" : "2023-06-23T13:14:26+0000", - "revoked" : false - } - } ], - "startDate" : "2022-06-23T13:14:26+0000", - "endDate" : "2023-06-23T13:14:26+0000", - "href" : null -} ] -""" - -# Following consumer do not contain information about content access mode -OLD_CONSUMER_CONTENT_JSON = """{"hypervisorId": null, - "serviceLevel": "", - "autoheal": true, - "idCert": { - "key": "FAKE_KEY", - "cert": "FAKE_CERT", - "serial" : { - "id" : 5196045143213189102, - "revoked" : false, - "collected" : false, - "expiration" : "2033-04-25T18:03:06+0000", - "serial" : 5196045143213189102, - "created" : "2017-04-25T18:03:06+0000", - "updated" : "2017-04-25T18:03:06+0000" - }, - "id" : "8a8d011e5ba64700015ba647fbd20b88", - "created" : "2017-04-25T18:03:07+0000", - "updated" : "2017-04-25T18:03:07+0000" - }, - "owner": { - "href": "/owners/admin", - "displayName": "Admin Owner", - "id": "ff808081550d997c01550d9adaf40003", - "key": "admin" - }, - "href": "/consumers/c1b8648c-6f0a-4aa5-b34e-b9e62c0e4364", - "facts": {}, "id": "ff808081550d997c015511b0406d1065", - "uuid": "c1b8648c-6f0a-4aa5-b34e-b9e62c0e4364", - "guestIds": null, "capabilities": null, - "environments": null, "installedProducts": null, - "canActivate": false, "type": {"manifest": false, - "id": "1000", "label": "system"}, "annotations": null, - "username": "admin", "updated": "2016-06-02T15:16:51+0000", - "lastCheckin": null, "entitlementCount": 0, "releaseVer": - {"releaseVer": null}, "entitlementStatus": "valid", "name": - "test.example.com", "created": "2016-06-02T15:16:51+0000", - "contentTags": null, "dev": false}""" - OWNERS_CONTENT_JSON = """[ { "autobindDisabled": false, @@ -426,13 +235,6 @@ def setUp(self) -> None: self.patches["update"] = update_patch.start() self.addCleanup(update_patch.stop) - attach_auto_patch = mock.patch( - "rhsmlib.dbus.objects.register.AttachService.attach_auto", - name="attach_auto", - ) - self.patches["attach_auto"] = attach_auto_patch.start() - self.addCleanup(attach_auto_patch.stop) - build_uep_patch = mock.patch( "rhsmlib.dbus.base_object.BaseImplementation.build_uep", name="build_uep", @@ -442,7 +244,7 @@ def setUp(self) -> None: self.patches["update"].return_value = None def test_Register(self): - expected = json.loads(CONSUMER_CONTENT_JSON) + expected = json.loads(CONSUMER_CONTENT_JSON_SCA) self.patches["register"].return_value = expected self.patches["is_registered"].return_value = False @@ -452,7 +254,7 @@ def test_Register(self): self.assertEqual(expected, result) def test_Register__with_force_option(self): - expected = json.loads(CONSUMER_CONTENT_JSON) + expected = json.loads(CONSUMER_CONTENT_JSON_SCA) self.patches["register"].return_value = expected self.patches["unregister"].return_value = None self.patches["is_registered"].return_value = True @@ -463,7 +265,7 @@ def test_Register__with_force_option(self): self.assertEqual(expected, result) def test_Register__already_registered(self): - expected = json.loads(CONSUMER_CONTENT_JSON) + expected = json.loads(CONSUMER_CONTENT_JSON_SCA) self.patches["register"].return_value = expected self.patches["unregister"].return_value = None self.patches["is_registered"].return_value = True @@ -473,9 +275,8 @@ def test_Register__already_registered(self): def test_Register__enable_content(self): """Test including 'enable_content' in entitlement mode with no content.""" - expected = json.loads(CONSUMER_CONTENT_JSON) + expected = json.loads(CONSUMER_CONTENT_JSON_SCA) self.patches["register"].return_value = expected - self.patches["attach_auto"].return_value = [] self.patches["is_registered"].return_value = False result = self.impl.register_with_credentials( @@ -483,18 +284,6 @@ def test_Register__enable_content(self): ) self.assertEqual(expected, result) - def test_Register__enable_content_with_content(self): - """Test including 'enable_content' in entitlement mode with some content.""" - expected = json.loads(ENABLED_CONTENT) - self.patches["register"].return_value = json.loads(CONSUMER_CONTENT_JSON) - self.patches["attach_auto"].return_value = expected - self.patches["is_registered"].return_value = False - - result = self.impl.register_with_credentials( - "org", {"username": "username", "password": "password", "enable_content": "1"}, {} - ) - self.assertEqual(expected, result["enabledContent"]) - def test_Register__enable_content__sca(self): """Test including 'enable_content' in SCA mode.""" expected = json.loads(CONSUMER_CONTENT_JSON_SCA) @@ -520,7 +309,7 @@ def test_GetOrgs(self): self.assertEqual(expected, result) def test_RegisterWithActivationKeys(self): - expected = json.loads(CONSUMER_CONTENT_JSON) + expected = json.loads(CONSUMER_CONTENT_JSON_SCA) self.patches["is_registered"].return_value = False self.patches["register"].return_value = expected @@ -532,7 +321,7 @@ def test_RegisterWithActivationKeys(self): self.assertEqual(expected, result) def test_RegisterWithActivationKeys__already_registered(self): - expected = json.loads(CONSUMER_CONTENT_JSON) + expected = json.loads(CONSUMER_CONTENT_JSON_SCA) self.patches["is_registered"].return_value = True self.patches["register"].return_value = expected @@ -544,7 +333,7 @@ def test_RegisterWithActivationKeys__already_registered(self): ) def test_RegisterWithActivationKeys__with_force_option(self): - expected = json.loads(CONSUMER_CONTENT_JSON) + expected = json.loads(CONSUMER_CONTENT_JSON_SCA) self.patches["is_registered"].return_value = True self.patches["unregister"].return_value = None self.patches["register"].return_value = expected