Add non-root test

This commit is contained in:
Ayaz Salikhov
2021-11-15 16:11:58 +03:00
committed by GitHub
parent b6ab91a606
commit 058229dc3a

View File

@@ -240,12 +240,13 @@ def test_container_not_delete_bind_mount(container, tmp_path):
assert len(list(tmp_path.iterdir())) == 1 assert len(list(tmp_path.iterdir())) == 1
def test_jupyter_env_vars_to_unset_as_root(container): @pytest.mark.parametrize("enable_root", [False, True])
def test_jupyter_env_vars_to_unset_as_root(container, enable_root):
"""Environment variables names listed in JUPYTER_ENV_VARS_TO_UNSET """Environment variables names listed in JUPYTER_ENV_VARS_TO_UNSET
should be unset in the final environment.""" should be unset in the final environment."""
root_args = {"user": "root"} if enable_root else {}
c = container.run( c = container.run(
tty=True, tty=True,
user="root",
environment=[ environment=[
"JUPYTER_ENV_VARS_TO_UNSET=SECRET_ANIMAL,UNUSED_ENV,SECRET_FRUIT", "JUPYTER_ENV_VARS_TO_UNSET=SECRET_ANIMAL,UNUSED_ENV,SECRET_FRUIT",
"FRUIT=bananas", "FRUIT=bananas",
@@ -258,6 +259,7 @@ def test_jupyter_env_vars_to_unset_as_root(container):
"-c", "-c",
"echo I like $FRUIT and ${SECRET_FRUIT:-stuff}, and love ${SECRET_ANIMAL:-to keep secrets}!", "echo I like $FRUIT and ${SECRET_FRUIT:-stuff}, and love ${SECRET_ANIMAL:-to keep secrets}!",
], ],
**root_args,
) )
rv = c.wait(timeout=10) rv = c.wait(timeout=10)
assert rv == 0 or rv["StatusCode"] == 0 assert rv == 0 or rv["StatusCode"] == 0