Ejemplo n.º 1
0
 def test_get_cnames_for(self):
     def _load():
         return yaml.load(TEST_NET)
     with patch.dict(self._salt, {
         'mc_utils.uniquify': mc_utils.uniquify,
         'mc_utils.dictupdate': mc_utils.dictupdate,
         'mc_pillar.loaddb_do': _load,
         'mc_pillar.query': mc_pillar.query,
         'mc_pillar.load_db': mc_pillar.load_db,
         'mc_pillar.get_sysadmins_keys': mc_pillar.get_sysadmins_keys,
         'mc_pillar.ips_for': mc_pillar.ips_for,
         'mc_pillar.ip_for': mc_pillar.ip_for,
     }):
         res = mc_pillar.rrs_cnames_for('makina-corpus.net')
         self.assertEqual(res,
                          '       boo.moo.makina-corpus.net.'
                          '  CNAME www.foo.fr.\n'
                          '       foo.moo.makina-corpus.net.'
                          '  CNAME a.makina-corpus.net.\n'
                          '       testb.makina-corpus.net.'
                          '  CNAME testa.makina-corpus.net.\n'
                          '       testc.makina-corpus.net.'
                          '  CNAME testb.makina-corpus.net.')
         self.assertEqual(mc_pillar.ip_for('testc.makina-corpus.net'),
                          '1.2.3.10')
Ejemplo n.º 2
0
 def test_get_ns_rr(self):
     def _load():
         return yaml.load(TEST_NET)
     with patch.dict(self._salt, {
         'mc_utils.uniquify': mc_utils.uniquify,
         'mc_pillar.loaddb_do': _load,
         'mc_pillar.query': mc_pillar.query,
         'mc_pillar.load_db': mc_pillar.load_db,
         'mc_utils.dictupdate': mc_utils.dictupdate,
         'mc_pillar.get_sysadmins_keys': mc_pillar.get_sysadmins_keys,
         'mc_pillar.ips_for': mc_pillar.ips_for,
         'mc_pillar.ip_for': mc_pillar.ip_for,
     }):
         res = mc_pillar.rrs_ns_for('makina-corpus.net')
         self.assertEqual(res, '       @ IN NS ns1.makina-corpus.net.')
         res = mc_pillar.rrs_ns_for('makina-corpus.com')
         self.assertEqual(res, '       @ IN NS ns1.makina-corpus.com.')
         ip1 = mc_pillar.ip_for('ns1.makina-corpus.net')
         ip3 = mc_pillar.ip_for('ns1.makina-corpus.fr')
         ip2 = mc_pillar.ip_for('ns2.makina-corpus.fr')
         self.assertEqual(ip1, '1.2.3.6')
         self.assertEqual(ip2, '1.2.3.6')
         self.assertEqual(ip3, '1.2.3.5')