Skip to content

Commit

Permalink
checkpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
radeusgd committed Jan 18, 2024
1 parent 3e9252a commit 7eb5a72
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions test/Base_Tests/src/Network/Enso_Cloud/Secrets_Spec.enso
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ import Standard.Base.Data.Base_64.Base_64
import Standard.Base.Data.Enso_Cloud.Enso_Secret.Derived_Secret_Value
import Standard.Base.Data.Enso_Cloud.Enso_Secret.Enso_Secret_Error
import Standard.Base.Data.Enso_Cloud.Utils as Internal_Cloud_Utils
import Standard.Base.Errors.Common.Forbidden_Operation
import Standard.Base.Errors.Common.Not_Found
import Standard.Base.Errors.Illegal_Argument.Illegal_Argument
import Standard.Base.Errors.Illegal_State.Illegal_State
import Standard.Base.Network.HTTP.Request.Request

from Standard.Test import Test, Test_Suite
from Standard.Test.Execution_Context_Helpers import run_with_and_without_output
import Standard.Test.Test_Environment
import Standard.Test.Extensions

Expand All @@ -21,8 +23,10 @@ polyglot java import org.enso.base.enso_cloud.EnsoSecretAccessDenied
spec setup:Cloud_Tests_Setup = setup.with_prepared_environment <|
Test.group "Enso Cloud Secrets" pending=setup.pending <|
Test.specify "should be able to list existing secrets" <|
# We cannot test much more because we do not know what secrets are already there, further tests will check more by creating and deleting secrets
Enso_Secret.list . should_be_a Vector
# This should work regardless of Output context setting:
run_with_and_without_output <|
# We cannot test much more because we do not know what secrets are already there, further tests will check more by creating and deleting secrets
Enso_Secret.list . should_be_a Vector

Test.specify "should allow to create, list and delete secrets" <|
my_secret = Enso_Secret.create "my_test_secret" "my_secret_value"
Expand Down Expand Up @@ -177,19 +181,29 @@ spec setup:Cloud_Tests_Setup = setup.with_prepared_environment <|
https = setup.httpbin_secure_client
response = https.request (Request.get (setup.httpbin_secure_uri / "get") headers=[Header.new "X-My-Nested-Secret" nested_secret])
response.decode_as_json.at "headers" . at "X-My-Nested-Secret" . should_equal "NESTED_secret_value"
##

Test.specify "should allow to update secrets within a sub-directory" pending=(setup.real_cloud_pending.if_nothing setup.httpbin_pending) <|
subdirectory = Enso_File.root.create_directory "my_test_subdirectory-3"
subdirectory.should_succeed
Panic.with_finalizer subdirectory.delete <|
nested_secret = Enso_Secret.create "my-nested-secret-3" "NESTED_secret_value" parent=subdirectory
nested_secret = Enso_Secret.create "my-nested-secret-3" "Value-A" parent=subdirectory
nested_secret.should_succeed
Panic.with_finalizer nested_secret.delete <|
with_retries <|
https = setup.httpbin_secure_client
response = https.request (Request.get (setup.httpbin_secure_uri / "get") headers=[Header.new "X-My-Nested-Secret" nested_secret])
response.decode_as_json.at "headers" . at "X-My-Nested-Secret" . should_equal "NESTED_secret_value"
response.decode_as_json.at "headers" . at "X-My-Nested-Secret" . should_equal "Value-A"

nested_secret.update_value TODO

Test.specify "should NOT be able to create/update/delete secrets with disabled Output Context" <|
Context.Output.with_disabled <|
Enso_Secret.create "foo" "bar" . should_fail_with Forbidden_Operation

secret1 = Enso_Secret.create "my_test_secret-13" "Something"
secret1.should_succeed
Panic.with_finalizer secret1.delete <|
TODO


main = Test_Suite.run_main (spec Cloud_Tests_Setup.prepare)
Expand Down

0 comments on commit 7eb5a72

Please sign in to comment.