Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions tests/unit/lms/extensions/feature_flags/_helpers_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,18 @@ def test_set_encodes_the_payload_in_the_cookie(self, pyramid_request):
helper.set(response, original_payload)

cookie = response.headers["Set-Cookie"].split(";")[0].split("=")[1]
decoded_payload = jwt.decode(cookie, "test_secret", algorithms=["HS256"])
decoded_payload = jwt.decode(
cookie, "test_secret_at_least_32_bytes_for_hs256", algorithms=["HS256"]
)
assert decoded_payload == original_payload

def test_get_returns_the_decoded_payload(self, pyramid_request):
original_payload = {"test_key": "test_value"}
encoded_payload = jwt.encode(original_payload, "test_secret", algorithm="HS256")
encoded_payload = jwt.encode(
original_payload,
"test_secret_at_least_32_bytes_for_hs256",
algorithm="HS256",
)
pyramid_request.cookies["test_cookie_name"] = encoded_payload
helper = JWTCookieHelper("test_cookie_name", pyramid_request)

Expand Down Expand Up @@ -143,5 +149,7 @@ def test_that_set_and_get_work_together(self, pyramid_request):

@pytest.fixture(autouse=True)
def pyramid_config(self, pyramid_config):
pyramid_config.registry.settings["feature_flags_cookie_secret"] = "test_secret" # noqa: S105
pyramid_config.registry.settings["feature_flags_cookie_secret"] = (
"test_secret_at_least_32_bytes_for_hs256" # noqa: S105
)
return pyramid_config
Loading