def test_auth_resp_callback_func_user_id_from_attrs_is_used_to_override_user_id( self, context, satosa_config): satosa_config["INTERNAL_ATTRIBUTES"]["user_id_from_attrs"] = [ "user_id", "domain" ] base = SATOSABase(satosa_config) internal_resp = InternalResponse(AuthenticationInformation("", "", "")) internal_resp.attributes = { "user_id": ["user"], "domain": ["@example.com"] } internal_resp.requester = "test_requester" context.state[satosa.base.STATE_KEY] = {"requester": "test_requester"} context.state[satosa.routing. STATE_KEY] = satosa_config["FRONTEND_MODULES"][0]["name"] UserIdHasher.save_state(InternalRequest(UserIdHashType.persistent, ""), context.state) base._auth_resp_callback_func(context, internal_resp) expected_user_id = UserIdHasher.hash_data( satosa_config["USER_ID_HASH_SALT"], "*****@*****.**") expected_user_id = UserIdHasher.hash_id( satosa_config["USER_ID_HASH_SALT"], expected_user_id, internal_resp.requester, context.state) assert internal_resp.user_id == expected_user_id
def internal_response(self): auth_info = AuthenticationInformation("auth_class_ref", "timestamp", "issuer") internal_response = InternalResponse(auth_info=auth_info) internal_response.requester = "client" internal_response.attributes = ATTRIBUTES return internal_response
def test_filter_one_attribute_from_all_target_providers_for_one_requester( self): requester = "test_requester" attribute_filters = {"": {requester: {"a1": "foo:bar"}}} filter_service = self.create_filter_service(attribute_filters) resp = InternalResponse(AuthenticationInformation(None, None, None)) resp.requester = requester resp.attributes = { "a1": ["abc:xyz", "1:foo:bar:2"], } filtered = filter_service.process(None, resp) assert filtered.attributes == {"a1": ["1:foo:bar:2"]}
def test_auth_resp_callback_func_user_id_from_attrs_is_used_to_override_user_id(self, context, satosa_config): satosa_config["INTERNAL_ATTRIBUTES"]["user_id_from_attrs"] = ["user_id", "domain"] base = SATOSABase(satosa_config) internal_resp = InternalResponse(AuthenticationInformation("", "", "")) internal_resp.attributes = {"user_id": ["user"], "domain": ["@example.com"]} internal_resp.requester = "test_requester" context.state[satosa.base.STATE_KEY] = {"requester": "test_requester"} context.state[satosa.routing.STATE_KEY] = satosa_config["FRONTEND_MODULES"][0]["name"] UserIdHasher.save_state(InternalRequest(UserIdHashType.persistent, ""), context.state) base._auth_resp_callback_func(context, internal_resp) expected_user_id = UserIdHasher.hash_data(satosa_config["USER_ID_HASH_SALT"], "*****@*****.**") expected_user_id = UserIdHasher.hash_id(satosa_config["USER_ID_HASH_SALT"], expected_user_id, internal_resp.requester, context.state) assert internal_resp.user_id == expected_user_id
def internal_response(self): auth_info = AuthenticationInformation("auth_class_ref", "timestamp", "issuer") internal_response = InternalResponse(auth_info=auth_info) internal_response.requester = "client" internal_response.attributes = ATTRIBUTES return internal_response
def internal_resp(self): resp = InternalResponse(AuthenticationInformation(None, str(datetime.now()), 'https://idp.example.com')) resp.requester = 'client1' resp.user_id = 'user1' resp.attributes['affiliation'] = ['student'] return resp