1+ import hashlib
12import requests
23import pytest
34from lib .fixtures import * # NOSONAR
@@ -22,6 +23,35 @@ def test_200_get_letter_status(url, authentication_secret):
2223 ErrorHandler .handle_retry (get_message_response )
2324 assert get_message_response .status_code == 200 , f"Response: { get_message_response .status_code } : { get_message_response .text } "
2425
26+ @pytest .mark .test
27+ @pytest .mark .devtest
28+ @pytest .mark .inttest
29+ @pytest .mark .prodtest
30+ def test_200_get_letter_status_matches_pdf_hash (url , authentication_secret ):
31+ headers = Generators .generate_valid_headers (authentication_secret )
32+
33+ ids = get_pending_letter_ids (url , headers , LETTERS_ENDPOINT , limit = 1 )
34+ letter_id = ids [0 ]
35+
36+ print (f"calling GET { url } { LETTERS_ENDPOINT } /{ letter_id } " )
37+ get_message_response = requests .get (f"{ url } { LETTERS_ENDPOINT } /{ letter_id } " , headers = headers )
38+
39+ ErrorHandler .handle_retry (get_message_response )
40+ expected_sha256 = get_message_response .json ().get ("data" , {}).get ("attributes" , {}).get ("sha256Hash" )
41+
42+ get_pdf_response = requests .get (
43+ f"{ url } { LETTERS_ENDPOINT } /{ letter_id } /data" ,
44+ headers = headers ,
45+ allow_redirects = True ,
46+ )
47+ downloaded_pdf_sha256 = hashlib .sha256 (get_pdf_response .content ).hexdigest ()
48+
49+ assert get_message_response .status_code == 200 , f"Response: { get_message_response .status_code } : { get_message_response .text } "
50+ assert expected_sha256 is not None , "Expected sha256Hash in GET /letters/{id} response"
51+ assert downloaded_pdf_sha256 == expected_sha256 , (
52+ f"Expected PDF sha256 { expected_sha256 } , got { downloaded_pdf_sha256 } "
53+ )
54+
2555@pytest .mark .test
2656@pytest .mark .devtest
2757@pytest .mark .inttest
0 commit comments