예제 #1
0
    def test_main_method_has_no_parameters(self, mock_cli):
        """
        This is the entrypoint for the cli tool, and should require no parameters

        :param mock_cli:
        :return:
        """

        # Function under test
        aws_google_auth.main()

        self.assertTrue(mock_cli.called)
예제 #2
0
    def test_main_method_chaining(self, process_auth, resolve_config,
                                  exit_if_unsupported_python):

        # Create a mock config to be returned from the resolve_config function
        mock_config = Mock()
        # Inject the mock as the return value from the function
        aws_google_auth.resolve_config.return_value = mock_config

        # Function under test
        aws_google_auth.main([])

        self.assertTrue(exit_if_unsupported_python.called)
        self.assertTrue(resolve_config.called)
        self.assertTrue(process_auth.called)

        self.assertEqual([call()], exit_if_unsupported_python.mock_calls)

        self.assertEqual([
            call(
                Namespace(ask_role=False,
                          keyring=False,
                          disable_u2f=False,
                          duration=None,
                          idp_id=None,
                          profile=None,
                          region=None,
                          resolve_aliases=False,
                          role_arn=None,
                          saml_cache=True,
                          sp_id=None,
                          username=None))
        ], resolve_config.mock_calls)

        self.assertEqual([
            call(
                Namespace(ask_role=False,
                          keyring=False,
                          disable_u2f=False,
                          duration=None,
                          idp_id=None,
                          profile=None,
                          region=None,
                          resolve_aliases=False,
                          role_arn=None,
                          saml_cache=True,
                          sp_id=None,
                          username=None), mock_config)
        ], process_auth.mock_calls)