|
1 | 1 | from Standard.Base import all
|
2 |
| -import Standard.Base.Enso_Cloud.Enso_Secret.Enso_Secret_Error |
3 | 2 | import Standard.Base.Errors.Common.Syntax_Error
|
4 | 3 | import Standard.Base.Errors.Illegal_Argument.Illegal_Argument
|
5 |
| -import Standard.Base.Network.HTTP.Request.Request |
6 | 4 | import Standard.Base.Network.URI.Invalid_Query_String
|
7 | 5 |
|
8 | 6 | from Standard.Test import all
|
9 | 7 |
|
10 |
| -import project.Network.Enso_Cloud.Cloud_Tests_Setup.Cloud_Tests_Setup |
11 |
| - |
12 |
| -polyglot java import org.enso.base.enso_cloud.EnsoSecretHelper |
13 |
| - |
14 | 8 | add_specs suite_builder =
|
15 | 9 | ## To run this test locally:
|
16 | 10 | $ sbt 'http-test-helper/run localhost 8080'
|
@@ -308,73 +302,6 @@ add_specs suite_builder =
|
308 | 302 | uri2.fragment . should_equal "FRAG"
|
309 | 303 | uri2.to_text . should_equal "https://example.com/path#FRAG"
|
310 | 304 |
|
311 |
| - cloud_setup = Cloud_Tests_Setup.prepare |
312 |
| - |
313 |
| - group_builder.specify "will not convert back to URI if secrets are present in the query arguments" pending=cloud_setup.pending <| Test.with_retries <| |
314 |
| - cloud_setup.with_prepared_environment <| |
315 |
| - secret1 = Enso_Secret.create "my_test_secret-uri-1-"+Random.uuid "My Value" |
316 |
| - secret1.should_succeed |
317 |
| - Panic.with_finalizer secret1.delete <| |
318 |
| - uri = URI.from "https://example.com/" |
319 |
| - . add_query_argument "arg1" secret1 |
320 |
| - . add_query_argument "arg2" "plain value" |
321 |
| - |
322 |
| - uri.to_text . should_equal ("https://example.com/?arg1=__SECRET__&arg2=plain+value") |
323 |
| - uri.to_java_uri . should_fail_with Enso_Secret_Error |
324 |
| - uri.raw_query . should_fail_with Enso_Secret_Error |
325 |
| - |
326 |
| - group_builder.specify "should allow to use secrets in query arguments, containing all kinds of various characters" pending=cloud_setup.httpbin_pending <| Test.with_retries <| |
327 |
| - cloud_setup.with_prepared_environment <| |
328 |
| - secret1 = Enso_Secret.create "my_test_secret-uri-4-"+Random.uuid "My Very Secret Value" |
329 |
| - secret1.should_succeed |
330 |
| - Panic.with_finalizer secret1.delete <| |
331 |
| - s2 = "Another Secret Value containing Emoji 😊❤️ and ąęś AND [a=b]:[b=c][d=e]++++!?&->#...__(){}@///\\\|%%%100*^, ]]] ==> <br>a" |
332 |
| - secret2 = Enso_Secret.create "my_test_secret-uri-5"+Random.uuid s2 |
333 |
| - secret2.should_succeed |
334 |
| - Panic.with_finalizer secret2.delete <| |
335 |
| - uri = (cloud_setup.httpbin_secure_uri / "get") |
336 |
| - . add_query_argument "arg1" secret1 |
337 |
| - . add_query_argument "arg2" "plain value" |
338 |
| - . add_query_argument "arg3" secret2 |
339 |
| - |
340 |
| - uri.to_text . should_equal (cloud_setup.httpbin_secure_uri.to_text + "get?arg1=__SECRET__&arg2=plain+value&arg3=__SECRET__") |
341 |
| - uri.raw_query . should_fail_with Enso_Secret_Error |
342 |
| - |
343 |
| - response = cloud_setup.httpbin_secure_client.request (Request.get uri) |
344 |
| - decode_query_params response.decode_as_json . should_equal [["arg1", "My Very Secret Value"], ["arg2", "plain value"], ["arg3", s2]] |
345 |
| - |
346 |
| - group_builder.specify "does not allow secrets in non-https requests" pending=cloud_setup.pending <| Test.with_retries <| |
347 |
| - cloud_setup.with_prepared_environment <| |
348 |
| - secret1 = Enso_Secret.create "my_test_secret-uri-8-"+Random.uuid "My Value" |
349 |
| - secret1.should_succeed |
350 |
| - Panic.with_finalizer secret1.delete <| |
351 |
| - uri1 = URI.from "http://example.com/" |
352 |
| - . add_query_argument "arg1" secret1 |
353 |
| - . add_query_argument "arg2" "plain value" |
354 |
| - |
355 |
| - uri1.to_text . should_equal ("http://example.com/?arg1=__SECRET__&arg2=plain+value") |
356 |
| - r1 = uri1.fetch |
357 |
| - r1.should_fail_with Illegal_Argument |
358 |
| - r1.catch.to_display_text . should_contain "Secrets are not allowed in HTTP connections, use HTTPS instead." |
359 |
| - |
360 |
| - with_secret ~action = |
361 |
| - secret = Enso_Secret.create "my_test_secret-clear-cache-1-"+Random.uuid "My Value" |
362 |
| - secret.should_succeed |
363 |
| - Panic.with_finalizer secret.delete (action secret) |
364 |
| - |
365 |
| - group_builder.specify "EnsoSecreetReader cache should be cleared when a reload is detected" pending=cloud_setup.pending <| Test.with_retries <| |
366 |
| - cloud_setup.with_prepared_environment <| |
367 |
| - with_secret secret1-> with_secret secret2-> |
368 |
| - base_uri = URI.from 'https://httpbin.org/bytes/50' |
369 |
| - uri1 = base_uri . add_query_argument "arg1" secret1 |
370 |
| - uri2 = base_uri . add_query_argument "arg1" secret2 |
371 |
| - uri1.fetch . should_succeed |
372 |
| - uri2.fetch . should_succeed |
373 |
| - (EnsoSecretHelper.getEnsoSecretReaderCacheSize >= 2) . should_be_true |
374 |
| - EnsoSecretHelper.simulateEnsoSecretReaderReload |
375 |
| - uri1.fetch . should_succeed |
376 |
| - (EnsoSecretHelper.getEnsoSecretReaderCacheSize == 1) . should_be_true |
377 |
| - |
378 | 305 | main filter=Nothing =
|
379 | 306 | suite = Test.build suite_builder->
|
380 | 307 | add_specs suite_builder
|
|
0 commit comments