コード例 #1
0
 def setUp(self):
     SubManFixture.setUp(self)
     self.status = json.loads(INST_PROD_STATUS)['installedProducts']
     self.prod_status_cache = NonCallableMock()
     self.prod_status_cache.load_status = Mock(return_value=self.status)
     inj.provide(inj.PROD_STATUS_CACHE, self.prod_status_cache)
     self.calculator = ValidProductDateRangeCalculator(None)
コード例 #2
0
 def setUp(self):
     SubManFixture.setUp(self)
     self.status = json.loads(INST_PROD_STATUS)['installedProducts']
     self.prod_status_cache = NonCallableMock()
     self.prod_status_cache.load_status = Mock(return_value=self.status)
     inj.provide(inj.PROD_STATUS_CACHE, self.prod_status_cache)
     self.calculator = ValidProductDateRangeCalculator(None)
コード例 #3
0
    def setUp(self, mock_update):
        SubManFixture.setUp(self)
        # Setup mock product and entitlement certs:
        self.prod_dir = StubProductDirectory(
            pids=[INST_PID_1, INST_PID_2, INST_PID_3, INST_PID_4])
        self.ent_dir = StubEntitlementDirectory([
            StubEntitlementCertificate(PROD_2, ent_id=ENT_ID_2),
            StubEntitlementCertificate(PROD_1, ent_id=ENT_ID_1),
            StubEntitlementCertificate(product=PROD_4,
                                       stacking_id=STACK_1,
                                       ent_id=ENT_ID_4),
            # entitled, but not installed
            StubEntitlementCertificate(StubProduct('not_installed_product',
                                                   name="Some Product"),
                                       ent_id="SomeSubId"),
        ])

        self.mock_uep = StubUEP()

        self.status_mgr = EntitlementStatusCache()
        self.status_mgr.load_status = Mock(return_value=SAMPLE_COMPLIANCE_JSON)
        self.status_mgr.write_cache = Mock()
        inj.provide(inj.ENTITLEMENT_STATUS_CACHE, self.status_mgr)
        inj.provide(inj.PROD_DIR, self.prod_dir)
        inj.provide(inj.ENT_DIR, self.ent_dir)
        self.sorter = CertSorter()
        self.sorter.is_registered = Mock(return_value=True)
コード例 #4
0
    def setUp(self, mock_update):
        SubManFixture.setUp(self)
        # Setup mock product and entitlement certs:
        self.prod_dir = StubProductDirectory(
                pids=[INST_PID_1, INST_PID_2, INST_PID_3, INST_PID_4])
        self.ent_dir = StubEntitlementDirectory([
            StubEntitlementCertificate(PROD_2,
                ent_id=ENT_ID_2),
            StubEntitlementCertificate(PROD_1,
                ent_id=ENT_ID_1),
            StubEntitlementCertificate(product=PROD_4,
                stacking_id=STACK_1,
                ent_id=ENT_ID_4),
            # entitled, but not installed
            StubEntitlementCertificate(StubProduct('not_installed_product',
                name="Some Product"),
                ent_id="SomeSubId"),
            ])

        self.mock_uep = StubUEP()

        self.status_mgr = EntitlementStatusCache()
        self.status_mgr.load_status = Mock(
                return_value=SAMPLE_COMPLIANCE_JSON)
        self.status_mgr.write_cache = Mock()
        inj.provide(inj.ENTITLEMENT_STATUS_CACHE, self.status_mgr)
        inj.provide(inj.PROD_DIR, self.prod_dir)
        inj.provide(inj.ENT_DIR, self.ent_dir)
        self.sorter = CertSorter()
        self.sorter.is_registered = Mock(return_value=True)
コード例 #5
0
    def setUp(self):
        SubManFixture.setUp(self)
        self.cc = self.command_class()
        # neuter the _do_command, since this is mostly
        # for testing arg parsing
        self._orig_do_command = self.cc._do_command
        self.cc._do_command = self._do_command
        self.cc.assert_should_be_registered = self._asert_should_be_registered

        # stub out uep
        managercli.connection.UEPConnection = self._uep_connection
        self.mock_stdout = MockStdout()
        self.mock_stderr = MockStderr()
        sys.stdout = self.mock_stdout
        sys.stderr = self.mock_stderr
コード例 #6
0
    def setUp(self):
        SubManFixture.setUp(self)
        self.cc = self.command_class()
        # neuter the _do_command, since this is mostly
        # for testing arg parsing
        self._orig_do_command = self.cc._do_command
        self.cc._do_command = self._do_command
        self.cc.assert_should_be_registered = self._asert_should_be_registered

        # stub out uep
        managercli.connection.UEPConnection = self._uep_connection
        self.mock_stdout = MockStdout()
        self.mock_stderr = MockStderr()
        sys.stdout = self.mock_stdout
        sys.stderr = self.mock_stderr
コード例 #7
0
    def setUp(self):
        SubManFixture.setUp(self)

        self.repo_lib = Mock()
        self.repo_lib.get_repos.return_value = []

        self.overrides_mock = Mock()
        self.overrides_mock.repo_lib = self.repo_lib
        self.overrides_mock.get_overrides.return_value = []

        backend = Mock()
        backend.overrides = self.overrides_mock

        self.dialog = RepositoriesDialog(backend, None)
        self.dialog.overrides_mock = self.overrides_mock
コード例 #8
0
    def setUp(self):
        SubManFixture.setUp(self)

        self.repo_lib = Mock()
        self.repo_lib.get_repos.return_value = []

        self.overrides_mock = Mock()
        self.overrides_mock.repo_lib = self.repo_lib
        self.overrides_mock.get_overrides.return_value = []

        backend = Mock()
        backend.overrides = self.overrides_mock

        self.dialog = RepositoriesDialog(backend, None)
        self.dialog.overrides_mock = self.overrides_mock
コード例 #9
0
    def setUp(self):
        SubManFixture.setUp(self)
        # we have to have a reference to the patchers
        self.patcher2 = mock.patch.object(certlib.UpdateAction, '_get_consumer_id')
        self.certlib_updateaction_getconsumerid = self.patcher2.start()

        self.patcher3 = mock.patch.object(repolib.UpdateAction, 'perform')
        self.repolib_updateaction_perform = self.patcher3.start()

        self.patcher4 = mock.patch('subscription_manager.factlib.ConsumerIdentity')
        self.factlib_consumeridentity = self.patcher4.start()

        self.patcher5 = mock.patch('subscription_manager.certlib.ConsumerIdentity')
        self.certlib_consumeridentity = self.patcher5.start()

        self.patcher6 = mock.patch('subscription_manager.managerlib.persist_consumer_cert')
        self.managerlib_persist_consumer_cert = self.patcher6.start()

        self.patcher8 = mock.patch.object(facts.Facts, 'get_last_update')
        self.facts_getlastupdate = self.patcher8.start()

        # mock out all hardware fetching... we may need to fake socket counts
        self.hwprobe_getall_patcher = mock.patch.object(hwprobe.Hardware, 'get_all')
        self.hwprobe_getall_mock = self.hwprobe_getall_patcher.start()
        self.hwprobe_getall_mock.return_value = {}

        self.patcher_certlib_writer = mock.patch("subscription_manager.certlib.Writer")
        self.certlib_writer = self.patcher_certlib_writer.start()

        self.patcher_certlib_action_syslogreport = mock.patch.object(certlib.UpdateAction, 'syslog_results')
        self.update_action_syslog_mock = self.patcher_certlib_action_syslogreport.start()

        # some stub certs
        stub_product = stubs.StubProduct('stub_product')
        self.stub_ent1 = stubs.StubEntitlementCertificate(stub_product)
        self.stub_ent2 = stubs.StubEntitlementCertificate(stub_product)
        self.stub_ent_expires_tomorrow = \
            stubs.StubEntitlementCertificate(stub_product,
                                             end_date=datetime.now() + timedelta(days=1))

        self.stub_ent_expires_tomorrow_entdir = \
            stubs.StubEntitlementDirectory([self.stub_ent_expires_tomorrow])

        self.local_ent_certs = [self.stub_ent1, self.stub_ent2]
        self.stub_entitled_proddir = \
            stubs.StubProductDirectory([stubs.StubProductCertificate(stub_product)])

        # local entitlement dir
        self.stub_entdir = stubs.StubEntitlementDirectory(self.local_ent_certs)
        inj.provide(inj.ENT_DIR, self.stub_entdir)

        self.mock_uep = mock.Mock()
        self.mock_uep.getCertificateSerials = mock.Mock(return_value=[{'serial': self.stub_ent1.serial},
                                                                        {'serial': self.stub_ent2.serial}])
        self.mock_uep.getConsumer = mock.Mock(return_value=CONSUMER_DATA)

        self.certlib_updateaction_getconsumerid.return_value = "234234"

        self.repolib_updateaction_perform.return_value = 0
        self.facts_getlastupdate.return_value = None

        self.factlib_consumeridentity.read.return_value = stubs.StubConsumerIdentity("sdfsdf", "sdfsdf")
        self.certlib_consumeridentity.read.return_value = stubs.StubConsumerIdentity("sdfsdf", "sdfsdf")

        # Setup a mock cert sorter to initiate the behaviour we want to test.
        # Must use a non-callable mock for our features dep injection
        # framework.
        self.mock_cert_sorter = mock.NonCallableMock()

        injection.provide(injection.CERT_SORTER, self.mock_cert_sorter)
コード例 #10
0
    def setUp(self):
        SubManFixture.setUp(self)
        # we have to have a reference to the patchers
        # self.patcher2 = mock.patch.object(entcertlib.EntCertUpdateAction, '_get_consumer_id')
        # self.entcertlib_updateaction_getconsumerid = self.patcher2.start()

        self.patcher3 = mock.patch.object(repolib.RepoUpdateActionCommand, "perform")
        self.repolib_updateaction_perform = self.patcher3.start()

        self.patcher6 = mock.patch("subscription_manager.managerlib.persist_consumer_cert")
        self.managerlib_persist_consumer_cert = self.patcher6.start()

        # mock out all hardware fetching... we may need to fake socket counts
        self.hwprobe_getall_patcher = mock.patch.object(hwprobe.Hardware, "get_all")
        self.hwprobe_getall_mock = self.hwprobe_getall_patcher.start()
        self.hwprobe_getall_mock.return_value = {}

        self.patcher_entcertlib_writer = mock.patch("subscription_manager.entcertlib.Writer")
        self.entcertlib_writer = self.patcher_entcertlib_writer.start()

        self.patcher_entcertlib_action_syslogreport = mock.patch.object(
            entcertlib.EntCertUpdateAction, "syslog_results"
        )
        self.update_action_syslog_mock = self.patcher_entcertlib_action_syslogreport.start()

        # some stub certs
        stub_product = stubs.StubProduct("stub_product")
        self.stub_ent1 = stubs.StubEntitlementCertificate(stub_product)
        self.stub_ent2 = stubs.StubEntitlementCertificate(stub_product)
        self.stub_ent_expires_tomorrow = stubs.StubEntitlementCertificate(
            stub_product, end_date=datetime.now() + timedelta(days=1)
        )

        self.stub_ent_expires_tomorrow_ent_dir = stubs.StubEntitlementDirectory([self.stub_ent_expires_tomorrow])

        self.local_ent_certs = [self.stub_ent1, self.stub_ent2]
        self.stub_entitled_proddir = stubs.StubProductDirectory([stubs.StubProductCertificate(stub_product)])

        # local entitlement dir
        self.stub_ent_dir = stubs.StubEntitlementDirectory(self.local_ent_certs)
        inj.provide(inj.ENT_DIR, self.stub_ent_dir)

        self.mock_uep = mock.Mock()
        self.mock_uep.getCertificateSerials = mock.Mock(
            return_value=[{"serial": self.stub_ent1.serial}, {"serial": self.stub_ent2.serial}]
        )
        self.mock_uep.getConsumer = mock.Mock(return_value=CONSUMER_DATA)
        self.set_consumer_auth_cp(self.mock_uep)

        stub_release = {"releaseVer": "6.4"}
        self.mock_uep.getRelease = mock.Mock(return_value=stub_release)

        # we need to mock the consumers uuid with the mocked GoneExceptions
        # uuid
        self._inject_mock_valid_consumer(uuid="234234")

        self.repolib_updateaction_perform.return_value = 0

        # Setup a mock cert sorter to initiate the behaviour we want to test.
        # Must use a non-callable mock for our features dep injection
        # framework.
        self.mock_cert_sorter = mock.NonCallableMock()

        # TODO: need to provide return for "getRelease" for repolib stuff

        injection.provide(injection.CERT_SORTER, self.mock_cert_sorter)
コード例 #11
0
 def setUp(self):
     SubManFixture.setUp(self)
     self.oldCI = managercli.ConsumerIdentity
コード例 #12
0
    def setUp(self):
        SubManFixture.setUp(self)
        # we have to have a reference to the patchers
        self.patcher2 = mock.patch.object(certlib.UpdateAction,
                                          '_get_consumer_id')
        self.certlib_updateaction_getconsumerid = self.patcher2.start()

        self.patcher3 = mock.patch.object(repolib.UpdateAction, 'perform')
        self.repolib_updateaction_perform = self.patcher3.start()

        self.patcher4 = mock.patch(
            'subscription_manager.factlib.ConsumerIdentity')
        self.factlib_consumeridentity = self.patcher4.start()

        self.patcher5 = mock.patch(
            'subscription_manager.certlib.ConsumerIdentity')
        self.certlib_consumeridentity = self.patcher5.start()

        self.patcher6 = mock.patch(
            'subscription_manager.managerlib.persist_consumer_cert')
        self.managerlib_persist_consumer_cert = self.patcher6.start()

        self.patcher8 = mock.patch.object(facts.Facts, 'get_last_update')
        self.facts_getlastupdate = self.patcher8.start()

        # mock out all hardware fetching... we may need to fake socket counts
        self.hwprobe_getall_patcher = mock.patch.object(
            hwprobe.Hardware, 'get_all')
        self.hwprobe_getall_mock = self.hwprobe_getall_patcher.start()
        self.hwprobe_getall_mock.return_value = {}

        self.patcher_certlib_writer = mock.patch(
            "subscription_manager.certlib.Writer")
        self.certlib_writer = self.patcher_certlib_writer.start()

        self.patcher_certlib_action_syslogreport = mock.patch.object(
            certlib.UpdateAction, 'syslog_results')
        self.update_action_syslog_mock = self.patcher_certlib_action_syslogreport.start(
        )

        # some stub certs
        stub_product = stubs.StubProduct('stub_product')
        self.stub_ent1 = stubs.StubEntitlementCertificate(stub_product)
        self.stub_ent2 = stubs.StubEntitlementCertificate(stub_product)
        self.stub_ent_expires_tomorrow = \
            stubs.StubEntitlementCertificate(stub_product,
                                             end_date=datetime.now() + timedelta(days=1))

        self.stub_ent_expires_tomorrow_entdir = \
            stubs.StubEntitlementDirectory([self.stub_ent_expires_tomorrow])

        self.local_ent_certs = [self.stub_ent1, self.stub_ent2]
        self.stub_entitled_proddir = \
            stubs.StubProductDirectory([stubs.StubProductCertificate(stub_product)])

        # local entitlement dir
        self.stub_entdir = stubs.StubEntitlementDirectory(self.local_ent_certs)
        inj.provide(inj.ENT_DIR, self.stub_entdir)

        self.mock_uep = mock.Mock()
        self.mock_uep.getCertificateSerials = mock.Mock(
            return_value=[{
                'serial': self.stub_ent1.serial
            }, {
                'serial': self.stub_ent2.serial
            }])
        self.mock_uep.getConsumer = mock.Mock(return_value=CONSUMER_DATA)

        self.certlib_updateaction_getconsumerid.return_value = "234234"

        self.repolib_updateaction_perform.return_value = 0
        self.facts_getlastupdate.return_value = None

        self.factlib_consumeridentity.read.return_value = stubs.StubConsumerIdentity(
            "sdfsdf", "sdfsdf")
        self.certlib_consumeridentity.read.return_value = stubs.StubConsumerIdentity(
            "sdfsdf", "sdfsdf")

        # Setup a mock cert sorter to initiate the behaviour we want to test.
        # Must use a non-callable mock for our features dep injection
        # framework.
        self.mock_cert_sorter = mock.NonCallableMock()

        injection.provide(injection.CERT_SORTER, self.mock_cert_sorter)
コード例 #13
0
 def setUp(self):
     SubManFixture.setUp(self)
     self.nc = networkConfig.NetworkConfigDialog()
     self.stubConfig = stubs.StubConfig()
コード例 #14
0
 def setUp(self):
     SubManFixture.setUp(self)
     self.nc = networkConfig.NetworkConfigDialog()
     self.stubConfig = stubs.StubConfig()
コード例 #15
0
 def setUp(self):
     SubManFixture.setUp(self)
     self.prod_dir = stubs.StubProductDirectory([])
     self.prod_db_mock = Mock()
     self.prod_mgr = productid.ProductManager(product_dir=self.prod_dir,
                                              product_db=self.prod_db_mock)
コード例 #16
0
 def setUp(self):
     SubManFixture.setUp(self)
     sys.stdout = stubs.MockStdout()
     sys.stderr = stubs.MockStderr()
コード例 #17
0
    def setUp(self):
        SubManFixture.setUp(self)
        # we have to have a reference to the patchers
        #self.patcher2 = mock.patch.object(entcertlib.EntCertUpdateAction, '_get_consumer_id')
        #self.entcertlib_updateaction_getconsumerid = self.patcher2.start()

        self.patcher3 = mock.patch.object(repolib.RepoUpdateActionCommand,
                                          'perform')
        self.repolib_updateaction_perform = self.patcher3.start()

        self.patcher6 = mock.patch(
            'subscription_manager.managerlib.persist_consumer_cert')
        self.managerlib_persist_consumer_cert = self.patcher6.start()

        # mock out all hardware fetching... we may need to fake socket counts
        self.hwprobe_getall_patcher = mock.patch.object(
            hwprobe.Hardware, 'get_all')
        self.hwprobe_getall_mock = self.hwprobe_getall_patcher.start()
        self.hwprobe_getall_mock.return_value = {}

        self.patcher_entcertlib_writer = mock.patch(
            "subscription_manager.entcertlib.Writer")
        self.entcertlib_writer = self.patcher_entcertlib_writer.start()

        self.patcher_entcertlib_action_syslogreport = mock.patch.object(
            entcertlib.EntCertUpdateAction, 'syslog_results')
        self.update_action_syslog_mock = self.patcher_entcertlib_action_syslogreport.start(
        )

        # some stub certs
        stub_product = stubs.StubProduct('stub_product')
        self.stub_ent1 = stubs.StubEntitlementCertificate(stub_product)
        self.stub_ent2 = stubs.StubEntitlementCertificate(stub_product)
        self.stub_ent_expires_tomorrow = \
            stubs.StubEntitlementCertificate(stub_product,
                                             end_date=datetime.now() + timedelta(days=1))

        self.stub_ent_expires_tomorrow_ent_dir = \
            stubs.StubEntitlementDirectory([self.stub_ent_expires_tomorrow])

        self.local_ent_certs = [self.stub_ent1, self.stub_ent2]
        self.stub_entitled_proddir = \
            stubs.StubProductDirectory([stubs.StubProductCertificate(stub_product)])

        # local entitlement dir
        self.stub_ent_dir = stubs.StubEntitlementDirectory(
            self.local_ent_certs)
        inj.provide(inj.ENT_DIR, self.stub_ent_dir)

        self.mock_uep = mock.Mock()
        self.mock_uep.getCertificateSerials = mock.Mock(
            return_value=[{
                'serial': self.stub_ent1.serial
            }, {
                'serial': self.stub_ent2.serial
            }])
        self.mock_uep.getConsumer = mock.Mock(return_value=CONSUMER_DATA)
        self.set_consumer_auth_cp(self.mock_uep)

        stub_release = {'releaseVer': '6.4'}
        self.mock_uep.getRelease = mock.Mock(return_value=stub_release)

        # we need to mock the consumers uuid with the mocked GoneExceptions
        # uuid
        self._inject_mock_valid_consumer(uuid="234234")

        self.repolib_updateaction_perform.return_value = 0

        # Setup a mock cert sorter to initiate the behaviour we want to test.
        # Must use a non-callable mock for our features dep injection
        # framework.
        self.mock_cert_sorter = mock.NonCallableMock()

        # TODO: need to provide return for "getRelease" for repolib stuff

        injection.provide(injection.CERT_SORTER, self.mock_cert_sorter)
コード例 #18
0
 def setUp(self):
     SubManFixture.setUp(self)
     self.stubConfig = stubs.StubConfig()
コード例 #19
0
 def setUp(self):
     SubManFixture.setUp(self)
     self.prod_dir = stubs.StubProductDirectory([])
     self.prod_db_mock = Mock()
     self.prod_mgr = productid.ProductManager(product_dir=self.prod_dir,
             product_db=self.prod_db_mock)
コード例 #20
0
 def setUp(self):
     SubManFixture.setUp(self)
     sys.stderr = stubs.MockStderr()
コード例 #21
0
 def setUp(self):
     SubManFixture.setUp(self)
     self.overrides = Overrides()