@@ -62,6 +62,42 @@ def invalid_attribute():
6262 assert docker .get_docker_user () == ()
6363
6464
65+ @pytest .fixture (autouse = True )
66+ def _avoid_cache ():
67+ with mock .patch .object (
68+ docker ,
69+ '_is_rootless' ,
70+ docker ._is_rootless .__wrapped__ ,
71+ ):
72+ yield
73+
74+
75+ @pytest .mark .parametrize (
76+ 'info_ret' ,
77+ (
78+ (0 , b'{"SecurityOptions": ["name=rootless","name=cgroupns"]}' , b'' ),
79+ (0 , b'{"host": {"security": {"rootless": true}}}' , b'' ),
80+ ),
81+ )
82+ def test_docker_user_rootless (info_ret ):
83+ with mock .patch .object (docker , 'cmd_output_b' , return_value = info_ret ):
84+ assert docker .get_docker_user () == ()
85+
86+
87+ @pytest .mark .parametrize (
88+ 'info_ret' ,
89+ (
90+ (0 , b'{"SecurityOptions": ["name=cgroupns"]}' , b'' ),
91+ (0 , b'{"host": {"security": {"rootless": false}}}' , b'' ),
92+ (0 , b'{"respone_from_some_other_container_engine": true}' , b'' ),
93+ (1 , b'' , b'' ),
94+ ),
95+ )
96+ def test_docker_user_non_rootless (info_ret ):
97+ with mock .patch .object (docker , 'cmd_output_b' , return_value = info_ret ):
98+ assert docker .get_docker_user () != ()
99+
100+
65101def test_in_docker_no_file ():
66102 with mock .patch .object (builtins , 'open' , side_effect = FileNotFoundError ):
67103 assert docker ._is_in_docker () is False
@@ -195,3 +231,14 @@ def test_docker_hook(tmp_path):
195231
196232 ret = run_language (tmp_path , docker , 'echo hello hello world' )
197233 assert ret == (0 , b'hello hello world\n ' )
234+
235+
236+ @xfailif_windows # pragma: win32 no cover
237+ def test_docker_hook_mount_permissions (tmp_path ):
238+ dockerfile = '''\
239+ FROM ubuntu:22.04
240+ '''
241+ tmp_path .joinpath ('Dockerfile' ).write_text (dockerfile )
242+
243+ retcode , _ = run_language (tmp_path , docker , 'touch' , ('README.md' ,))
244+ assert retcode == 0
0 commit comments