@@ -895,6 +895,40 @@ def runTest(self):
895
895
self .assertEqual (exec_log , expected )
896
896
897
897
898
+ @unittest .skipIf (not EXEC_DRIVER_IS_NATIVE , 'Exec driver not native' )
899
+ class TestExecuteCommandStringAsUser (BaseTestCase ):
900
+ def runTest (self ):
901
+ container = self .client .create_container ('busybox' , 'cat' ,
902
+ detach = True , stdin_open = True )
903
+ id = container ['Id' ]
904
+ self .client .start (id )
905
+ self .tmp_containers .append (id )
906
+
907
+ res = self .client .exec_create (id , 'whoami' , user = 'default' )
908
+ self .assertIn ('Id' , res )
909
+
910
+ exec_log = self .client .exec_start (res )
911
+ expected = b'default' if six .PY3 else 'default\n '
912
+ self .assertEqual (exec_log , expected )
913
+
914
+
915
+ @unittest .skipIf (not EXEC_DRIVER_IS_NATIVE , 'Exec driver not native' )
916
+ class TestExecuteCommandStringAsRoot (BaseTestCase ):
917
+ def runTest (self ):
918
+ container = self .client .create_container ('busybox' , 'cat' ,
919
+ detach = True , stdin_open = True )
920
+ id = container ['Id' ]
921
+ self .client .start (id )
922
+ self .tmp_containers .append (id )
923
+
924
+ res = self .client .exec_create (id , 'whoami' )
925
+ self .assertIn ('Id' , res )
926
+
927
+ exec_log = self .client .exec_start (res )
928
+ expected = b'root' if six .PY3 else 'root\n '
929
+ self .assertEqual (exec_log , expected )
930
+
931
+
898
932
@unittest .skipIf (not EXEC_DRIVER_IS_NATIVE , 'Exec driver not native' )
899
933
class TestExecuteCommandStreaming (BaseTestCase ):
900
934
def runTest (self ):
0 commit comments