def update_content_hook(self, conduit): """ Hook to update for any Docker content we have. Args: conduit: An UpdateContentConduit """ conduit.log.info("Updating container content.") registry_hostnames = conduit.conf_string('main', 'registry_hostnames') conduit.log.info("registry hostnames = %s" % registry_hostnames) cmd = ContainerContentUpdateActionCommand( ent_source=conduit.ent_source, registry_hostnames=registry_hostnames.split(','), host_cert_dir=self.HOSTNAME_CERT_DIR) report = cmd.perform() conduit.reports.add(report)
def update_content_hook(self, conduit): """ Hook to update for any Docker content we have. Args: conduit: An UpdateContentConduit """ conduit.log.debug("Updating container content.") registry_hostnames = conduit.conf_string('main', 'registry_hostnames') conduit.log.debug("registry hostnames = %s" % registry_hostnames) cmd = ContainerContentUpdateActionCommand( ent_source=conduit.ent_source, registry_hostnames=registry_hostnames.split(','), host_cert_dir=self.HOSTNAME_CERT_DIR) report = cmd.perform() conduit.reports.add(report)
def test_multi_directory(self): host1 = 'hostname.example.org' host2 = 'hostname2.example.org' host3 = 'hostname3.example.org' self.assertFalse(exists(join(self.host_cert_dir, host1))) self.assertFalse(exists(join(self.host_cert_dir, host2))) self.assertFalse(exists(join(self.host_cert_dir, host3))) cmd = ContainerContentUpdateActionCommand(None, [host1, host2, host3], self.host_cert_dir) cmd._find_content = mock.Mock(return_value=[]) cmd.perform() self.assertTrue(exists(join(self.host_cert_dir, host1))) self.assertTrue(exists(join(self.host_cert_dir, host2))) self.assertTrue(exists(join(self.host_cert_dir, host3)))
def test_unique_paths_with_dupes(self): cert1 = self._mock_cert('5001') cert2 = self._mock_cert('5002') cert3 = self._mock_cert('5003') content1 = self._create_content('content1', cert1) content2 = self._create_content('content2', cert1) content3 = self._create_content('content3', cert2) # This content is provided by two other certs: content1_dupe = self._create_content('content1', cert2) content1_dupe2 = self._create_content('content1', cert3) contents = [content1, content2, content3, content1_dupe, content1_dupe2] cmd = ContainerContentUpdateActionCommand(None, ['cdn.example.org'], self.host_cert_dir) cert_paths = cmd._get_unique_paths(contents) self.assertEquals(3, len(cert_paths)) self.assertTrue(KeyPair(cert1.path, cert1.key_path()) in cert_paths) self.assertTrue(KeyPair(cert2.path, cert2.key_path()) in cert_paths) self.assertTrue(KeyPair(cert3.path, cert3.key_path()) in cert_paths)
def test_unique_paths_with_dupes(self): cert1 = self._mock_cert('5001') cert2 = self._mock_cert('5002') cert3 = self._mock_cert('5003') content1 = self._create_content('content1', cert1) content2 = self._create_content('content2', cert1) content3 = self._create_content('content3', cert2) # This content is provided by two other certs: content1_dupe = self._create_content('content1', cert2) content1_dupe2 = self._create_content('content1', cert3) contents = [ content1, content2, content3, content1_dupe, content1_dupe2 ] cmd = ContainerContentUpdateActionCommand(None, ['cdn.example.org'], self.host_cert_dir) cert_paths = cmd._get_unique_paths(contents) self.assertEqual(3, len(cert_paths)) self.assertTrue(KeyPair(cert1.path, cert1.key_path()) in cert_paths) self.assertTrue(KeyPair(cert2.path, cert2.key_path()) in cert_paths) self.assertTrue(KeyPair(cert3.path, cert3.key_path()) in cert_paths)