class TestCertGeneration(TestCase): def setUp(self): self.tmpdir = tempfile.mkdtemp() config = AmbariConfig.AmbariConfig() #config.add_section('server') config.set('server', 'hostname', 'example.com') config.set('server', 'url_port', '777') #config.add_section('security') config.set('security', 'keysdir', self.tmpdir) config.set('security', 'server_crt', 'ca.crt') self.certMan = CertificateManager(config) def test_generation(self): self.certMan.genAgentCrtReq() self.assertTrue(os.path.exists(self.certMan.getAgentKeyName())) self.assertTrue(os.path.exists(self.certMan.getAgentCrtReqName())) def tearDown(self): shutil.rmtree(self.tmpdir)
class TestCertGeneration(TestCase): @patch.object(OSCheck, "os_distribution", new = MagicMock(return_value = os_distro_value)) def setUp(self): self.tmpdir = tempfile.mkdtemp() config = AmbariConfig.AmbariConfig() #config.add_section('server') config.set('server', 'hostname', 'example.com') config.set('server', 'url_port', '777') #config.add_section('security') config.set('security', 'keysdir', self.tmpdir) config.set('security', 'server_crt', 'ca.crt') self.certMan = CertificateManager(config) @patch.object(os, "chmod") def test_generation(self, chmod_mock): self.certMan.genAgentCrtReq('/dummy_dir/hostname.key') self.assertTrue(chmod_mock.called) self.assertTrue(os.path.exists(self.certMan.getAgentKeyName())) self.assertTrue(os.path.exists(self.certMan.getAgentCrtReqName())) def tearDown(self): shutil.rmtree(self.tmpdir)
class TestCertGeneration(TestCase): @patch.object(OSCheck, "os_distribution", new=MagicMock(return_value=os_distro_value)) def setUp(self): self.tmpdir = tempfile.mkdtemp() config = AmbariConfig.AmbariConfig() #config.add_section('server') config.set('server', 'hostname', 'example.com') config.set('server', 'url_port', '777') #config.add_section('security') config.set('security', 'keysdir', self.tmpdir) config.set('security', 'server_crt', 'ca.crt') self.certMan = CertificateManager(config) @patch.object(os, "chmod") def test_generation(self, chmod_mock): self.certMan.genAgentCrtReq('/dummy_dir/hostname.key') self.assertTrue(chmod_mock.called) self.assertTrue(os.path.exists(self.certMan.getAgentKeyName())) self.assertTrue(os.path.exists(self.certMan.getAgentCrtReqName())) def tearDown(self): shutil.rmtree(self.tmpdir)