def test_get_payload(): expected = { "GivenName": "Toto", "Email": "*****@*****.**", "Role": "tester", "iss": "adacore.com", "sub": "test", "exp": 1550655711, "iat": 1519119711, "Surname": "123", "aud": "www.adacore.com", } token = create_token(expected) payload = get_payload(token) assert payload == expected
def test_get_payload(): expected = { u'GivenName': u'Toto', u'Email': u'*****@*****.**', u'Role': u'tester', u'iss': u'adacore.com', u'sub': u'test', u'exp': 1550655711, u'iat': 1519119711, u'Surname': u'123', u'aud': u'www.adacore.com' } token = create_token(expected) payload = get_payload(token) assert payload == expected
def test_token_str(): token = ("eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJhZGFjb3JlLmNvbSI" "sImlhdCI6MTUxOTExOTcxMSwiZXhwIjoxNTUwNjU1NzExLCJhdWQiOiJ3d3cuYWR" "hY29yZS5jb20iLCJzdWIiOiJ0ZXN0IiwiR2l2ZW5OYW1lIjoiVG90byIsIlN1cm5" "hbWUiOiIxMjMiLCJFbWFpbCI6InRvdG9AZXhhbXBsZS5jb20iLCJSb2xlIjoidGV" "zdGVyIn0.UERDJuUFh6A30TXIEKbNu6BbDOUCdsLGMKuQS8DfboA") payload = get_payload(token) expected = { "GivenName": "Toto", "Email": "*****@*****.**", "Role": "tester", "iss": "adacore.com", "sub": "test", "exp": 1550655711, "iat": 1519119711, "Surname": "123", "aud": "www.adacore.com", } assert payload == expected assert not is_valid(token)
def test_token_str(): token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJhZGFjb3JlLmNvbSI'\ 'sImlhdCI6MTUxOTExOTcxMSwiZXhwIjoxNTUwNjU1NzExLCJhdWQiOiJ3d3cuYWR'\ 'hY29yZS5jb20iLCJzdWIiOiJ0ZXN0IiwiR2l2ZW5OYW1lIjoiVG90byIsIlN1cm5'\ 'hbWUiOiIxMjMiLCJFbWFpbCI6InRvdG9AZXhhbXBsZS5jb20iLCJSb2xlIjoidGV'\ 'zdGVyIn0.UERDJuUFh6A30TXIEKbNu6BbDOUCdsLGMKuQS8DfboA' payload = get_payload(token) expected = { u'GivenName': u'Toto', u'Email': u'*****@*****.**', u'Role': u'tester', u'iss': u'adacore.com', u'sub': u'test', u'exp': 1550655711, u'iat': 1519119711, u'Surname': u'123', u'aud': u'www.adacore.com' } assert payload == expected assert not is_valid(token)