28 lines
803 B
Python
28 lines
803 B
Python
import unittest
|
|
import tempfile
|
|
from jwcrypto.jwt import JWT, JWTExpired
|
|
|
|
from src.jwt_cli.main import main
|
|
from asyncio.runners import run
|
|
from pwo import async_test, tmpdir
|
|
from pathlib import Path
|
|
import sys
|
|
import json
|
|
|
|
|
|
class TokenTest(unittest.TestCase):
|
|
@tmpdir
|
|
def test_parse_token(self, temp_dir):
|
|
result = temp_dir / 'output.json'
|
|
|
|
with self.assertRaises(JWTExpired) as _:
|
|
main(['token', 'parse', '-i', 'auth_token.txt',
|
|
'-o', str(result),
|
|
'--keys', 'file:jwks.json'])
|
|
main(['token', 'parse', '-i', 'auth_token.txt',
|
|
'-o', str(result)])
|
|
with open(result, 'r') as infile:
|
|
# print(infile.read())
|
|
jwt = json.load(infile)
|
|
json.dump(jwt, sys.stdout, indent=4)
|