Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
test: added integration test for secrets get all and secrets get all without connection
Sheen Capadngan772dd464f564
diff --git a/cli/test/.snapshots/test-TestUserAuth_SecretsGetAll b/cli/test/.snapshots/test-TestUserAuth_SecretsGetAllnew file mode 100644index 0000000000..260607e976--- /dev/null+++ b/cli/test/.snapshots/test-TestUserAuth_SecretsGetAll@@ -0,0 +1,7 @@+┌───────────────┬──────────────┬─────────────┐+│ SECRET NAME │ SECRET VALUE │ SECRET TYPE │+├───────────────┼──────────────┼─────────────┤+│ TEST-SECRET-1 │ test-value-1 │ shared │+│ TEST-SECRET-2 │ test-value-2 │ shared │+│ TEST-SECRET-3 │ test-value-3 │ shared │+└───────────────┴──────────────┴─────────────┘diff --git a/cli/test/.snapshots/test-TestUserAuth_SecretsGetAllWithoutConnection b/cli/test/.snapshots/test-TestUserAuth_SecretsGetAllWithoutConnectionnew file mode 100644index 0000000000..c48627f73f--- /dev/null+++ b/cli/test/.snapshots/test-TestUserAuth_SecretsGetAllWithoutConnection@@ -0,0 +1,8 @@+Warning: Unable to fetch latest secret(s) due to connection error, serving secrets from last successful fetch. For more info, run with --debug+┌───────────────┬──────────────┬─────────────┐+│ SECRET NAME │ SECRET VALUE │ SECRET TYPE │+├───────────────┼──────────────┼─────────────┤+│ TEST-SECRET-1 │ test-value-1 │ shared │+│ TEST-SECRET-2 │ test-value-2 │ shared │+│ TEST-SECRET-3 │ test-value-3 │ shared │+└───────────────┴──────────────┴─────────────┘diff --git a/cli/test/secrets_test.go b/cli/test/secrets_test.goindex 453666406d..b9c8fa85d9 100644--- a/cli/test/secrets_test.go+++ b/cli/test/secrets_test.go@@ -3,9 +3,11 @@ package testsimport ("testing"+ "github.com/Infisical/infisical-merge/packages/util""github.com/bradleyjkemp/cupaloy/v2")+func TestServiceToken_SecretsGetWithImportsAndRecursiveCmd(t *testing.T) {SetupCli(t)@@ -85,3 +87,45 @@ func TestUniversalAuth_SecretsGetWrongEnvironment(t *testing.T) {}}++func TestUserAuth_SecretsGetAll(t *testing.T) {+ SetupCli(t)+ output, err := ExecuteCliCommand(FORMATTED_CLI_NAME, "secrets", "--projectId", creds.ProjectID, "--env", creds.EnvSlug, "--include-imports=false", "--silent")+ if err != nil {+ t.Fatalf("error running CLI command: %v", err)+ }++ // Use cupaloy to snapshot test the output+ err = cupaloy.Snapshot(output)+ if err != nil {+ t.Fatalf("snapshot failed: %v", err)+ }+}++func TestUserAuth_SecretsGetAllWithoutConnection(t *testing.T) {+ SetupCli(t)++ originalConfigFile, err := util.GetConfigFile()+ if err != nil {+ t.Fatalf("error getting config file")+ }+ newConfigFile := originalConfigFile++ // set it to a URL that will always be unreachable+ newConfigFile.LoggedInUserDomain = "http://localhost:4999"+ util.WriteConfigFile(&newConfigFile)++ // restore config file+ defer util.WriteConfigFile(&originalConfigFile)++ output, err := ExecuteCliCommand(FORMATTED_CLI_NAME, "secrets", "--projectId", creds.ProjectID, "--env", creds.EnvSlug, "--include-imports=false", "--silent")+ if err != nil {+ t.Fatalf("error running CLI command: %v", err)+ }++ // Use cupaloy to snapshot test the output+ err = cupaloy.Snapshot(output)+ if err != nil {+ t.Fatalf("snapshot failed: %v", err)+ }+}\ No newline at end of file