File tree Expand file tree Collapse file tree 2 files changed +32
-4
lines changed
Expand file tree Collapse file tree 2 files changed +32
-4
lines changed Original file line number Diff line number Diff line change @@ -1037,3 +1037,23 @@ def campaign_config_with_missing_descriptions_missing_rule_text(
10371037 )
10381038 yield campaign
10391039 s3_client .delete_object (Bucket = rules_bucket , Key = f"{ campaign .name } .json" )
1040+
1041+
1042+ class StubHashingService :
1043+ def hash_with_current_secret (self , nhs_number : str ) -> str :
1044+ return hmac .new (
1045+ "test_value" .encode ("utf-8" ),
1046+ nhs_number .encode ("utf-8" ),
1047+ hashlib .sha512 ,
1048+ ).hexdigest ()
1049+
1050+ def hash_with_previous_secret (self , nhs_number : str ) -> str :
1051+ return hmac .new (
1052+ "test_old_value" .encode ("utf-8" ),
1053+ nhs_number .encode ("utf-8" ),
1054+ hashlib .sha512 ,
1055+ ).hexdigest ()
1056+
1057+ @pytest .fixture
1058+ def hashing_service () -> StubHashingService :
1059+ return StubHashingService ()
Original file line number Diff line number Diff line change 1+ import hashlib
2+ import hmac
13from typing import Any
24
35import pytest
79from eligibility_signposting_api .model .eligibility_status import NHSNumber
810from eligibility_signposting_api .repos import NotFoundError
911from eligibility_signposting_api .repos .person_repo import PersonRepo
12+ from tests .integration .conftest import StubHashingService
1013
1114
12- def test_person_found (person_table : Any , persisted_person : NHSNumber ):
15+ def test_person_found (person_table : Any , persisted_person : NHSNumber ,
16+ hashing_service : StubHashingService ,):
1317 # Given
14- repo = PersonRepo (person_table )
18+ #repo = PersonRepo(person_table)
19+ repo = PersonRepo (person_table , hashing_service )
1520
1621 # When
1722 actual = repo .get_eligibility_data (persisted_person )
1823
1924 # Then
25+ nhs_num_hash = hashing_service .hash_with_current_secret (persisted_person )
26+
2027 assert_that (
2128 actual .data ,
2229 contains_inanyorder (
23- has_entries ({"NHS_NUMBER" : persisted_person , "ATTRIBUTE_TYPE" : "PERSON" }),
24- has_entries ({"NHS_NUMBER" : persisted_person , "ATTRIBUTE_TYPE" : "COHORTS" }),
30+ #has_entries({"NHS_NUMBER": persisted_person, "ATTRIBUTE_TYPE": "PERSON"}),
31+ has_entries ({"NHS_NUMBER" : nhs_num_hash , "ATTRIBUTE_TYPE" : "PERSON" }),
32+ has_entries ({"NHS_NUMBER" : nhs_num_hash , "ATTRIBUTE_TYPE" : "COHORTS" }),
2533 ),
2634 )
2735
You can’t perform that action at this time.
0 commit comments