4
4
import pytest
5
5
6
6
from idpyoidc .server import Server
7
+ from idpyoidc .server .authn_event import create_authn_event
7
8
from idpyoidc .server .configure import OPConfiguration
8
9
from idpyoidc .server .user_authn .authn_context import INTERNETPROTOCOLPASSWORD
9
10
from idpyoidc .server .user_authn .authn_context import UNSPECIFIED
@@ -80,6 +81,20 @@ def create_endpoint_context(self):
80
81
}
81
82
self .server = Server (OPConfiguration (conf = conf , base_path = BASEDIR ), cwd = BASEDIR )
82
83
self .endpoint_context = self .server .endpoint_context
84
+ self .session_manager = self .endpoint_context .session_manager
85
+ self .user_id = "diana"
86
+
87
+ def _create_session (self , auth_req , sub_type = "public" , sector_identifier = "" ):
88
+ if sector_identifier :
89
+ authz_req = auth_req .copy ()
90
+ authz_req ["sector_identifier_uri" ] = sector_identifier
91
+ else :
92
+ authz_req = auth_req
93
+ client_id = authz_req ["client_id" ]
94
+ ae = create_authn_event (self .user_id )
95
+ return self .session_manager .create_session (
96
+ ae , authz_req , self .user_id , client_id = client_id , sub_type = sub_type
97
+ )
83
98
84
99
def test_authenticated_as_without_cookie (self ):
85
100
authn_item = self .endpoint_context .authn_broker .pick (INTERNETPROTOCOLPASSWORD )
@@ -93,12 +108,11 @@ def test_authenticated_as_with_cookie(self):
93
108
method = authn_item [0 ]["method" ]
94
109
95
110
authn_req = {"state" : "state_identifier" , "client_id" : "client 12345" }
111
+ _sid = self ._create_session (authn_req )
96
112
_cookie = self .endpoint_context .new_cookie (
97
113
name = self .endpoint_context .cookie_handler .name ["session" ],
98
114
sub = "diana" ,
99
- sid = self .endpoint_context .session_manager .encrypted_session_id (
100
- "diana" , "client 12345" , "abcdefgh"
101
- ),
115
+ sid = _sid ,
102
116
state = authn_req ["state" ],
103
117
client_id = authn_req ["client_id" ],
104
118
)
0 commit comments