|
23 | 23 | from oidcmsg.exception import OidcMsgError |
24 | 24 | from oidcmsg.oauth2 import ResponseMessage |
25 | 25 | from oidcmsg.oauth2 import ROPCAccessTokenRequest |
| 26 | +from oidcmsg.oidc import EXPError |
| 27 | +from oidcmsg.oidc import IATError |
26 | 28 | from oidcmsg.oidc import JRD |
27 | 29 | from oidcmsg.oidc import AccessTokenRequest |
28 | 30 | from oidcmsg.oidc import AccessTokenResponse |
@@ -929,6 +931,68 @@ def test_id_token(): |
929 | 931 | idt.verify() |
930 | 932 |
|
931 | 933 |
|
| 934 | +def test_id_token_expired(): |
| 935 | + _now = time_util.utc_time_sans_frac() |
| 936 | + |
| 937 | + idt = IdToken(**{ |
| 938 | + "sub": "553df2bcf909104751cfd8b2", |
| 939 | + "aud": [ |
| 940 | + "5542958437706128204e0000", |
| 941 | + "554295ce3770612820620000" |
| 942 | + ], |
| 943 | + "auth_time": 1441364872, |
| 944 | + "azp": "554295ce3770612820620000", |
| 945 | + "at_hash": "L4Ign7TCAD_EppRbHAuCyw", |
| 946 | + "iat": _now - 200, |
| 947 | + "exp": _now - 100, |
| 948 | + "iss": "https://sso.qa.7pass.ctf.prosiebensat1.com" |
| 949 | + }) |
| 950 | + |
| 951 | + with pytest.raises(EXPError): |
| 952 | + idt.verify() |
| 953 | + |
| 954 | + |
| 955 | +def test_id_token_iat_in_the_future(): |
| 956 | + _now = time_util.utc_time_sans_frac() |
| 957 | + |
| 958 | + idt = IdToken(**{ |
| 959 | + "sub": "553df2bcf909104751cfd8b2", |
| 960 | + "aud": [ |
| 961 | + "5542958437706128204e0000", |
| 962 | + "554295ce3770612820620000" |
| 963 | + ], |
| 964 | + "auth_time": 1441364872, |
| 965 | + "azp": "554295ce3770612820620000", |
| 966 | + "at_hash": "L4Ign7TCAD_EppRbHAuCyw", |
| 967 | + "iat": _now + 600, |
| 968 | + "exp": _now + 1200, |
| 969 | + "iss": "https://sso.qa.7pass.ctf.prosiebensat1.com" |
| 970 | + }) |
| 971 | + |
| 972 | + with pytest.raises(IATError): |
| 973 | + idt.verify() |
| 974 | + |
| 975 | + |
| 976 | +def test_id_token_exp_before_iat(): |
| 977 | + _now = time_util.utc_time_sans_frac() |
| 978 | + |
| 979 | + idt = IdToken(**{ |
| 980 | + "sub": "553df2bcf909104751cfd8b2", |
| 981 | + "aud": [ |
| 982 | + "5542958437706128204e0000", |
| 983 | + "554295ce3770612820620000" |
| 984 | + ], |
| 985 | + "auth_time": 1441364872, |
| 986 | + "azp": "554295ce3770612820620000", |
| 987 | + "at_hash": "L4Ign7TCAD_EppRbHAuCyw", |
| 988 | + "iat": _now + 50, |
| 989 | + "exp": _now, |
| 990 | + "iss": "https://sso.qa.7pass.ctf.prosiebensat1.com" |
| 991 | + }) |
| 992 | + |
| 993 | + with pytest.raises(IATError): |
| 994 | + idt.verify(skew=100) |
| 995 | + |
932 | 996 | class TestAccessTokenRequest(object): |
933 | 997 | def test_example(self): |
934 | 998 | _txt = 'grant_type=authorization_code&code=SplxlOBeZQQYbYS6WxSbIA' \ |
|
0 commit comments