コード例 #1
0
    def test_registration_with_failed_profile_upload(self):

        with patch("rhsm.connection.UEPConnection",
                   new_callable=StubUEP) as mock_uep:
            profile_mgr = inj.require(inj.PROFILE_MANAGER)

            def raise_remote_server_exception(*args, **kwargs):
                """Raise remote server exception (uploading of profile failed)"""
                from rhsm.connection import RemoteServerException

                raise RemoteServerException(
                    502,
                    request_type="PUT",
                    handler=
                    "/subscription/consumers/xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/profiles",
                )

            profile_mgr.update_check = Mock(
                side_effect=raise_remote_server_exception)
            self.stub_cp_provider.basic_auth_cp = mock_uep
            cmd = RegisterCommand()
            with Capture() as cap:
                cmd.main([
                    "--force", "--username", "admin", "--password", "admin",
                    "--org", "admin"
                ])
                output = cap.out
                self.assertTrue(
                    "The system has been registered with ID" in output)
                self.assertTrue("The registered system name is:" in output)
コード例 #2
0
 def test_registration(self):
     """
     Test normal registration (test of proper patching)
     """
     with patch('rhsm.connection.UEPConnection', new_callable=StubUEP) as mock_uep:
         self.stub_cp_provider.basic_auth_cp = mock_uep
         cmd = RegisterCommand()
         cmd.main(['register', '--force', '--username', 'admin', '--password', 'admin', '--org', 'admin'])
コード例 #3
0
    def test_activation_keys_updates_certs_and_repos(self, mock_entcertlib):
        self.stub_cp_provider.basic_auth_cp = Mock('rhsm.connection.UEPConnection', new_callable=StubUEP)
        self._inject_mock_invalid_consumer()

        cmd = RegisterCommand()
        mock_entcertlib = mock_entcertlib.return_value
        self._inject_ipm()

        cmd.main(['register', '--activationkey=test_key', '--org=test_org'])
        self.mock_register.register.assert_called_once()
        mock_entcertlib.update.assert_called_once()
コード例 #4
0
    def test_deprecate_consumer_type(self):
        with patch('rhsm.connection.UEPConnection', new_callable=StubUEP) as mock_uep:
            self.stub_cp_provider.basic_auth_cp = mock_uep

            cmd = RegisterCommand()
            self._inject_mock_invalid_consumer()

            with Capture(silent=True):
                with self.assertRaises(SystemExit) as e:
                    cmd.main(['register', '--type=candlepin'])
                    self.assertEqual(e.code, os.EX_USAGE)
コード例 #5
0
    def test_consumerid_updates_certs_and_repos(self, mock_entcertlib):
        self.stub_cp_provider.basic_auth_cp = Mock('rhsm.connection.UEPConnection', new_callable=StubUEP)
        self._inject_mock_invalid_consumer()

        cmd = RegisterCommand()
        mock_entcertlib = mock_entcertlib.return_value
        self._inject_ipm()

        cmd.main(['register', '--consumerid=123456', '--username=testuser1', '--password=password', '--org=test_org'])
        self.mock_register.register.assert_called_once_with(None, consumerid='123456')
        mock_entcertlib.update.assert_called_once()
コード例 #6
0
    def test_consumerid_with_distributor_id(self):
        self.stub_cp_provider.basic_auth_cp = Mock('rhsm.connection.UEPConnection', new_callable=StubUEP)

        self._inject_mock_invalid_consumer()
        cmd = RegisterCommand()
        self._inject_ipm()
        self.mock_register.register.side_effect = exceptions.ServiceError()

        with Capture(silent=True):
            with self.assertRaises(SystemExit) as e:
                cmd.main(['register', '--consumerid=TaylorSwift', '--username=testuser1', '--password=password', '--org=test_org'])
                self.assertEqual(e.code, os.EX_USAGE)