Exemplo n.º 1
0
    def test_controller_authentication(self):
        jboss7_cli.run_operation(self.jboss_config, 'some cli operation')

        self.assertEqual(
            self.cmd.get_last_command(),
            '/opt/jboss/jboss-eap-6.0.1/bin/jboss-cli.sh --connect --controller="123.234.345.456:9999" --user="******" --password="******" --command="some cli operation"'
        )
Exemplo n.º 2
0
    def test_controller_without_authentication(self):
        jboss_config = {
            'cli_path': '/opt/jboss/jboss-eap-6.0.1/bin/jboss-cli.sh',
            'controller': '123.234.345.456:9999'
        }
        jboss7_cli.run_operation(jboss_config, 'some cli operation')

        self.assertEqual(self.cmd.get_last_command(), '/opt/jboss/jboss-eap-6.0.1/bin/jboss-cli.sh --connect --controller="123.234.345.456:9999" --command="some cli operation"')
Exemplo n.º 3
0
    def test_controller_without_authentication(self):
        jboss_config = {
            'cli_path': '/opt/jboss/jboss-eap-6.0.1/bin/jboss-cli.sh',
            'controller': '123.234.345.456:9999'
        }
        jboss7_cli.run_operation(jboss_config, 'some cli operation')

        self.assertEqual(self.cmd.get_last_command(), '/opt/jboss/jboss-eap-6.0.1/bin/jboss-cli.sh --connect --controller="123.234.345.456:9999" --command="some cli operation"')
Exemplo n.º 4
0
    def test_operation_execution(self):
        operation = r'sample_operation'
        jboss7_cli.run_operation(self.jboss_config, operation)

        self.assertEqual(
            self.cmd.get_last_command(),
            r'/opt/jboss/jboss-eap-6.0.1/bin/jboss-cli.sh --connect --controller="123.234.345.456:9999" --user="******" --password="******" --command="sample_operation"'
        )
Exemplo n.º 5
0
    def test_escaping_operation_with_backslashes_and_quotes(self):
        operation = r'/subsystem=naming/binding="java:/sampleapp/web-module/ldap/username":add(binding-type=simple, value="DOMAIN\\\\user")'
        jboss7_cli.run_operation(self.jboss_config, operation)

        self.assertEqual(
            self.cmd.get_last_command(),
            r'/opt/jboss/jboss-eap-6.0.1/bin/jboss-cli.sh --connect --controller="123.234.345.456:9999" --user="******" --password="******" --command="/subsystem=naming/binding=\"java:/sampleapp/web-module/ldap/username\":add(binding-type=simple, value=\"DOMAIN\\\\\\\\user\")"'
        )
Exemplo n.º 6
0
    def test_controller_without_authentication(self):
        jboss_config = {
            "cli_path": "/opt/jboss/jboss-eap-6.0.1/bin/jboss-cli.sh",
            "controller": "123.234.345.456:9999",
        }
        jboss7_cli.run_operation(jboss_config, "some cli operation")

        self.assertEqual(
            self.cmd.get_last_command(),
            '/opt/jboss/jboss-eap-6.0.1/bin/jboss-cli.sh --connect --controller="123.234.345.456:9999" --command="some cli operation"',
        )
Exemplo n.º 7
0
    def test_handling_cmd_not_exists(self):
        def command_response(command):
            return {'retcode': 127,
                    'stdout': '''Command not exists''',
                    'stderr': 'some err'}
        self.cmd.command_response_func = command_response

        try:
            jboss7_cli.run_operation(self.jboss_config, 'some cli command')
            # should throw an exception
            assert False
        except CommandExecutionError as err:
            self.assertTrue(six.text_type(err).startswith('Could not execute jboss-cli.sh script'))
Exemplo n.º 8
0
    def test_handling_cmd_not_exists(self):
        def command_response(command):
            return {'retcode': 127,
                    'stdout': '''Command not exists''',
                    'stderr': 'some err'}
        self.cmd.command_response_func = command_response

        try:
            jboss7_cli.run_operation(self.jboss_config, 'some cli command')
            # should throw an exception
            assert False
        except CommandExecutionError as e:
            self.assertTrue(str(e).startswith('Could not execute jboss-cli.sh script'))
Exemplo n.º 9
0
    def test_handling_cmd_not_exists(self):
        def command_response(command):
            return {
                "retcode": 127,
                "stdout": """Command not exists""",
                "stderr": "some err",
            }

        self.cmd.command_response_func = command_response

        try:
            jboss7_cli.run_operation(self.jboss_config, "some cli command")
            # should throw an exception
            assert False
        except CommandExecutionError as err:
            self.assertTrue(
                str(err).startswith("Could not execute jboss-cli.sh script"))
Exemplo n.º 10
0
 def test_run_operation_no_code_error(self):
     call_cli_ret = {
         "retcode": 1,
         "stdout": '{"failure-description" => "ERROR234523: ops"}',
     }
     with patch("salt.modules.jboss7_cli._call_cli",
                return_value=call_cli_ret) as _call_cli:
         ret = jboss7_cli.run_operation(None, "ls", False)
         self.assertEqual(ret["err_code"], "-1")
Exemplo n.º 11
0
 def test_run_operation_no_code_error(self):
     call_cli_ret = {
         'retcode': 1,
         'stdout': '{"failure-description" => "ERROR234523: ops"}'
     }
     with patch('salt.modules.jboss7_cli._call_cli',
                return_value=call_cli_ret) as _call_cli:
         ret = jboss7_cli.run_operation(None, "ls", False)
         self.assertEqual(ret['err_code'], "-1")
Exemplo n.º 12
0
    def test_handling_jboss_error(self):
        def command_response(command):
            return {'retcode': 1,
                    'stdout': r'''{
                       "outcome" => "failed",
                       "failure-description" => "JBAS014807: Management resource '[
                       (\"subsystem\" => \"datasources\"),
                       (\"data-source\" => \"non-existing\")
                    ]' not found",
                        "rolled-back" => true,
                        "response-headers" => {"process-state" => "reload-required"}
                    }
                    ''',
                    'stderr': 'some err'}
        self.cmd.command_response_func = command_response

        result = jboss7_cli.run_operation(self.jboss_config, 'some cli command')

        self.assertFalse(result['success'])
        self.assertEqual(result['err_code'], 'JBAS014807')
Exemplo n.º 13
0
    def test_handling_jboss_error(self):
        def command_response(command):
            return {'retcode': 1,
                    'stdout': r'''{
                       "outcome" => "failed",
                       "failure-description" => "JBAS014807: Management resource '[
                       (\"subsystem\" => \"datasources\"),
                       (\"data-source\" => \"non-existing\")
                    ]' not found",
                        "rolled-back" => true,
                        "response-headers" => {"process-state" => "reload-required"}
                    }
                    ''',
                    'stderr': 'some err'}
        self.cmd.command_response_func = command_response

        result = jboss7_cli.run_operation(self.jboss_config, 'some cli command')

        self.assertFalse(result['success'])
        self.assertEqual(result['err_code'], 'JBAS014807')
Exemplo n.º 14
0
    def test_handling_jboss_error(self):
        def command_response(command):
            return {
                "retcode": 1,
                "stdout": r"""{
                       "outcome" => "failed",
                       "failure-description" => "JBAS014807: Management resource '[
                       (\"subsystem\" => \"datasources\"),
                       (\"data-source\" => \"non-existing\")
                    ]' not found",
                        "rolled-back" => true,
                        "response-headers" => {"process-state" => "reload-required"}
                    }
                    """,
                "stderr": "some err",
            }

        self.cmd.command_response_func = command_response

        result = jboss7_cli.run_operation(self.jboss_config, "some cli command")

        self.assertFalse(result["success"])
        self.assertEqual(result["err_code"], "JBAS014807")
Exemplo n.º 15
0
    def test_escaping_operation_with_backslashes_and_quotes(self):
        operation = r'/subsystem=naming/binding="java:/sampleapp/web-module/ldap/username":add(binding-type=simple, value="DOMAIN\\\\user")'
        jboss7_cli.run_operation(self.jboss_config, operation)

        self.assertEqual(self.cmd.get_last_command(), r'/opt/jboss/jboss-eap-6.0.1/bin/jboss-cli.sh --connect --controller="123.234.345.456:9999" --user="******" --password="******" --command="/subsystem=naming/binding=\"java:/sampleapp/web-module/ldap/username\":add(binding-type=simple, value=\"DOMAIN\\\\\\\\user\")"')
Exemplo n.º 16
0
    def test_controller_authentication(self):
        jboss7_cli.run_operation(self.jboss_config, 'some cli operation')

        self.assertEqual(self.cmd.get_last_command(), '/opt/jboss/jboss-eap-6.0.1/bin/jboss-cli.sh --connect --controller="123.234.345.456:9999" --user="******" --password="******" --command="some cli operation"')
Exemplo n.º 17
0
    def test_operation_execution(self):
        operation = r'sample_operation'
        jboss7_cli.run_operation(self.jboss_config, operation)

        self.assertEqual(self.cmd.get_last_command(), r'/opt/jboss/jboss-eap-6.0.1/bin/jboss-cli.sh --connect --controller="123.234.345.456:9999" --user="******" --password="******" --command="sample_operation"')