refact(e2e): Add support for authenticating as any user

This commit is contained in:
Michael Li committed 2022-10-25 16:23:52 -04:00
1 parent 220456d092
commit 5d795e6104
8 files changed
+21 -11

No files matched your search

+14 -4
View File
@@ -4,6 +4,7 @@ package boundary
import (
"context"
"fmt"
"os"
"testing"
"github.com/hashicorp/boundary/api"
@@ -59,16 +60,25 @@ func NewApiClient() (*api.Client, error) {
return client, err
}
// AuthenticateCli uses the cli to authenticate the specified Boundary instance.
func AuthenticateCli(t testing.TB) {
// AuthenticateAdminCli uses the cli to authenticate the specified Boundary instance as an admin
func AuthenticateAdminCli(t testing.TB) {
c, err := loadConfig()
require.NoError(t, err)
AuthenticateCli(t, c.AdminLoginName, c.AdminLoginPassword)
}
// AuthenticateCli uses the cli to authenticate the specified Boundary instance
func AuthenticateCli(t testing.TB, loginName string, password string) {
c, err := loadConfig()
require.NoError(t, err)
os.Setenv("E2E_TEST_BOUNDARY_PASSWORD", password)
output := e2e.RunCommand(context.Background(), "boundary", "authenticate", "password",
"-addr", c.Address,
"-auth-method-id", c.AuthMethodId,
"-login-name", c.AdminLoginName,
"-password", "env://E2E_PASSWORD_ADMIN_PASSWORD",
"-login-name", loginName,
"-password", "env://E2E_TEST_BOUNDARY_PASSWORD",
)
require.NoError(t, output.Err, string(output.Stderr))
}
@@ -52,7 +52,7 @@ func TestCreateVaultCredentialStoreCli(t *testing.T) {
c, err := loadConfig()
require.NoError(t, err)
boundary.AuthenticateCli(t)
boundary.AuthenticateAdminCli(t)
newOrgId := boundary.CreateNewOrgCli(t)
newProjectId := boundary.CreateNewProjectCli(t, newOrgId)
newHostCatalogId := boundary.CreateNewHostCatalogCli(t, newProjectId)
@@ -50,7 +50,7 @@ func TestCreateAwsDynamicHostCatalogCli(t *testing.T) {
c, err := loadConfig()
require.NoError(t, err)
boundary.AuthenticateCli(t)
boundary.AuthenticateAdminCli(t)
newOrgId := boundary.CreateNewOrgCli(t)
newProjectId := boundary.CreateNewProjectCli(t, newOrgId)
@@ -23,7 +23,7 @@ func TestConnectTargetWithAuthzTokenCli(t *testing.T) {
c, err := loadConfig()
require.NoError(t, err)
boundary.AuthenticateCli(t)
boundary.AuthenticateAdminCli(t)
newOrgId := boundary.CreateNewOrgCli(t)
newProjectId := boundary.CreateNewProjectCli(t, newOrgId)
newHostCatalogId := boundary.CreateNewHostCatalogCli(t, newProjectId)
@@ -23,7 +23,7 @@ func TestConnectTargetWithSshCli(t *testing.T) {
c, err := loadConfig()
require.NoError(t, err)
boundary.AuthenticateCli(t)
boundary.AuthenticateAdminCli(t)
newOrgId := boundary.CreateNewOrgCli(t)
newProjectId := boundary.CreateNewProjectCli(t, newOrgId)
newHostCatalogId := boundary.CreateNewHostCatalogCli(t, newProjectId)
@@ -18,7 +18,7 @@ func TestConnectTargetCli(t *testing.T) {
c, err := loadConfig()
require.NoError(t, err)
boundary.AuthenticateCli(t)
boundary.AuthenticateAdminCli(t)
newOrgId := boundary.CreateNewOrgCli(t)
newProjectId := boundary.CreateNewProjectCli(t, newOrgId)
newHostCatalogId := boundary.CreateNewHostCatalogCli(t, newProjectId)
@@ -21,7 +21,7 @@ func TestSessionCancelCli(t *testing.T) {
c, err := loadConfig()
require.NoError(t, err)
boundary.AuthenticateCli(t)
boundary.AuthenticateAdminCli(t)
newOrgId := boundary.CreateNewOrgCli(t)
newProjectId := boundary.CreateNewProjectCli(t, newOrgId)
newHostCatalogId := boundary.CreateNewHostCatalogCli(t, newProjectId)
@@ -21,7 +21,7 @@ func TestStaticCredentialStoreCli(t *testing.T) {
c, err := loadConfig()
require.NoError(t, err)
boundary.AuthenticateCli(t)
boundary.AuthenticateAdminCli(t)
newOrgId := boundary.CreateNewOrgCli(t)
newProjectId := boundary.CreateNewProjectCli(t, newOrgId)
newCredentialStoreId := boundary.CreateNewCredentialStoreStaticCli(t, newProjectId)