Пример #1
0
    def test_returns_opts_if_specified(self):
        """
        If ssl options are present then check that they are parsed and returned
        """
        options = MagicMock(
            return_value={
                "cluster": ["192.168.50.10", "192.168.50.11", "192.168.50.12"],
                "port": 9000,
                "ssl_options": {
                    "ca_certs": "/etc/ssl/certs/ca-bundle.trust.crt",
                    "ssl_version": "PROTOCOL_TLSv1",
                },
                "username": "******",
            }
        )

        with patch.dict(cassandra_cql.__salt__, {"config.option": options}):

            self.assertEqual(
                cassandra_cql._get_ssl_opts(),
                {  # pylint: disable=protected-access
                    "ca_certs": "/etc/ssl/certs/ca-bundle.trust.crt",
                    "ssl_version": ssl.PROTOCOL_TLSv1,
                },
            )  # pylint: disable=no-member
Пример #2
0
    def test_unspecified_opts(self):
        '''
        Check that it returns None when ssl opts aren't specified
        '''
        cassandra_cql.__salt__['config.option'] = lambda x: {}

        self.assertEqual(cassandra_cql._get_ssl_opts(),  # pylint: disable=protected-access
                         None)
Пример #3
0
    def test_invalid_protocol_version(self):
        '''
        Check that the protocol version is imported only if it isvalid
        '''
        cassandra_cql.cs_ = {
            'cluster': [
                '192.168.50.10', '192.168.50.11', '192.168.50.12'],
            'port': 9000,
            'ssl_options': {
                'ca_certs': '/etc/ssl/certs/ca-bundle.trust.crt',
                'ssl_version': 'Invalid'},
            'username': '******'}

        cassandra_cql.__salt__['config.option'] = lambda x: cassandra_cql.cs_

        with self.assertRaises(CommandExecutionError):
            cassandra_cql._get_ssl_opts()  # pylint: disable=protected-access
Пример #4
0
    def test_invalid_protocol_version(self):
        """
        Check that the protocol version is imported only if it isvalid
        """
        options = MagicMock(
            return_value={
                "cluster": ["192.168.50.10", "192.168.50.11", "192.168.50.12"],
                "port": 9000,
                "ssl_options": {
                    "ca_certs": "/etc/ssl/certs/ca-bundle.trust.crt",
                    "ssl_version": "Invalid",
                },
                "username": "******",
            })

        with patch.dict(cassandra_cql.__salt__, {"config.option": options}):
            with self.assertRaises(CommandExecutionError):
                cassandra_cql._get_ssl_opts()  # pylint: disable=protected-access
    def test_unspecified_opts(self):
        '''
        Check that it returns None when ssl opts aren't specified
        '''
        cassandra_cql.__salt__['config.option'] = lambda x: {}

        self.assertEqual(
            cassandra_cql._get_ssl_opts(),  # pylint: disable=protected-access
            None)
    def test_invalid_protocol_version(self):
        '''
        Check that the protocol version is imported only if it isvalid
        '''
        cassandra_cql.cs_ = {
            'cluster': ['192.168.50.10', '192.168.50.11', '192.168.50.12'],
            'port': 9000,
            'ssl_options': {
                'ca_certs': '/etc/ssl/certs/ca-bundle.trust.crt',
                'ssl_version': 'Invalid'
            },
            'username': '******'
        }

        cassandra_cql.__salt__['config.option'] = lambda x: cassandra_cql.cs_

        with self.assertRaises(CommandExecutionError):
            cassandra_cql._get_ssl_opts()  # pylint: disable=protected-access
Пример #7
0
 def test_unspecified_opts(self):
     '''
     Check that it returns None when ssl opts aren't specified
     '''
     with patch.dict(cassandra_cql.__salt__,
                     {'config.option': MagicMock(return_value={})}):
         self.assertEqual(
             cassandra_cql._get_ssl_opts(),  # pylint: disable=protected-access
             None)
Пример #8
0
    def test_returns_opts_if_specified(self):
        '''
        If ssl options are present then check that they are parsed and returned
        '''
        cassandra_cql.cs_ = {
            'cluster': [
                '192.168.50.10', '192.168.50.11', '192.168.50.12'],
            'port': 9000,
            'ssl_options': {
                'ca_certs': '/etc/ssl/certs/ca-bundle.trust.crt',
                'ssl_version': 'PROTOCOL_TLSv1'},
            'username': '******'}

        cassandra_cql.__salt__['config.option'] = lambda x: cassandra_cql.cs_

        self.assertEqual(cassandra_cql._get_ssl_opts(), {  # pylint: disable=protected-access
            'ca_certs': '/etc/ssl/certs/ca-bundle.trust.crt', 'ssl_version': ssl.PROTOCOL_TLSv1})  # pylint: disable=no-member
    def test_returns_opts_if_specified(self):
        '''
        If ssl options are present then check that they are parsed and returned
        '''
        cassandra_cql.cs_ = {
            'cluster': ['192.168.50.10', '192.168.50.11', '192.168.50.12'],
            'port': 9000,
            'ssl_options': {
                'ca_certs': '/etc/ssl/certs/ca-bundle.trust.crt',
                'ssl_version': 'PROTOCOL_TLSv1'
            },
            'username': '******'
        }

        cassandra_cql.__salt__['config.option'] = lambda x: cassandra_cql.cs_

        self.assertEqual(
            cassandra_cql._get_ssl_opts(),
            {  # pylint: disable=protected-access
                'ca_certs': '/etc/ssl/certs/ca-bundle.trust.crt',
                'ssl_version': ssl.PROTOCOL_TLSv1
            })  # pylint: disable=no-member