@@ -69,6 +69,7 @@ def test_lightning_run_cluster_without_cloud(monkeypatch):
69
69
env = ("FOO=bar" ,),
70
70
secret = (),
71
71
run_app_comment_commands = False ,
72
+ enable_basic_auth = "" ,
72
73
)
73
74
74
75
@@ -96,6 +97,7 @@ def test_lightning_run_app_cloud(mock_dispatch: mock.MagicMock, open_ui, caplog,
96
97
env = ("FOO=bar" ,),
97
98
secret = ("BAR=my-secret" ,),
98
99
run_app_comment_commands = False ,
100
+ enable_basic_auth = "" ,
99
101
)
100
102
# capture logs.
101
103
# 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,
112
114
secrets = {"BAR" : "my-secret" },
113
115
cluster_id = "" ,
114
116
run_app_comment_commands = False ,
117
+ enable_basic_auth = "" ,
115
118
)
116
119
117
120
@@ -139,6 +142,7 @@ def test_lightning_run_app_cloud_with_run_app_commands(mock_dispatch: mock.Magic
139
142
env = ("FOO=bar" ,),
140
143
secret = ("BAR=my-secret" ,),
141
144
run_app_comment_commands = True ,
145
+ enable_basic_auth = "" ,
142
146
)
143
147
# capture logs.
144
148
# 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
155
159
secrets = {"BAR" : "my-secret" },
156
160
cluster_id = "" ,
157
161
run_app_comment_commands = True ,
162
+ enable_basic_auth = "" ,
158
163
)
159
164
160
165
@@ -175,4 +180,45 @@ def test_lightning_run_app_secrets(monkeypatch):
175
180
env = (),
176
181
secret = ("FOO=my-secret" ),
177
182
run_app_comment_commands = False ,
183
+ enable_basic_auth = "" ,
178
184
)
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