Skip to content

Commit f079af5

Browse files
committed
Fixed test.
1 parent 9375982 commit f079af5

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

tests/test_server_13_user_authn.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import pytest
55

66
from idpyoidc.server import Server
7+
from idpyoidc.server.authn_event import create_authn_event
78
from idpyoidc.server.configure import OPConfiguration
89
from idpyoidc.server.user_authn.authn_context import INTERNETPROTOCOLPASSWORD
910
from idpyoidc.server.user_authn.authn_context import UNSPECIFIED
@@ -80,6 +81,20 @@ def create_endpoint_context(self):
8081
}
8182
self.server = Server(OPConfiguration(conf=conf, base_path=BASEDIR), cwd=BASEDIR)
8283
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+
)
8398

8499
def test_authenticated_as_without_cookie(self):
85100
authn_item = self.endpoint_context.authn_broker.pick(INTERNETPROTOCOLPASSWORD)
@@ -93,12 +108,11 @@ def test_authenticated_as_with_cookie(self):
93108
method = authn_item[0]["method"]
94109

95110
authn_req = {"state": "state_identifier", "client_id": "client 12345"}
111+
_sid = self._create_session(authn_req)
96112
_cookie = self.endpoint_context.new_cookie(
97113
name=self.endpoint_context.cookie_handler.name["session"],
98114
sub="diana",
99-
sid=self.endpoint_context.session_manager.encrypted_session_id(
100-
"diana", "client 12345", "abcdefgh"
101-
),
115+
sid=_sid,
102116
state=authn_req["state"],
103117
client_id=authn_req["client_id"],
104118
)

0 commit comments

Comments
 (0)