From cba22751b4e334877d0a930b0c1764f3d86f6ab1 Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Mon, 25 Jan 2021 22:29:48 +0100 Subject: [PATCH] Test setting cookie_secret to a hexadecimal string --- jupyterhub/tests/test_app.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/jupyterhub/tests/test_app.py b/jupyterhub/tests/test_app.py index accdd430..a918e9b7 100644 --- a/jupyterhub/tests/test_app.py +++ b/jupyterhub/tests/test_app.py @@ -199,6 +199,18 @@ def test_cookie_secret_env(tmpdir, request): assert not os.path.exists(hub.cookie_secret_file) +def test_cookie_secret_string_(): + cfg = Config() + + cfg.JupyterHub.cookie_secret = "not hex" + with pytest.raises(ValueError): + JupyterHub(config=cfg) + + cfg.JupyterHub.cookie_secret = "abc123" + app = JupyterHub(config=cfg) + assert app.cookie_secret == binascii.a2b_hex('abc123') + + async def test_load_groups(tmpdir, request): to_load = { 'blue': ['cyclops', 'rogue', 'wolverine'],