def test_unsubscribe_unregistered(self): connection.UEPConnection = StubUEP prod = StubProduct('stub_product') ent = StubEntitlementCertificate(prod) cmd = managercli.UnSubscribeCommand(ent_dir=StubEntitlementDirectory( [ent]), prod_dir=StubProductDirectory([])) managercli.ConsumerIdentity = StubConsumerIdentity StubConsumerIdentity.existsAndValid = classmethod(lambda cls: False) StubConsumerIdentity.exists = classmethod(lambda cls: False) cmd.main(['unsubscribe', '--all']) self.assertTrue(cmd.entitlement_dir.list_called) self.assertTrue(ent.is_deleted) prod = StubProduct('stub_product') ent1 = StubEntitlementCertificate(prod) ent2 = StubEntitlementCertificate(prod) cmd = managercli.UnSubscribeCommand(ent_dir=StubEntitlementDirectory( [ent1, ent2]), prod_dir=StubProductDirectory([])) managercli.ConsumerIdentity = StubConsumerIdentity StubConsumerIdentity.existsAndValid = classmethod(lambda cls: False) StubConsumerIdentity.exists = classmethod(lambda cls: False) cmd.main(['unsubscribe', '--serial=%s' % ent1.serial]) self.assertTrue(cmd.entitlement_dir.list_called) self.assertTrue(ent1.is_deleted) self.assertFalse(ent2.is_deleted)
def test_unsubscribe_unregistered(self): prod = StubProduct('stub_product') ent = StubEntitlementCertificate(prod) inj.provide(inj.ENT_DIR, StubEntitlementDirectory([ent])) inj.provide(inj.PROD_DIR, StubProductDirectory([])) cmd = managercli.UnSubscribeCommand() self._inject_mock_invalid_consumer() cmd.main(['unsubscribe', '--all']) self.assertTrue(cmd.entitlement_dir.list_called) self.assertTrue(ent.is_deleted) prod = StubProduct('stub_product') ent1 = StubEntitlementCertificate(prod) ent2 = StubEntitlementCertificate(prod) ent3 = StubEntitlementCertificate(prod) inj.provide(inj.ENT_DIR, StubEntitlementDirectory([ent1, ent2, ent3])) inj.provide(inj.PROD_DIR, StubProductDirectory([])) cmd = managercli.UnSubscribeCommand() code = cmd.main(['unsubscribe', '--serial=%s' % ent1.serial, '--serial=%s' % ent3.serial]) self.assertTrue(cmd.entitlement_dir.list_called) self.assertTrue(ent1.is_deleted) self.assertFalse(ent2.is_deleted) self.assertTrue(ent3.is_deleted) self.assertEquals(code, 0) code = cmd.main(['unsubscribe', '--serial=%s' % '33333333']) self.assertEquals(code, 1)
def test_unsubscribe_registered(self): prod = StubProduct('stub_product') ent1 = StubEntitlementCertificate(prod) ent2 = StubEntitlementCertificate(prod) ent3 = StubEntitlementCertificate(prod) inj.provide(inj.ENT_DIR, StubEntitlementDirectory([ent1, ent2, ent3])) inj.provide(inj.PROD_DIR, StubProductDirectory([])) cmd = managercli.UnSubscribeCommand() mock_identity = self._inject_mock_valid_consumer() managercli.EntCertActionInvoker = StubEntActionInvoker cmd.main(['unsubscribe', '--all']) self.assertEquals(cmd.cp.called_unbind_uuid, mock_identity.uuid) cmd.main(['unsubscribe', '--serial=%s' % ent1.serial]) self.assertEquals(cmd.cp.called_unbind_serial, ['%s' % ent1.serial]) code = cmd.main([ 'unsubscribe', '--serial=%s' % ent2.serial, '--serial=%s' % ent3.serial ]) self.assertEquals( cmd.cp.called_unbind_serial, ['%s' % ent2.serial, '%s' % ent3.serial]) self.assertEquals(code, 0) self.stub_cp_provider.get_consumer_auth_cp( ).unbindBySerial = mock.Mock(side_effect=connection.RestlibException( "Entitlement Certificate with serial number " "2300922701043065601 could not be found.")) code = cmd.main(['unsubscribe', '--serial=%s' % '2300922701043065601'])
def test_unsubscribe_unregistered(self): connection.UEPConnection = StubUEP prod = StubProduct('stub_product') ent = StubEntitlementCertificate(prod) inj.provide(inj.ENT_DIR, StubEntitlementDirectory([ent])) inj.provide(inj.PROD_DIR, StubProductDirectory([])) cmd = managercli.UnSubscribeCommand() managercli.ConsumerIdentity = StubConsumerIdentity StubConsumerIdentity.existsAndValid = classmethod(lambda cls: False) StubConsumerIdentity.exists = classmethod(lambda cls: False) cmd.main(['unsubscribe', '--all']) self.assertTrue(cmd.entitlement_dir.list_called) self.assertTrue(ent.is_deleted) prod = StubProduct('stub_product') ent1 = StubEntitlementCertificate(prod) ent2 = StubEntitlementCertificate(prod) ent3 = StubEntitlementCertificate(prod) inj.provide(inj.ENT_DIR, StubEntitlementDirectory([ent1, ent2, ent3])) inj.provide(inj.PROD_DIR, StubProductDirectory([])) cmd = managercli.UnSubscribeCommand() managercli.ConsumerIdentity = StubConsumerIdentity StubConsumerIdentity.existsAndValid = classmethod(lambda cls: False) StubConsumerIdentity.exists = classmethod(lambda cls: False) code = cmd.main([ 'unsubscribe', '--serial=%s' % ent1.serial, '--serial=%s' % ent3.serial ]) self.assertTrue(cmd.entitlement_dir.list_called) self.assertTrue(ent1.is_deleted) self.assertFalse(ent2.is_deleted) self.assertTrue(ent3.is_deleted) self.assertEquals(code, 0) code = cmd.main(['unsubscribe', '--serial=%s' % '33333333']) self.assertEquals(code, 1)
def test_unsubscribe_registered(self): connection.UEPConnection = StubUEP cmd = managercli.UnSubscribeCommand(ent_dir=StubEntitlementDirectory( []), prod_dir=StubProductDirectory([])) managercli.ConsumerIdentity = StubConsumerIdentity StubConsumerIdentity.existsAndValid = classmethod(lambda cls: True) StubConsumerIdentity.exists = classmethod(lambda cls: True) managercli.CertLib = StubCertLib cmd.main(['unsubscribe', '--all']) self.assertEquals(cmd.cp.called_unbind_uuid, StubConsumerIdentity.CONSUMER_ID) serial = '123456' cmd.main(['unsubscribe', '--serial=%s' % serial]) self.assertEquals(cmd.cp.called_unbind_serial, serial)
def test_unsubscribe_registered(self): connection.UEPConnection = StubUEP prod = StubProduct('stub_product') ent1 = StubEntitlementCertificate(prod) ent2 = StubEntitlementCertificate(prod) ent3 = StubEntitlementCertificate(prod) inj.provide(inj.ENT_DIR, StubEntitlementDirectory([ent1, ent2, ent3])) inj.provide(inj.PROD_DIR, StubProductDirectory([])) cmd = managercli.UnSubscribeCommand() managercli.ConsumerIdentity = StubConsumerIdentity StubConsumerIdentity.existsAndValid = classmethod(lambda cls: True) StubConsumerIdentity.exists = classmethod(lambda cls: True) managercli.CertLib = StubCertLib cmd.main(['unsubscribe', '--all']) self.assertEquals(cmd.cp.called_unbind_uuid, StubConsumerIdentity.CONSUMER_ID) cmd.main(['unsubscribe', '--serial=%s' % ent1.serial]) self.assertEquals(cmd.cp.called_unbind_serial, ['%s' % ent1.serial]) code = cmd.main([ 'unsubscribe', '--serial=%s' % ent2.serial, '--serial=%s' % ent3.serial ]) self.assertEquals( cmd.cp.called_unbind_serial, ['%s' % ent2.serial, '%s' % ent3.serial]) self.assertEquals(code, 0) connection.UEPConnection.unbindBySerial = mock.Mock( side_effect=connection.RestlibException( "Entitlement Certificate with serial number 2300922701043065601 could not be found." )) code = cmd.main(['unsubscribe', '--serial=%s' % '2300922701043065601']) self.assertEquals(code, 1)