Esempio n. 1
0
    def test_automatic_auth_skipped_on_auth_command(self):
        self._write_mock_config()

        shell = Shell()
        shell._get_auth_token = mock.Mock()

        argv = ['auth', 'testu', '-p', 'testp']
        args = shell.parser.parse_args(args=argv)
        shell.get_client(args=args)
        self.assertEqual(shell._get_auth_token.call_count, 0)
Esempio n. 2
0
    def test_automatic_auth_skipped_on_auth_command(self):
        self._write_mock_config()

        shell = Shell()
        shell._get_auth_token = mock.Mock()

        argv = ['auth', 'testu', '-p', 'testp']
        args = shell.parser.parse_args(args=argv)
        shell.get_client(args=args)
        self.assertEqual(shell._get_auth_token.call_count, 0)
Esempio n. 3
0
    def test_automatic_auth_skipped_if_token_provided_as_env_variable(self):
        self._write_mock_config()

        shell = Shell()
        shell._get_auth_token = mock.Mock()

        os.environ['ST2_AUTH_TOKEN'] = 'fooo'
        argv = ['action', 'list']
        args = shell.parser.parse_args(args=argv)
        shell.get_client(args=args)
        self.assertEqual(shell._get_auth_token.call_count, 0)
Esempio n. 4
0
    def test_automatic_auth_skipped_if_token_provided_as_env_variable(self):
        self._write_mock_config()

        shell = Shell()
        shell._get_auth_token = mock.Mock()

        os.environ['ST2_AUTH_TOKEN'] = 'fooo'
        argv = ['action', 'list']
        args = shell.parser.parse_args(args=argv)
        shell.get_client(args=args)
        self.assertEqual(shell._get_auth_token.call_count, 0)
Esempio n. 5
0
    def test_get_one_unicode_character_in_name(self):
        self._write_mock_config()

        shell = Shell()
        shell._get_auth_token = mock.Mock()

        os.environ["ST2_AUTH_TOKEN"] = "fooo"
        argv = ["action", "get", "examples.test_rule_utf8_náme"]
        args = shell.parser.parse_args(args=argv)
        shell.get_client(args=args)
        self.assertEqual(args.ref_or_id, ["examples.test_rule_utf8_náme"])
Esempio n. 6
0
    def test_automatic_auth_skipped_if_token_provided_as_cli_argument(self):
        self._write_mock_config()

        shell = Shell()
        shell._get_auth_token = mock.Mock()

        argv = ['action', 'list', '--token=bar']
        args = shell.parser.parse_args(args=argv)
        shell.get_client(args=args)
        self.assertEqual(shell._get_auth_token.call_count, 0)

        argv = ['action', 'list', '-t', 'bar']
        args = shell.parser.parse_args(args=argv)
        shell.get_client(args=args)
        self.assertEqual(shell._get_auth_token.call_count, 0)
Esempio n. 7
0
    def test_automatic_auth_skipped_if_token_provided_as_cli_argument(self):
        self._write_mock_config()

        shell = Shell()
        shell._get_auth_token = mock.Mock()

        argv = ['action', 'list', '--token=bar']
        args = shell.parser.parse_args(args=argv)
        shell.get_client(args=args)
        self.assertEqual(shell._get_auth_token.call_count, 0)

        argv = ['action', 'list', '-t', 'bar']
        args = shell.parser.parse_args(args=argv)
        shell.get_client(args=args)
        self.assertEqual(shell._get_auth_token.call_count, 0)