Skip to content

Commit

Permalink
fixed prefixed digest underscore, use dash instead (#45)
Browse files Browse the repository at this point in the history
Signed-off-by: 2byrds <[email protected]>
  • Loading branch information
2byrds authored Sep 16, 2024
1 parent 9ed0dbd commit 266320d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/regps/app/api/digest_verifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

def get_non_prefixed_digest(dig):
try:
prefix, digest = dig.split("_", 1)
prefix, digest = dig.split("-", 1)
except ValueError:
raise DigestVerificationFailedException(
f"Digest ({dig}) must start with prefix", 400
Expand Down
12 changes: 6 additions & 6 deletions tests/unit/test_reports_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ def test_check_report_status_authorization():
aid = "jnhh8f7h79nufb97hbw3fieBHJBgg7uhn"
lei = "j9h7ufehhcWBUTDVWYH98h9bfyaebgGBFfsa3wFf"
report_1 = "report 1"
dig_1 = "sha256_moiuhLFBf9afnHJDfaffg4ehgh"
dig_1 = "sha256-moiuhLFBf9afnHJDfaffg4ehgh"
report_2 = "report 2"
dig_2 = "sha256_fer4grniuojnfaNHBBcaaUh89h"
dig_2 = "sha256-fer4grniuojnfaNHBBcaaUh89h"
reports_db = ReportsDB()
reports_db.register_aid(aid, lei)
reports_db.add_report(aid, dig_1, report_1)
Expand All @@ -23,9 +23,9 @@ def test_check_report_status_authorization_2_aids_from_the_same_lei():
aid_2 = "UNBOUb8dadh98hnansudHD0jndbuh8hnd"
lei = "j9h7ufehhcWBUTDVWYH98h9bfyaebgGBFfsa3wFf"
report_1 = "report 1"
dig_1 = "sha256_moiuhLFBf9afnHJDfaffg4ehgh"
dig_1 = "sha256-moiuhLFBf9afnHJDfaffg4ehgh"
report_2 = "report 2"
dig_2 = "sha256_fer4grniuojnfaNHBBcaaUh89h"
dig_2 = "sha256-fer4grniuojnfaNHBBcaaUh89h"
reports_db = ReportsDB()
reports_db.register_aid(aid_1, lei)
reports_db.register_aid(aid_2, lei)
Expand All @@ -47,9 +47,9 @@ def test_check_report_status_authorization_2_aids_from_different_lei():
lei_1 = "j9h7ufehhcWBUTDVWYH98h9bfyaebgGBFfsa3wFf"
lei_2 = "mOI8hbsah80hihSHFIHh8h3r8hf8h08hfaiffha0"
report_1 = "report 1"
dig_1 = "sha256_moiuhLFBf9afnHJDfaffg4ehgh"
dig_1 = "sha256-moiuhLFBf9afnHJDfaffg4ehgh"
report_2 = "report 2"
dig_2 = "sha256_fer4grniuojnfaNHBBcaaUh89h"
dig_2 = "sha256-fer4grniuojnfaNHBBcaaUh89h"
reports_db = ReportsDB()
reports_db.register_aid(aid_1, lei_1)
reports_db.register_aid(aid_2, lei_2)
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_verifying.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
def test_digest_verification():
BASE_STR = "fefUBIUhdo9032bfHf0UNONF0kubni9HnF22L0KD2".encode()
dig = sha256(BASE_STR).hexdigest()
dig = f"sha256_{dig}"
dig = f"sha256-{dig}"
assert verify_digest(BASE_STR, dig) is True


def test_digest_verification_fail():
BASE_STR = "fefUBIUhdo9032bfHf0UNONF0kubni9HnF22L0KD2".encode()
WRONG_BASE_STR = "fefUBIUhdo9032bfHf0UNONF0kubni9HnF22L0KDT".encode()
dig = sha256(BASE_STR).hexdigest()
dig = f"sha256_{dig}"
dig = f"sha256-{dig}"
assert verify_digest(WRONG_BASE_STR, dig) is False


Expand Down

0 comments on commit 266320d

Please sign in to comment.