mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-06 17:27:16 +00:00
test: added integration test for secrets get all and secrets get all without connection
This commit is contained in:
@@ -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 │
|
||||||
|
└───────────────┴──────────────┴─────────────┘
|
||||||
@@ -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 │
|
||||||
|
└───────────────┴──────────────┴─────────────┘
|
||||||
@@ -3,9 +3,11 @@ package tests
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/Infisical/infisical-merge/packages/util"
|
||||||
"github.com/bradleyjkemp/cupaloy/v2"
|
"github.com/bradleyjkemp/cupaloy/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
func TestServiceToken_SecretsGetWithImportsAndRecursiveCmd(t *testing.T) {
|
func TestServiceToken_SecretsGetWithImportsAndRecursiveCmd(t *testing.T) {
|
||||||
SetupCli(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)
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user