def test_certificats_written(self):
        # check public-cert and private-cert keys in config get written
        cfg = {'loglevel': 'debug',
               'public-cert': "this is my public-certificate",
               'private-cert': "secret private certificate"}

        cc_mcollective.configure(config=cfg,
            server_cfg=self.server_cfg, pricert_file=self.pricert_file,
            pubcert_file=self.pubcert_file)

        found = configobj.ConfigObj(self.server_cfg)

        # make sure these didnt get written in
        self.assertFalse('public-cert' in found)
        self.assertFalse('private-cert' in found)

        # these need updating to the specified paths
        self.assertEqual(found['plugin.ssl_server_public'], self.pubcert_file)
        self.assertEqual(found['plugin.ssl_server_private'], self.pricert_file)

        # and the security provider should be ssl
        self.assertEqual(found['securityprovider'], 'ssl')

        self.assertEqual(
            util.load_file(self.pricert_file), cfg['private-cert'])
        self.assertEqual(
            util.load_file(self.pubcert_file), cfg['public-cert'])
 def test_existing_config_is_saved(self):
     cfg = {'loglevel': 'warn'}
     util.write_file(self.server_cfg, STOCK_CONFIG)
     cc_mcollective.configure(config=cfg, server_cfg=self.server_cfg)
     self.assertTrue(os.path.exists(self.server_cfg))
     self.assertTrue(os.path.exists(self.server_cfg + ".old"))
     self.assertEqual(util.load_file(self.server_cfg + ".old"), STOCK_CONFIG)
Esempio n. 3
0
    def test_certificats_written(self):
        # check public-cert and private-cert keys in config get written
        cfg = {'loglevel': 'debug',
               'public-cert': "this is my public-certificate",
               'private-cert': "secret private certificate"}

        cc_mcollective.configure(
            config=cfg, server_cfg=self.server_cfg,
            pricert_file=self.pricert_file, pubcert_file=self.pubcert_file)

        found = configobj.ConfigObj(self.server_cfg)

        # make sure these didnt get written in
        self.assertFalse('public-cert' in found)
        self.assertFalse('private-cert' in found)

        # these need updating to the specified paths
        self.assertEqual(found['plugin.ssl_server_public'], self.pubcert_file)
        self.assertEqual(found['plugin.ssl_server_private'], self.pricert_file)

        # and the security provider should be ssl
        self.assertEqual(found['securityprovider'], 'ssl')

        self.assertEqual(
            util.load_file(self.pricert_file), cfg['private-cert'])
        self.assertEqual(
            util.load_file(self.pubcert_file), cfg['public-cert'])
    def test_basic_config(self):
        cfg = {
            'mcollective': {
                'conf': {
                    'loglevel': 'debug',
                    'connector': 'rabbitmq',
                    'logfile': '/var/log/mcollective.log',
                    'ttl': '4294957',
                    'collectives': 'mcollective',
                    'main_collective': 'mcollective',
                    'securityprovider': 'psk',
                    'daemonize': '1',
                    'factsource': 'yaml',
                    'direct_addressing': '1',
                    'plugin.psk': 'unset',
                    'libdir': '/usr/share/mcollective/plugins',
                    'identity': '1',
                },
            },
        }
        expected = cfg['mcollective']['conf']

        self.patchUtils(self.tmp)
        cc_mcollective.configure(cfg['mcollective']['conf'])
        contents = util.load_file(cc_mcollective.SERVER_CFG, decode=False)
        contents = configobj.ConfigObj(BytesIO(contents))
        self.assertEqual(expected, dict(contents))
Esempio n. 5
0
    def test_basic_config(self):
        cfg = {
            'mcollective': {
                'conf': {
                    'loglevel': 'debug',
                    'connector': 'rabbitmq',
                    'logfile': '/var/log/mcollective.log',
                    'ttl': '4294957',
                    'collectives': 'mcollective',
                    'main_collective': 'mcollective',
                    'securityprovider': 'psk',
                    'daemonize': '1',
                    'factsource': 'yaml',
                    'direct_addressing': '1',
                    'plugin.psk': 'unset',
                    'libdir': '/usr/share/mcollective/plugins',
                    'identity': '1',
                },
            },
        }
        expected = cfg['mcollective']['conf']

        self.patchUtils(self.tmp)
        cc_mcollective.configure(cfg['mcollective']['conf'])
        contents = util.load_file(cc_mcollective.SERVER_CFG, decode=False)
        contents = configobj.ConfigObj(BytesIO(contents))
        self.assertEqual(expected, dict(contents))
Esempio n. 6
0
    def test_basic_config(self):
        cfg = {
            "mcollective": {
                "conf": {
                    "loglevel": "debug",
                    "connector": "rabbitmq",
                    "logfile": "/var/log/mcollective.log",
                    "ttl": "4294957",
                    "collectives": "mcollective",
                    "main_collective": "mcollective",
                    "securityprovider": "psk",
                    "daemonize": "1",
                    "factsource": "yaml",
                    "direct_addressing": "1",
                    "plugin.psk": "unset",
                    "libdir": "/usr/share/mcollective/plugins",
                    "identity": "1",
                },
            },
        }
        expected = cfg["mcollective"]["conf"]

        self.patchUtils(self.tmp)
        cc_mcollective.configure(cfg["mcollective"]["conf"])
        contents = util.load_file(cc_mcollective.SERVER_CFG, decode=False)
        contents = configobj.ConfigObj(BytesIO(contents))
        self.assertEqual(expected, dict(contents))
Esempio n. 7
0
    def test_certificats_written(self):
        # check public-cert and private-cert keys in config get written
        cfg = {
            "loglevel": "debug",
            "public-cert": "this is my public-certificate",
            "private-cert": "secret private certificate",
        }

        cc_mcollective.configure(
            config=cfg,
            server_cfg=self.server_cfg,
            pricert_file=self.pricert_file,
            pubcert_file=self.pubcert_file,
        )

        found = configobj.ConfigObj(self.server_cfg)

        # make sure these didnt get written in
        self.assertFalse("public-cert" in found)
        self.assertFalse("private-cert" in found)

        # these need updating to the specified paths
        self.assertEqual(found["plugin.ssl_server_public"], self.pubcert_file)
        self.assertEqual(found["plugin.ssl_server_private"], self.pricert_file)

        # and the security provider should be ssl
        self.assertEqual(found["securityprovider"], "ssl")

        self.assertEqual(
            util.load_file(self.pricert_file), cfg["private-cert"]
        )
        self.assertEqual(util.load_file(self.pubcert_file), cfg["public-cert"])
Esempio n. 8
0
 def test_existing_config_is_saved(self):
     cfg = {'loglevel': 'warn'}
     util.write_file(self.server_cfg, STOCK_CONFIG)
     cc_mcollective.configure(config=cfg, server_cfg=self.server_cfg)
     self.assertTrue(os.path.exists(self.server_cfg))
     self.assertTrue(os.path.exists(self.server_cfg + ".old"))
     self.assertEqual(util.load_file(self.server_cfg + ".old"),
                      STOCK_CONFIG)
 def test_existing_updated(self):
     cfg = {'loglevel': 'warn'}
     util.write_file(self.server_cfg, STOCK_CONFIG)
     cc_mcollective.configure(config=cfg, server_cfg=self.server_cfg)
     cfgobj = configobj.ConfigObj(self.server_cfg)
     self.assertEqual(cfg['loglevel'], cfgobj['loglevel'])
Esempio n. 10
0
 def test_existing_updated(self):
     cfg = {'loglevel': 'warn'}
     util.write_file(self.server_cfg, STOCK_CONFIG)
     cc_mcollective.configure(config=cfg, server_cfg=self.server_cfg)
     cfgobj = configobj.ConfigObj(self.server_cfg)
     self.assertEqual(cfg['loglevel'], cfgobj['loglevel'])