Exemplo n.º 1
0
    def test_no_user(self):
        custom_fake_get = partial(fake_get, CONFIG)
        with mock.patch('pulp.server.async.celery_instance.config.get', new=custom_fake_get):
            result = celery_instance.create_mongo_config()

            self.assertTrue('user' not in result)
            self.assertTrue('password' not in result)
Exemplo n.º 2
0
    def test_ssl_false(self):
        """
        Assert that no SSL related flags are set if ssl is false.
        """
        result = celery_instance.create_mongo_config()

        for s in ('ssl', 'ssl_keyfile', 'ssl_certfile', 'ssl_cert_reqs', 'ssl_ca_certs'):
            self.assertTrue(s not in result)
Exemplo n.º 3
0
    def test_verify_ssl_true(self, getboolean):
        """
        Assert correct behavior when verify_ssl is True.
        """
        result = celery_instance.create_mongo_config()

        self.assertEqual(result['ssl'], True)
        self.assertEqual(result['ssl_cert_reqs'], ssl.CERT_REQUIRED)
Exemplo n.º 4
0
    def test_verify_ssl_false(self):
        """
        Assert correct behavior when verify_ssl is False.
        """
        result = celery_instance.create_mongo_config()

        self.assertEqual(result['ssl'], True)
        self.assertEqual(result['ssl_cert_reqs'], ssl.CERT_NONE)
Exemplo n.º 5
0
    def test_no_user(self):
        custom_fake_get = partial(fake_get, CONFIG)
        with mock.patch('pulp.server.async.celery_instance.config.get',
                        new=custom_fake_get):
            result = celery_instance.create_mongo_config()

            self.assertTrue('user' not in result)
            self.assertTrue('password' not in result)
Exemplo n.º 6
0
    def test_verify_ssl_true(self, getboolean):
        """
        Assert correct behavior when verify_ssl is True.
        """
        result = celery_instance.create_mongo_config()

        self.assertEqual(result['ssl'], True)
        self.assertEqual(result['ssl_cert_reqs'], ssl.CERT_REQUIRED)
Exemplo n.º 7
0
    def test_verify_ssl_false(self):
        """
        Assert correct behavior when verify_ssl is False.
        """
        result = celery_instance.create_mongo_config()

        self.assertEqual(result['ssl'], True)
        self.assertEqual(result['ssl_cert_reqs'], ssl.CERT_NONE)
Exemplo n.º 8
0
    def test_create_config_no_port(self):
        config = CONFIG.copy()
        config['seeds'] = 'host1'
        custom_fake_get = partial(fake_get, config)
        with mock.patch('pulp.server.async.celery_instance.config.get', new=custom_fake_get):
            result = celery_instance.create_mongo_config()

            self.assertEqual(result['host'], 'host1')
            self.assertTrue('port' not in result)
Exemplo n.º 9
0
    def test_create_config_one_seed(self):
        config = CONFIG.copy()
        config['seeds'] = config['seeds'].split(',')[0]
        custom_fake_get = partial(fake_get, config)
        with mock.patch('pulp.server.async.celery_instance.config.get', new=custom_fake_get):
            result = celery_instance.create_mongo_config()

            self.assertEqual(result['host'], 'host1')
            self.assertEqual(result['port'], '27017')
Exemplo n.º 10
0
    def test_ssl_false(self):
        """
        Assert that no SSL related flags are set if ssl is false.
        """
        result = celery_instance.create_mongo_config()

        for s in ('ssl', 'ssl_keyfile', 'ssl_certfile', 'ssl_cert_reqs',
                  'ssl_ca_certs'):
            self.assertTrue(s not in result)
Exemplo n.º 11
0
    def test_create_config_one_seed(self):
        config = CONFIG.copy()
        config['seeds'] = config['seeds'].split(',')[0]
        custom_fake_get = partial(fake_get, config)
        with mock.patch('pulp.server.async.celery_instance.config.get',
                        new=custom_fake_get):
            result = celery_instance.create_mongo_config()

            self.assertEqual(result['host'], 'host1')
            self.assertEqual(result['port'], '27017')
Exemplo n.º 12
0
    def test_create_config(self):
        custom_fake_get = partial(fake_get, CONFIG)
        with mock.patch('pulp.server.async.celery_instance.config.get', new=custom_fake_get):
            result = celery_instance.create_mongo_config()

            self.assertEqual(result['host'], 'host1')
            self.assertEqual(result['port'], '27017')
            self.assertEqual(result['database'], 'database_name')
            self.assertEqual(result['user'], 'someguy')
            self.assertEqual(result['password'], 'letmein')
Exemplo n.º 13
0
    def test_no_user(self):
        """
        Assert both user and password are missing mongo config if username is missing.
        """
        custom_fake_get = partial(fake_get, _get_database_test_config())
        with mock.patch('pulp.server.async.celery_instance.config.get', new=custom_fake_get):
            result = celery_instance.create_mongo_config()

            self.assertTrue('user' not in result)
            self.assertTrue('password' not in result)
Exemplo n.º 14
0
    def test_create_config_no_port(self):
        config = CONFIG.copy()
        config['seeds'] = 'host1'
        custom_fake_get = partial(fake_get, config)
        with mock.patch('pulp.server.async.celery_instance.config.get',
                        new=custom_fake_get):
            result = celery_instance.create_mongo_config()

            self.assertEqual(result['host'], 'host1')
            self.assertTrue('port' not in result)
Exemplo n.º 15
0
    def test_ssl_ca_path(self, getboolean):
        """
        Assert correct behavior when a ca_path is provided.
        """
        config = {'ca_path': '/some/ca.pem'}
        custom_fake_get = partial(fake_get, config)

        with mock.patch('pulp.server.async.celery_instance.config.get', new=custom_fake_get):
            result = celery_instance.create_mongo_config()

            self.assertEqual(result['ssl_ca_certs'], config['ca_path'])
Exemplo n.º 16
0
    def test_create_config(self):
        custom_fake_get = partial(fake_get, CONFIG)
        with mock.patch('pulp.server.async.celery_instance.config.get',
                        new=custom_fake_get):
            result = celery_instance.create_mongo_config()

            self.assertEqual(result['host'], 'host1')
            self.assertEqual(result['port'], '27017')
            self.assertEqual(result['database'], 'database_name')
            self.assertEqual(result['user'], 'someguy')
            self.assertEqual(result['password'], 'letmein')
Exemplo n.º 17
0
    def test_no_user(self):
        """
        Assert both user and password are missing mongo config if username is missing.
        """
        custom_fake_get = partial(fake_get, _get_database_test_config())
        with mock.patch('pulp.server.async.celery_instance.config.get',
                        new=custom_fake_get):
            result = celery_instance.create_mongo_config()

            self.assertTrue('user' not in result)
            self.assertTrue('password' not in result)
Exemplo n.º 18
0
    def test_ssl_client_cert_and_key(self, getboolean):
        """
        Assert correct behavior when a client cert and key are provided.
        """
        config = {'ssl_keyfile': '/some/file.key', 'ssl_certfile': '/some/file.crt'}
        custom_fake_get = partial(fake_get, config)

        with mock.patch('pulp.server.async.celery_instance.config.get', new=custom_fake_get):
            result = celery_instance.create_mongo_config()

            self.assertEqual(result['ssl_keyfile'], config['ssl_keyfile'])
            self.assertEqual(result['ssl_certfile'], config['ssl_certfile'])
Exemplo n.º 19
0
    def test_create_config_one_seed(self):
        """
        Assert that port and host are set on the mongo config with only one host:port specified.
        """
        config = _get_database_test_config()
        config['database']['seeds'] = config['database']['seeds'].split(',')[0]
        custom_fake_get = partial(fake_get, config)
        with mock.patch('pulp.server.async.celery_instance.config.get', new=custom_fake_get):
            result = celery_instance.create_mongo_config()

            self.assertEqual(result['host'], 'host1')
            self.assertEqual(result['port'], '27017')
Exemplo n.º 20
0
    def test_create_config_no_port(self):
        """
        Assert a seed that does not have a port does not set the port on the mongo config.
        """
        config = _get_database_test_config()
        config['database']['seeds'] = 'host1'
        custom_fake_get = partial(fake_get, config)
        with mock.patch('pulp.server.async.celery_instance.config.get', new=custom_fake_get):
            result = celery_instance.create_mongo_config()

            self.assertEqual(result['host'], 'host1')
            self.assertTrue('port' not in result)
Exemplo n.º 21
0
    def test_create_config(self):
        """
        Assert that the mongo config is created correctly with correct settings.
        """
        custom_fake_get = partial(fake_get, _get_database_test_config())
        with mock.patch('pulp.server.async.celery_instance.config.get', new=custom_fake_get):
            result = celery_instance.create_mongo_config()

            self.assertEqual(result['host'], 'host1')
            self.assertEqual(result['port'], '27017')
            self.assertEqual(result['database'], 'database_name')
            self.assertEqual(result['user'], 'someguy')
            self.assertEqual(result['password'], 'letmein')
Exemplo n.º 22
0
    def test_ssl_ca_path(self, getboolean):
        """
        Assert correct behavior when a ca_path is provided.
        """
        config = {'database': {'ca_path': '/some/ca.pem'}}
        custom_fake_get = partial(fake_get, config)

        with mock.patch('pulp.server.async.celery_instance.config.get',
                        new=custom_fake_get):
            result = celery_instance.create_mongo_config()

            self.assertEqual(result['ssl_ca_certs'],
                             config['database']['ca_path'])
Exemplo n.º 23
0
    def test_create_config_no_port(self):
        """
        Assert a seed that does not have a port does not set the port on the mongo config.
        """
        config = _get_database_test_config()
        config['database']['seeds'] = 'host1'
        custom_fake_get = partial(fake_get, config)
        with mock.patch('pulp.server.async.celery_instance.config.get',
                        new=custom_fake_get):
            result = celery_instance.create_mongo_config()

            self.assertEqual(result['host'], 'host1')
            self.assertTrue('port' not in result)
Exemplo n.º 24
0
    def test_create_config_one_seed(self):
        """
        Assert that port and host are set on the mongo config with only one host:port specified.
        """
        config = _get_database_test_config()
        config['database']['seeds'] = config['database']['seeds'].split(',')[0]
        custom_fake_get = partial(fake_get, config)
        with mock.patch('pulp.server.async.celery_instance.config.get',
                        new=custom_fake_get):
            result = celery_instance.create_mongo_config()

            self.assertEqual(result['host'], 'host1')
            self.assertEqual(result['port'], '27017')
Exemplo n.º 25
0
    def test_create_config(self):
        """
        Assert that the mongo config is created correctly with correct settings.
        """
        custom_fake_get = partial(fake_get, _get_database_test_config())
        with mock.patch('pulp.server.async.celery_instance.config.get',
                        new=custom_fake_get):
            result = celery_instance.create_mongo_config()

            self.assertEqual(result['host'], 'host1')
            self.assertEqual(result['port'], '27017')
            self.assertEqual(result['database'], 'database_name')
            self.assertEqual(result['user'], 'someguy')
            self.assertEqual(result['password'], 'letmein')
Exemplo n.º 26
0
    def test_ssl_client_cert_and_key(self, getboolean):
        """
        Assert correct behavior when a client cert and key are provided.
        """
        config = {
            'database': {
                'ssl_keyfile': '/some/file.key',
                'ssl_certfile': '/some/file.crt'
            }
        }
        custom_fake_get = partial(fake_get, config)

        with mock.patch('pulp.server.async.celery_instance.config.get',
                        new=custom_fake_get):
            result = celery_instance.create_mongo_config()

            self.assertEqual(result['ssl_keyfile'],
                             config['database']['ssl_keyfile'])
            self.assertEqual(result['ssl_certfile'],
                             config['database']['ssl_certfile'])