def test_trusted_filter_update_cache(self, req_mock): oat_data = { "hosts": [{ "host_name": "node1", "trust_lvl": "untrusted", "vtime": timeutils.isotime() }] } req_mock.return_value = requests.codes.OK, oat_data extra_specs = {'trust:trusted_host': 'untrusted'} filter_properties = { 'context': mock.sentinel.ctx, 'instance_type': { 'memory_mb': 1024, 'extra_specs': extra_specs } } host = fakes.FakeHostState('host1', 'node1', {}) self.filt_cls.host_passes(host, filter_properties) # Fill the caches req_mock.reset_mock() self.filt_cls.host_passes(host, filter_properties) self.assertFalse(req_mock.called) req_mock.reset_mock() timeutils.set_time_override(timeutils.utcnow()) timeutils.advance_time_seconds( CONF.trusted_computing.attestation_auth_timeout + 80) self.filt_cls.host_passes(host, filter_properties) self.assertTrue(req_mock.called) timeutils.clear_time_override()
def test_trusted_filter_update_cache(self, req_mock): oat_data = {"hosts": [{"host_name": "node1", "trust_lvl": "untrusted", "vtime": timeutils.isotime()}]} req_mock.return_value = requests.codes.OK, oat_data extra_specs = {'trust:trusted_host': 'untrusted'} filter_properties = {'context': mock.sentinel.ctx, 'instance_type': {'memory_mb': 1024, 'extra_specs': extra_specs}} host = fakes.FakeHostState('host1', 'node1', {}) self.filt_cls.host_passes(host, filter_properties) # Fill the caches req_mock.reset_mock() self.filt_cls.host_passes(host, filter_properties) self.assertFalse(req_mock.called) req_mock.reset_mock() timeutils.set_time_override(timeutils.utcnow()) timeutils.advance_time_seconds( CONF.trusted_computing.attestation_auth_timeout + 80) self.filt_cls.host_passes(host, filter_properties) self.assertTrue(req_mock.called) timeutils.clear_time_override()
def test_utcnow(self): timeutils.set_time_override(mock.sentinel.utcnow) self.assertEqual(timeutils.utcnow(), mock.sentinel.utcnow) timeutils.clear_time_override() self.assertFalse(timeutils.utcnow() == mock.sentinel.utcnow) self.assertTrue(timeutils.utcnow())
def tearDown(self): super(ServicesJsonTest, self).tearDown() timeutils.clear_time_override()
def tearDown(self): timeutils.clear_time_override() super(AuditPeriodTest, self).tearDown()
def tearDown(self): # pylint: disable=C0103 timeutils.clear_time_override() super(LockoutTestCase, self).tearDown()
def tearDown(self): timeutils.clear_time_override() super(LockoutTestCase, self).tearDown()
def tearDown(self): """tearDown method for simple tenant usage.""" super(SimpleTenantUsageSampleJsonTest, self).tearDown() timeutils.clear_time_override()
def tearDown(self): super(MuteWeigherTestClass, self).tearDown() timeutils.clear_time_override()
def tearDown(self): super(InstanceUsageAuditLogTestV21, self).tearDown() timeutils.clear_time_override()