def test_invalid_token_header_not_expiry_time(): payload = { 'id': 2, } token = token_validation.encode_token(payload, PRIVATE_KEY) token = token.decode('utf8') header = f'Bearer {token}' result = token_validation.validate_token_header(header, PUBLIC_KEY) assert None is result
def test_invalid_token_header_no_user_id(): expiry = delorean.parse('2018-05-17 13:47:34').datetime payload = { 'exp': expiry, } token = token_validation.encode_token(payload, PRIVATE_KEY) token = token.decode('utf8') header = f'Bearer {token}' result = token_validation.validate_token_header(header, PUBLIC_KEY) assert None is result
def test_valid_token_header(): payload = {'id': 1} header = token_validation.generate_token_header(payload, PRIVATE_KEY) result = token_validation.validate_token_header(header, PUBLIC_KEY) assert payload['id'] == result['id']
def test_valid_token_header_invalid_key(): payload = {'id': 1} header = token_validation.generate_token_header(payload, PRIVATE_KEY) result = token_validation.validate_token_header(header, INVALID_PUBLIC_KEY) assert None is result
def test_invalid_token_no_header(): header = None result = token_validation.validate_token_header(header, PUBLIC_KEY) assert None is result
def test_invalid_token_header_bad_token(): header = 'Bearer baddata' result = token_validation.validate_token_header(header, PUBLIC_KEY) assert None is result
def test_invalid_token_header_invalid_format(): header = 'bad header' result = token_validation.validate_token_header(header, PUBLIC_KEY) assert None is result