mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-11 05:28:51 +00:00
Fix: Use login UA token
This commit is contained in:
+29
-21
@@ -3,8 +3,6 @@ package tests
|
|||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/Infisical/infisical-merge/packages/util"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var DEV_SECRETS = []Secret{
|
var DEV_SECRETS = []Secret{
|
||||||
@@ -46,19 +44,21 @@ var ALL_SECRET_KEYS = []string{}
|
|||||||
var ALL_SECRET_VALUES = []string{}
|
var ALL_SECRET_VALUES = []string{}
|
||||||
|
|
||||||
type Credentials struct {
|
type Credentials struct {
|
||||||
ClientID string
|
ClientID string
|
||||||
ClientSecret string
|
ClientSecret string
|
||||||
ServiceToken string
|
UAAccessToken string
|
||||||
ProjectID string
|
ServiceToken string
|
||||||
EnvSlug string
|
ProjectID string
|
||||||
|
EnvSlug string
|
||||||
}
|
}
|
||||||
|
|
||||||
var creds = Credentials{
|
var creds = Credentials{
|
||||||
ClientID: os.Getenv("CLI_TESTS_UA_CLIENT_ID"),
|
UAAccessToken: "",
|
||||||
ClientSecret: os.Getenv("CLI_TESTS_UA_CLIENT_SECRET"),
|
ClientID: os.Getenv("CLI_TESTS_UA_CLIENT_ID"),
|
||||||
ServiceToken: os.Getenv("CLI_TESTS_SERVICE_TOKEN"),
|
ClientSecret: os.Getenv("CLI_TESTS_UA_CLIENT_SECRET"),
|
||||||
ProjectID: os.Getenv("CLI_TESTS_PROJECT_ID"),
|
ServiceToken: os.Getenv("CLI_TESTS_SERVICE_TOKEN"),
|
||||||
EnvSlug: os.Getenv("CLI_TESTS_ENV_SLUG"),
|
ProjectID: os.Getenv("CLI_TESTS_PROJECT_ID"),
|
||||||
|
EnvSlug: os.Getenv("CLI_TESTS_ENV_SLUG"),
|
||||||
}
|
}
|
||||||
|
|
||||||
func initialize() {
|
func initialize() {
|
||||||
@@ -79,29 +79,37 @@ func initialize() {
|
|||||||
func Test_RunTests(t *testing.T) {
|
func Test_RunTests(t *testing.T) {
|
||||||
initialize()
|
initialize()
|
||||||
|
|
||||||
res, err := util.UniversalAuthLogin(creds.ClientID, creds.ClientSecret)
|
t.Run("User login command", func(t *testing.T) {
|
||||||
if err != nil {
|
UALoginCmd(t)
|
||||||
t.Errorf("Error: %v", err)
|
})
|
||||||
}
|
|
||||||
universalAuthAccessToken := res.AccessToken
|
t.Run("Run command", func(t *testing.T) {
|
||||||
|
RunCmd(t, creds.UAAccessToken, creds.ProjectID, creds.EnvSlug)
|
||||||
|
RunCmd(t, creds.ServiceToken, creds.ProjectID, creds.EnvSlug)
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("Run Command (without imports, with recursive)", func(t *testing.T) {
|
||||||
|
RunCmdWithoutImportsAndWithRecursive(t, creds.UAAccessToken, creds.ProjectID, creds.EnvSlug)
|
||||||
|
RunCmdWithoutImportsAndWithRecursive(t, creds.ServiceToken, creds.ProjectID, creds.EnvSlug)
|
||||||
|
})
|
||||||
|
|
||||||
t.Run("Export secrets", func(t *testing.T) {
|
t.Run("Export secrets", func(t *testing.T) {
|
||||||
ExportSecrets(t, universalAuthAccessToken, creds.ProjectID, creds.EnvSlug)
|
ExportSecrets(t, creds.UAAccessToken, creds.ProjectID, creds.EnvSlug)
|
||||||
ExportSecrets(t, creds.ServiceToken, creds.ProjectID, creds.EnvSlug)
|
ExportSecrets(t, creds.ServiceToken, creds.ProjectID, creds.EnvSlug)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("Export secrets (without imports)", func(t *testing.T) {
|
t.Run("Export secrets (without imports)", func(t *testing.T) {
|
||||||
ExportSecretsWithoutImports(t, universalAuthAccessToken, creds.ProjectID, creds.EnvSlug)
|
ExportSecretsWithoutImports(t, creds.UAAccessToken, creds.ProjectID, creds.EnvSlug)
|
||||||
ExportSecretsWithoutImports(t, creds.ServiceToken, creds.ProjectID, creds.EnvSlug)
|
ExportSecretsWithoutImports(t, creds.ServiceToken, creds.ProjectID, creds.EnvSlug)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("List Secrets (with imports and recursive)", func(t *testing.T) {
|
t.Run("List Secrets (with imports and recursive)", func(t *testing.T) {
|
||||||
ListSecretsWithImportsAndRecursive(t, universalAuthAccessToken, creds.ProjectID, creds.EnvSlug)
|
ListSecretsWithImportsAndRecursive(t, creds.UAAccessToken, creds.ProjectID, creds.EnvSlug)
|
||||||
ListSecretsWithImportsAndRecursive(t, creds.ServiceToken, creds.ProjectID, creds.EnvSlug)
|
ListSecretsWithImportsAndRecursive(t, creds.ServiceToken, creds.ProjectID, creds.EnvSlug)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("Get Secrets by Names", func(t *testing.T) {
|
t.Run("Get Secrets by Names", func(t *testing.T) {
|
||||||
GetSecretsByNames(t, universalAuthAccessToken, creds.ProjectID, creds.EnvSlug)
|
GetSecretsByNames(t, creds.UAAccessToken, creds.ProjectID, creds.EnvSlug)
|
||||||
GetSecretsByNames(t, creds.ServiceToken, creds.ProjectID, creds.EnvSlug)
|
GetSecretsByNames(t, creds.ServiceToken, creds.ProjectID, creds.EnvSlug)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user