@@ -56,6 +56,19 @@ def test_build_image_minimal(self):
5656 rm = True ,
5757 )
5858
59+ @patch ("samcli.local.docker.image_build_client.LOG" )
60+ def test_build_image_extra_params_logs_warning (self , mock_log ):
61+ """Test that extra_params triggers a warning and is not passed to SDK"""
62+ mock_image = Mock ()
63+ mock_logs = iter ([])
64+
65+ self .mock_container_client .images .build .return_value = (mock_image , mock_logs )
66+ self .client .build_image (** self .base_build_args , extra_params = ["--ssh" , "default" ])
67+ mock_log .warning .assert_called_once ()
68+ self .assertIn ("DockerBuildExtraParams" , mock_log .warning .call_args [0 ][0 ])
69+
70+ self .mock_container_client .images .build .assert_called_once_with (** self .base_build_args , rm = True )
71+
5972 def test_is_available_returns_true (self ):
6073 """Test that is_available always returns True for SDK"""
6174 result = SDKBuildClient .is_available ("docker" )
@@ -202,6 +215,28 @@ def test_build_image_handles_failure(self, mock_popen):
202215 self .assertIn ("Build failed with exit code 1" , str (context .exception ))
203216 self .assertEqual (context .exception .build_log , [{"stream" : "Step 1/5\n " }, {"stream" : "Error: build failed\n " }])
204217
218+ @patch ("samcli.local.docker.image_build_client.subprocess.Popen" )
219+ def test_build_image_docker_with_extra_params (self , mock_popen ):
220+ """Test that extra_params are appended to the docker command"""
221+ mock_process = Mock ()
222+ mock_process .stdout = iter (["Done\n " ])
223+ mock_process .returncode = 0
224+ mock_popen .return_value = mock_process
225+
226+ list (
227+ self .docker_client .build_image (
228+ ** self .base_build_args ,
229+ extra_params = ["--ssh" , "default" , "--secret" , "id=mysecret,src=secret.txt" ],
230+ )
231+ )
232+
233+ actual_cmd = mock_popen .call_args [0 ][0 ]
234+ self .assertEqual (actual_cmd [- 1 ], self .base_build_args ["path" ])
235+ self .assertIn ("--ssh" , actual_cmd )
236+ self .assertIn ("default" , actual_cmd )
237+ self .assertIn ("--secret" , actual_cmd )
238+ self .assertIn ("id=mysecret,src=secret.txt" , actual_cmd )
239+
205240 @patch ("samcli.local.docker.image_build_client.shutil.which" )
206241 @patch ("samcli.local.docker.image_build_client.subprocess.run" )
207242 def test_is_available_docker_success (self , mock_run , mock_which ):
0 commit comments