@@ -69,6 +69,7 @@ def test_lightning_run_cluster_without_cloud(monkeypatch):
6969 env = ("FOO=bar" ,),
7070 secret = (),
7171 run_app_comment_commands = False ,
72+ enable_basic_auth = "" ,
7273 )
7374
7475
@@ -96,6 +97,7 @@ def test_lightning_run_app_cloud(mock_dispatch: mock.MagicMock, open_ui, caplog,
9697 env = ("FOO=bar" ,),
9798 secret = ("BAR=my-secret" ,),
9899 run_app_comment_commands = False ,
100+ enable_basic_auth = "" ,
99101 )
100102 # capture logs.
101103 # TODO(yurij): refactor the test, check if the actual HTTP request is being sent and that the proper admin
@@ -112,6 +114,7 @@ def test_lightning_run_app_cloud(mock_dispatch: mock.MagicMock, open_ui, caplog,
112114 secrets = {"BAR" : "my-secret" },
113115 cluster_id = "" ,
114116 run_app_comment_commands = False ,
117+ enable_basic_auth = "" ,
115118 )
116119
117120
@@ -139,6 +142,7 @@ def test_lightning_run_app_cloud_with_run_app_commands(mock_dispatch: mock.Magic
139142 env = ("FOO=bar" ,),
140143 secret = ("BAR=my-secret" ,),
141144 run_app_comment_commands = True ,
145+ enable_basic_auth = "" ,
142146 )
143147 # capture logs.
144148 # TODO(yurij): refactor the test, check if the actual HTTP request is being sent and that the proper admin
@@ -155,6 +159,7 @@ def test_lightning_run_app_cloud_with_run_app_commands(mock_dispatch: mock.Magic
155159 secrets = {"BAR" : "my-secret" },
156160 cluster_id = "" ,
157161 run_app_comment_commands = True ,
162+ enable_basic_auth = "" ,
158163 )
159164
160165
@@ -175,4 +180,45 @@ def test_lightning_run_app_secrets(monkeypatch):
175180 env = (),
176181 secret = ("FOO=my-secret" ),
177182 run_app_comment_commands = False ,
183+ enable_basic_auth = "" ,
178184 )
185+
186+
187+ @mock .patch .dict (os .environ , {"LIGHTNING_CLOUD_URL" : "https://beta.lightning.ai" })
188+ @mock .patch ("lightning_app.cli.lightning_cli.dispatch" )
189+ def test_lightning_run_app_enable_basic_auth_passed (mock_dispatch : mock .MagicMock , caplog , monkeypatch ):
190+ """This test just validates the command has ran properly when --enable-basic-auth argument is passed.
191+
192+ It checks the call to `dispatch` for the right arguments.
193+ """
194+ monkeypatch .setattr ("lightning_app.runners.cloud.logger" , logging .getLogger ())
195+
196+ with caplog .at_level (logging .INFO ):
197+ _run_app (
198+ file = os .path .join (_PROJECT_ROOT , "tests/tests_app/core/scripts/app_metadata.py" ),
199+ cloud = True ,
200+ cluster_id = "" ,
201+ without_server = False ,
202+ name = "" ,
203+ blocking = False ,
204+ open_ui = False ,
205+ no_cache = True ,
206+ env = ("FOO=bar" ,),
207+ secret = ("BAR=my-secret" ,),
208+ run_app_comment_commands = False ,
209+ enable_basic_auth = "username:password" ,
210+ )
211+ mock_dispatch .assert_called_with (
212+ Path (os .path .join (_PROJECT_ROOT , "tests/tests_app/core/scripts/app_metadata.py" )),
213+ RuntimeType .CLOUD ,
214+ start_server = True ,
215+ blocking = False ,
216+ open_ui = False ,
217+ name = "" ,
218+ no_cache = True ,
219+ env_vars = {"FOO" : "bar" },
220+ secrets = {"BAR" : "my-secret" },
221+ cluster_id = "" ,
222+ run_app_comment_commands = False ,
223+ enable_basic_auth = "username:password" ,
224+ )
0 commit comments