Пример #1
0
    def test_main_update(self, config_mock):
        config_mock().update = True
        keyman = Keyman(['foo', '-o', 'foo', '-u', 'bar', '-a', 'baz'])
        keyman.update = mock.MagicMock()
        keyman.handle_appid_selection = mock.MagicMock()
        keyman.user_password = mock.MagicMock()
        keyman.user_password.return_value = 'foo'
        keyman.init_okta = mock.MagicMock()
        keyman.auth_okta = mock.MagicMock()
        keyman.aws_auth_loop = mock.MagicMock()

        with self.assertRaises(SystemExit):
            keyman.main()

        keyman.update.assert_has_calls([mock.call(__version__)])
Пример #2
0
    def test_main_post_okta_appid_selection(self, _config_mock):
        keyman = Keyman(['foo', '-o', 'foo', '-u', 'bar'])
        keyman.handle_appid_selection = mock.MagicMock()
        keyman.config.appid = None
        keyman.user_password = mock.MagicMock()
        keyman.user_password.return_value = 'foo'
        keyman.init_okta = mock.MagicMock()
        keyman.auth_okta = mock.MagicMock()
        keyman.aws_auth_loop = mock.MagicMock()
        keyman.aws_auth_loop.return_value = None
        keyman.handle_appid_selection = mock.MagicMock()

        keyman.main()

        keyman.handle_appid_selection.assert_has_calls(
            [mock.call(), mock.call(okta_ready=True)])
Пример #3
0
    def test_main(self, _config_mock):
        keyman = Keyman(['foo', '-o', 'foo', '-u', 'bar', '-a', 'baz'])
        keyman.handle_appid_selection = mock.MagicMock()
        keyman.user_password = mock.MagicMock()
        keyman.user_password.return_value = 'foo'
        keyman.init_okta = mock.MagicMock()
        keyman.auth_okta = mock.MagicMock()
        keyman.aws_auth_loop = mock.MagicMock()

        keyman.main()

        assert keyman.handle_appid_selection.called
        assert keyman.user_password.called
        keyman.init_okta.assert_called_with('foo')
        assert keyman.auth_okta.called
        assert keyman.aws_auth_loop.called
Пример #4
0
    def test_main(self, _config_mock):
        keyman = Keyman(["foo", "-o", "foo", "-u", "bar", "-a", "baz"])
        keyman.handle_appid_selection = mock.MagicMock()
        keyman.user_password = mock.MagicMock()
        keyman.user_password.return_value = "foo"
        keyman.init_okta = mock.MagicMock()
        keyman.auth_okta = mock.MagicMock()
        keyman.aws_auth_loop = mock.MagicMock()
        keyman.aws_auth_loop.return_value = None

        keyman.main()

        assert keyman.handle_appid_selection.called
        assert keyman.user_password.called
        keyman.init_okta.assert_called_with("foo")
        assert keyman.auth_okta.called
        assert keyman.aws_auth_loop.called
Пример #5
0
def entry_point():
    """Zero-argument entry point for use with setuptools/distribute."""
    logger = logging.getLogger()
    logger.setLevel(logging.INFO)
    handler = colorlog.StreamHandler()
    fmt = "%(asctime)-8s (%(bold)s%(log_color)s%(levelname)s%(reset)s) " "%(message)s"
    formatter = colorlog.ColoredFormatter(fmt, datefmt="%H:%M:%S")
    handler.setFormatter(formatter)
    logger.addHandler(handler)
    keyman = Keyman(sys.argv)
    raise SystemExit(keyman.main())
Пример #6
0
def entry_point():
    """Zero-argument entry point for use with setuptools/distribute."""
    keyman = Keyman(sys.argv)
    raise SystemExit(keyman.main())