From 756d6cf084164e4a8f94958c2139781119259b2d Mon Sep 17 00:00:00 2001 From: pylover Date: Tue, 11 Jan 2022 12:19:00 +0330 Subject: [PATCH] Fix: create JWT token without payload --- tests/test_cli.py | 6 ++++++ yhttp/ext/auth/__init__.py | 2 +- yhttp/ext/auth/cli.py | 7 ++++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/tests/test_cli.py b/tests/test_cli.py index 3920390..5da7e2c 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -19,6 +19,12 @@ def test_jwtcli(): assert status == 0 assert len(stdout.split('.')) == 3 + # Without token + when('auth create') + assert stderr == '' + assert status == 0 + assert len(stdout.split('.')) == 3 + if __name__ == '__main__': app.climain(['auth', 'c', '{"foo": "bar"}']) diff --git a/yhttp/ext/auth/__init__.py b/yhttp/ext/auth/__init__.py index 5b4b44b..62dcf40 100644 --- a/yhttp/ext/auth/__init__.py +++ b/yhttp/ext/auth/__init__.py @@ -2,4 +2,4 @@ from .install import install from .authentication import Authenticator -__version__ = '3.7.0' +__version__ = '3.7.1' diff --git a/yhttp/ext/auth/cli.py b/yhttp/ext/auth/cli.py index 4983cef..6883666 100644 --- a/yhttp/ext/auth/cli.py +++ b/yhttp/ext/auth/cli.py @@ -16,7 +16,12 @@ class Create(SubCommand): def __call__(self, args): settings = args.application.settings.auth jwt = Authenticator(settings) - print(jwt.dump(json.loads(args.payload))) + if args.payload: + payload = json.loads(args.payload) + else: + payload = '' + + print(jwt.dump(payload)) class AuthenticatorCLI(SubCommand):