Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

Fix: Integrated UA login test

Daniel Hougaard2b215a510c7a
diff --git a/cli/test/login.go b/cli/test/login.go
new file mode 100644
index 0000000000..0f45914132
--- /dev/null
+++ b/cli/test/login.go
@@ -0,0 +1,29 @@
+package tests
+
+import (
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+)
+
+func MachineIdentityLoginCmd(t *testing.T) {
+ SetupCli(t)
+
+ if creds.UAAccessToken != "" {
+ return
+ }
+
+ jwtPattern := `^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$`
+
+ output, err := ExecuteCliCommand(FORMATTED_CLI_NAME, "login", "--method=universal-auth", "--client-id", creds.ClientID, "--client-secret", creds.ClientSecret, "--plain", "--silent")
+
+ if err != nil {
+ t.Fatalf("error running CLI command: %v", err)
+ }
+
+ assert.Regexp(t, jwtPattern, output)
+
+ creds.UAAccessToken = output
+
+ // We can't use snapshot testing here because the output will be different every time
+}