refact(e2e): Add context as an argument for cli methods
This was done have some alignment with the corresponding api methods as well as matching standard Go conventions.
This commit is contained in:
1 parent
a956e8dec9
commit
57ffc71849
15 files changed
+107
-110
No files matched your search
@@ -39,11 +39,10 @@ func CreateNewAccountApi(t testing.TB, ctx context.Context, client *api.Client,
|
||||
|
||||
// CreateNewAccountCli creates a new account using the cli.
|
||||
// Returns the id of the new account as well as the password that was generated
|
||||
func CreateNewAccountCli(t testing.TB, loginName string) (string, string) {
|
||||
func CreateNewAccountCli(t testing.TB, ctx context.Context, loginName string) (string, string) {
|
||||
c, err := loadConfig()
|
||||
require.NoError(t, err)
|
||||
|
||||
ctx := context.Background()
|
||||
password, err := base62.Random(16)
|
||||
require.NoError(t, err)
|
||||
output := e2e.RunCommand(ctx, "boundary",
|
||||
@@ -66,7 +65,7 @@ func CreateNewAccountCli(t testing.TB, loginName string) (string, string) {
|
||||
|
||||
newAccountId := newAccountResult.Item.Id
|
||||
t.Cleanup(func() {
|
||||
AuthenticateAdminCli(t)
|
||||
AuthenticateAdminCli(t, context.Background())
|
||||
output := e2e.RunCommand(ctx, "boundary",
|
||||
e2e.WithArgs("accounts", "delete", "-id", newAccountId),
|
||||
)
|
||||
|
||||
@@ -60,19 +60,19 @@ func NewApiClient() (*api.Client, error) {
|
||||
}
|
||||
|
||||
// AuthenticateAdminCli uses the cli to authenticate the specified Boundary instance as an admin
|
||||
func AuthenticateAdminCli(t testing.TB) {
|
||||
func AuthenticateAdminCli(t testing.TB, ctx context.Context) {
|
||||
c, err := loadConfig()
|
||||
require.NoError(t, err)
|
||||
|
||||
AuthenticateCli(t, c.AdminLoginName, c.AdminLoginPassword)
|
||||
AuthenticateCli(t, ctx, c.AdminLoginName, c.AdminLoginPassword)
|
||||
}
|
||||
|
||||
// AuthenticateCli uses the cli to authenticate the specified Boundary instance
|
||||
func AuthenticateCli(t testing.TB, loginName string, password string) {
|
||||
func AuthenticateCli(t testing.TB, ctx context.Context, loginName string, password string) {
|
||||
c, err := loadConfig()
|
||||
require.NoError(t, err)
|
||||
|
||||
output := e2e.RunCommand(context.Background(), "boundary",
|
||||
output := e2e.RunCommand(ctx, "boundary",
|
||||
e2e.WithArgs(
|
||||
"authenticate", "password",
|
||||
"-addr", c.Address,
|
||||
|
||||
@@ -25,8 +25,8 @@ func CreateNewCredentialStoreStaticApi(t testing.TB, ctx context.Context, client
|
||||
|
||||
// CreateNewCredentialStoreStaticCli creates a new static credential store using the cli.
|
||||
// Returns the id of the new credential store
|
||||
func CreateNewCredentialStoreStaticCli(t testing.TB, projectId string) string {
|
||||
output := e2e.RunCommand(context.Background(), "boundary",
|
||||
func CreateNewCredentialStoreStaticCli(t testing.TB, ctx context.Context, projectId string) string {
|
||||
output := e2e.RunCommand(ctx, "boundary",
|
||||
e2e.WithArgs(
|
||||
"credential-stores", "create", "static",
|
||||
"-scope-id", projectId,
|
||||
|
||||
@@ -61,8 +61,8 @@ func AddHostToHostSetApi(t testing.TB, ctx context.Context, client *api.Client,
|
||||
|
||||
// CreateNewHostCatalogCli creates a new host catalog in boundary using the cli.
|
||||
// Returns the id of the new host catalog.
|
||||
func CreateNewHostCatalogCli(t testing.TB, projectId string) string {
|
||||
output := e2e.RunCommand(context.Background(), "boundary",
|
||||
func CreateNewHostCatalogCli(t testing.TB, ctx context.Context, projectId string) string {
|
||||
output := e2e.RunCommand(ctx, "boundary",
|
||||
e2e.WithArgs(
|
||||
"host-catalogs", "create", "static",
|
||||
"-scope-id", projectId,
|
||||
@@ -82,8 +82,8 @@ func CreateNewHostCatalogCli(t testing.TB, projectId string) string {
|
||||
|
||||
// CreateNewHostSetCli creates a new host set in boundary using the cli.
|
||||
// Returns the id of the new host set.
|
||||
func CreateNewHostSetCli(t testing.TB, hostCatalogId string) string {
|
||||
output := e2e.RunCommand(context.Background(), "boundary",
|
||||
func CreateNewHostSetCli(t testing.TB, ctx context.Context, hostCatalogId string) string {
|
||||
output := e2e.RunCommand(ctx, "boundary",
|
||||
e2e.WithArgs(
|
||||
"host-sets", "create", "static",
|
||||
"-host-catalog-id", hostCatalogId,
|
||||
@@ -103,8 +103,8 @@ func CreateNewHostSetCli(t testing.TB, hostCatalogId string) string {
|
||||
|
||||
// CreateNewHostCli creates a new host in boundary using the cli.
|
||||
// Returns the id of the new host.
|
||||
func CreateNewHostCli(t testing.TB, hostCatalogId string, address string) string {
|
||||
output := e2e.RunCommand(context.Background(), "boundary",
|
||||
func CreateNewHostCli(t testing.TB, ctx context.Context, hostCatalogId string, address string) string {
|
||||
output := e2e.RunCommand(ctx, "boundary",
|
||||
e2e.WithArgs(
|
||||
"hosts", "create", "static",
|
||||
"-host-catalog-id", hostCatalogId,
|
||||
@@ -124,8 +124,8 @@ func CreateNewHostCli(t testing.TB, hostCatalogId string, address string) string
|
||||
}
|
||||
|
||||
// AddHostToHostSetCli adds a host to a host set using the cli
|
||||
func AddHostToHostSetCli(t testing.TB, hostSetId string, hostId string) {
|
||||
output := e2e.RunCommand(context.Background(), "boundary",
|
||||
func AddHostToHostSetCli(t testing.TB, ctx context.Context, hostSetId string, hostId string) {
|
||||
output := e2e.RunCommand(ctx, "boundary",
|
||||
e2e.WithArgs("host-sets", "add-hosts", "-id", hostSetId, "-host", hostId),
|
||||
)
|
||||
require.NoError(t, output.Err, string(output.Stderr))
|
||||
|
||||
@@ -43,8 +43,7 @@ func CreateNewProjectApi(t testing.TB, ctx context.Context, client *api.Client,
|
||||
|
||||
// CreateNewOrgCli creates a new organization in boundary using the cli.
|
||||
// Returns the id of the new org.
|
||||
func CreateNewOrgCli(t testing.TB) string {
|
||||
ctx := context.Background()
|
||||
func CreateNewOrgCli(t testing.TB, ctx context.Context) string {
|
||||
output := e2e.RunCommand(ctx, "boundary",
|
||||
e2e.WithArgs(
|
||||
"scopes", "create",
|
||||
@@ -61,7 +60,7 @@ func CreateNewOrgCli(t testing.TB) string {
|
||||
|
||||
newOrgId := newOrgResult.Item.Id
|
||||
t.Cleanup(func() {
|
||||
AuthenticateAdminCli(t)
|
||||
AuthenticateAdminCli(t, context.Background())
|
||||
output := e2e.RunCommand(ctx, "boundary",
|
||||
e2e.WithArgs("scopes", "delete", "-id", newOrgId),
|
||||
)
|
||||
@@ -75,8 +74,7 @@ func CreateNewOrgCli(t testing.TB) string {
|
||||
// CreateNewProjectCli creates a new project in boundary using the cli. The project will be created
|
||||
// under the provided org id.
|
||||
// Returns the id of the new project.
|
||||
func CreateNewProjectCli(t testing.TB, orgId string) string {
|
||||
ctx := context.Background()
|
||||
func CreateNewProjectCli(t testing.TB, ctx context.Context, orgId string) string {
|
||||
output := e2e.RunCommand(ctx, "boundary",
|
||||
e2e.WithArgs(
|
||||
"scopes", "create",
|
||||
|
||||
@@ -41,8 +41,8 @@ func AddHostSourceToTargetApi(t testing.TB, ctx context.Context, client *api.Cli
|
||||
|
||||
// CreateNewTargetCli creates a new target in boundary using the cli
|
||||
// Returns the id of the new target.
|
||||
func CreateNewTargetCli(t testing.TB, projectId string, defaultPort string) string {
|
||||
output := e2e.RunCommand(context.Background(), "boundary",
|
||||
func CreateNewTargetCli(t testing.TB, ctx context.Context, projectId string, defaultPort string) string {
|
||||
output := e2e.RunCommand(ctx, "boundary",
|
||||
e2e.WithArgs(
|
||||
"targets", "create", "tcp",
|
||||
"-scope-id", projectId,
|
||||
@@ -62,8 +62,8 @@ func CreateNewTargetCli(t testing.TB, projectId string, defaultPort string) stri
|
||||
}
|
||||
|
||||
// AddHostSourceToTargetCli adds a host source (host set or host) to a target using the cli
|
||||
func AddHostSourceToTargetCli(t testing.TB, targetId string, hostSourceId string) {
|
||||
output := e2e.RunCommand(context.Background(), "boundary",
|
||||
func AddHostSourceToTargetCli(t testing.TB, ctx context.Context, targetId string, hostSourceId string) {
|
||||
output := e2e.RunCommand(ctx, "boundary",
|
||||
e2e.WithArgs("targets", "add-host-sources", "-id", targetId, "-host-source", hostSourceId),
|
||||
)
|
||||
require.NoError(t, output.Err, string(output.Stderr))
|
||||
|
||||
@@ -29,8 +29,7 @@ func CreateNewUserApi(t testing.TB, ctx context.Context, client *api.Client, sco
|
||||
|
||||
// CreateNewUserCli creates a new user using the cli.
|
||||
// Returns the id of the new user
|
||||
func CreateNewUserCli(t testing.TB, scopeId string) string {
|
||||
ctx := context.Background()
|
||||
func CreateNewUserCli(t testing.TB, ctx context.Context, scopeId string) string {
|
||||
output := e2e.RunCommand(ctx, "boundary",
|
||||
e2e.WithArgs(
|
||||
"users", "create",
|
||||
@@ -48,7 +47,7 @@ func CreateNewUserCli(t testing.TB, scopeId string) string {
|
||||
|
||||
newUserId := newUserResult.Item.Id
|
||||
t.Cleanup(func() {
|
||||
AuthenticateAdminCli(t)
|
||||
AuthenticateAdminCli(t, context.Background())
|
||||
output := e2e.RunCommand(ctx, "boundary",
|
||||
e2e.WithArgs("users", "delete", "-id", newUserId),
|
||||
)
|
||||
@@ -60,8 +59,8 @@ func CreateNewUserCli(t testing.TB, scopeId string) string {
|
||||
}
|
||||
|
||||
// SetAccountToUserCli sets an account to a the specified user using the cli.
|
||||
func SetAccountToUserCli(t testing.TB, userId string, accountId string) {
|
||||
output := e2e.RunCommand(context.Background(), "boundary",
|
||||
func SetAccountToUserCli(t testing.TB, ctx context.Context, userId string, accountId string) {
|
||||
output := e2e.RunCommand(ctx, "boundary",
|
||||
e2e.WithArgs(
|
||||
"users", "set-accounts",
|
||||
"-id", userId,
|
||||
|
||||
@@ -52,18 +52,19 @@ func TestCreateVaultCredentialStoreCli(t *testing.T) {
|
||||
c, err := loadConfig()
|
||||
require.NoError(t, err)
|
||||
|
||||
boundary.AuthenticateAdminCli(t)
|
||||
newOrgId := boundary.CreateNewOrgCli(t)
|
||||
newProjectId := boundary.CreateNewProjectCli(t, newOrgId)
|
||||
newHostCatalogId := boundary.CreateNewHostCatalogCli(t, newProjectId)
|
||||
newHostSetId := boundary.CreateNewHostSetCli(t, newHostCatalogId)
|
||||
newHostId := boundary.CreateNewHostCli(t, newHostCatalogId, c.TargetIp)
|
||||
boundary.AddHostToHostSetCli(t, newHostSetId, newHostId)
|
||||
newTargetId := boundary.CreateNewTargetCli(t, newProjectId, c.TargetPort)
|
||||
boundary.AddHostSourceToTargetCli(t, newTargetId, newHostSetId)
|
||||
ctx := context.Background()
|
||||
boundary.AuthenticateAdminCli(t, ctx)
|
||||
newOrgId := boundary.CreateNewOrgCli(t, ctx)
|
||||
newProjectId := boundary.CreateNewProjectCli(t, ctx, newOrgId)
|
||||
newHostCatalogId := boundary.CreateNewHostCatalogCli(t, ctx, newProjectId)
|
||||
newHostSetId := boundary.CreateNewHostSetCli(t, ctx, newHostCatalogId)
|
||||
newHostId := boundary.CreateNewHostCli(t, ctx, newHostCatalogId, c.TargetIp)
|
||||
boundary.AddHostToHostSetCli(t, ctx, newHostSetId, newHostId)
|
||||
newTargetId := boundary.CreateNewTargetCli(t, ctx, newProjectId, c.TargetPort)
|
||||
boundary.AddHostSourceToTargetCli(t, ctx, newTargetId, newHostSetId)
|
||||
|
||||
// Configure vault
|
||||
ctx := context.Background()
|
||||
|
||||
vaultAddr, boundaryPolicyName := vault.Setup(t)
|
||||
|
||||
output := e2e.RunCommand(ctx, "vault",
|
||||
|
||||
@@ -50,12 +50,12 @@ func TestCreateAwsDynamicHostCatalogCli(t *testing.T) {
|
||||
c, err := loadConfig()
|
||||
require.NoError(t, err)
|
||||
|
||||
boundary.AuthenticateAdminCli(t)
|
||||
newOrgId := boundary.CreateNewOrgCli(t)
|
||||
newProjectId := boundary.CreateNewProjectCli(t, newOrgId)
|
||||
ctx := context.Background()
|
||||
boundary.AuthenticateAdminCli(t, ctx)
|
||||
newOrgId := boundary.CreateNewOrgCli(t, ctx)
|
||||
newProjectId := boundary.CreateNewProjectCli(t, ctx, newOrgId)
|
||||
|
||||
// Create a dynamic host catalog
|
||||
ctx := context.Background()
|
||||
output := e2e.RunCommand(ctx, "boundary",
|
||||
e2e.WithArgs(
|
||||
"host-catalogs", "create", "plugin",
|
||||
@@ -228,8 +228,8 @@ func TestCreateAwsDynamicHostCatalogCli(t *testing.T) {
|
||||
assert.Equal(t, expectedHostCatalogCount, actualHostCatalogCount, "Numbers of hosts in host catalog did not match expected amount")
|
||||
|
||||
// Create target
|
||||
newTargetId := boundary.CreateNewTargetCli(t, newProjectId, c.TargetPort)
|
||||
boundary.AddHostSourceToTargetCli(t, newTargetId, newHostSetId1)
|
||||
newTargetId := boundary.CreateNewTargetCli(t, ctx, newProjectId, c.TargetPort)
|
||||
boundary.AddHostSourceToTargetCli(t, ctx, newTargetId, newHostSetId1)
|
||||
|
||||
// Connect to target
|
||||
output = e2e.RunCommand(ctx, "boundary",
|
||||
|
||||
@@ -23,19 +23,19 @@ func TestConnectTargetWithAuthzTokenCli(t *testing.T) {
|
||||
c, err := loadConfig()
|
||||
require.NoError(t, err)
|
||||
|
||||
boundary.AuthenticateAdminCli(t)
|
||||
newOrgId := boundary.CreateNewOrgCli(t)
|
||||
newProjectId := boundary.CreateNewProjectCli(t, newOrgId)
|
||||
newHostCatalogId := boundary.CreateNewHostCatalogCli(t, newProjectId)
|
||||
newHostSetId := boundary.CreateNewHostSetCli(t, newHostCatalogId)
|
||||
newHostId := boundary.CreateNewHostCli(t, newHostCatalogId, c.TargetIp)
|
||||
boundary.AddHostToHostSetCli(t, newHostSetId, newHostId)
|
||||
newTargetId := boundary.CreateNewTargetCli(t, newProjectId, c.TargetPort)
|
||||
boundary.AddHostSourceToTargetCli(t, newTargetId, newHostSetId)
|
||||
newCredentialStoreId := boundary.CreateNewCredentialStoreStaticCli(t, newProjectId)
|
||||
ctx := context.Background()
|
||||
boundary.AuthenticateAdminCli(t, ctx)
|
||||
newOrgId := boundary.CreateNewOrgCli(t, ctx)
|
||||
newProjectId := boundary.CreateNewProjectCli(t, ctx, newOrgId)
|
||||
newHostCatalogId := boundary.CreateNewHostCatalogCli(t, ctx, newProjectId)
|
||||
newHostSetId := boundary.CreateNewHostSetCli(t, ctx, newHostCatalogId)
|
||||
newHostId := boundary.CreateNewHostCli(t, ctx, newHostCatalogId, c.TargetIp)
|
||||
boundary.AddHostToHostSetCli(t, ctx, newHostSetId, newHostId)
|
||||
newTargetId := boundary.CreateNewTargetCli(t, ctx, newProjectId, c.TargetPort)
|
||||
boundary.AddHostSourceToTargetCli(t, ctx, newTargetId, newHostSetId)
|
||||
newCredentialStoreId := boundary.CreateNewCredentialStoreStaticCli(t, ctx, newProjectId)
|
||||
|
||||
// Create credentials
|
||||
ctx := context.Background()
|
||||
output := e2e.RunCommand(ctx, "boundary",
|
||||
e2e.WithArgs(
|
||||
"credentials", "create", "ssh-private-key",
|
||||
|
||||
@@ -23,19 +23,19 @@ func TestConnectTargetWithSshCli(t *testing.T) {
|
||||
c, err := loadConfig()
|
||||
require.NoError(t, err)
|
||||
|
||||
boundary.AuthenticateAdminCli(t)
|
||||
newOrgId := boundary.CreateNewOrgCli(t)
|
||||
newProjectId := boundary.CreateNewProjectCli(t, newOrgId)
|
||||
newHostCatalogId := boundary.CreateNewHostCatalogCli(t, newProjectId)
|
||||
newHostSetId := boundary.CreateNewHostSetCli(t, newHostCatalogId)
|
||||
newHostId := boundary.CreateNewHostCli(t, newHostCatalogId, c.TargetIp)
|
||||
boundary.AddHostToHostSetCli(t, newHostSetId, newHostId)
|
||||
newTargetId := boundary.CreateNewTargetCli(t, newProjectId, c.TargetPort)
|
||||
boundary.AddHostSourceToTargetCli(t, newTargetId, newHostSetId)
|
||||
newCredentialStoreId := boundary.CreateNewCredentialStoreStaticCli(t, newProjectId)
|
||||
ctx := context.Background()
|
||||
boundary.AuthenticateAdminCli(t, ctx)
|
||||
newOrgId := boundary.CreateNewOrgCli(t, ctx)
|
||||
newProjectId := boundary.CreateNewProjectCli(t, ctx, newOrgId)
|
||||
newHostCatalogId := boundary.CreateNewHostCatalogCli(t, ctx, newProjectId)
|
||||
newHostSetId := boundary.CreateNewHostSetCli(t, ctx, newHostCatalogId)
|
||||
newHostId := boundary.CreateNewHostCli(t, ctx, newHostCatalogId, c.TargetIp)
|
||||
boundary.AddHostToHostSetCli(t, ctx, newHostSetId, newHostId)
|
||||
newTargetId := boundary.CreateNewTargetCli(t, ctx, newProjectId, c.TargetPort)
|
||||
boundary.AddHostSourceToTargetCli(t, ctx, newTargetId, newHostSetId)
|
||||
newCredentialStoreId := boundary.CreateNewCredentialStoreStaticCli(t, ctx, newProjectId)
|
||||
|
||||
// Create credentials
|
||||
ctx := context.Background()
|
||||
output := e2e.RunCommand(ctx, "boundary",
|
||||
e2e.WithArgs(
|
||||
"credentials", "create", "ssh-private-key",
|
||||
|
||||
@@ -18,18 +18,18 @@ func TestConnectTargetCli(t *testing.T) {
|
||||
c, err := loadConfig()
|
||||
require.NoError(t, err)
|
||||
|
||||
boundary.AuthenticateAdminCli(t)
|
||||
newOrgId := boundary.CreateNewOrgCli(t)
|
||||
newProjectId := boundary.CreateNewProjectCli(t, newOrgId)
|
||||
newHostCatalogId := boundary.CreateNewHostCatalogCli(t, newProjectId)
|
||||
newHostSetId := boundary.CreateNewHostSetCli(t, newHostCatalogId)
|
||||
newHostId := boundary.CreateNewHostCli(t, newHostCatalogId, c.TargetIp)
|
||||
boundary.AddHostToHostSetCli(t, newHostSetId, newHostId)
|
||||
newTargetId := boundary.CreateNewTargetCli(t, newProjectId, c.TargetPort)
|
||||
boundary.AddHostSourceToTargetCli(t, newTargetId, newHostSetId)
|
||||
ctx := context.Background()
|
||||
boundary.AuthenticateAdminCli(t, ctx)
|
||||
newOrgId := boundary.CreateNewOrgCli(t, ctx)
|
||||
newProjectId := boundary.CreateNewProjectCli(t, ctx, newOrgId)
|
||||
newHostCatalogId := boundary.CreateNewHostCatalogCli(t, ctx, newProjectId)
|
||||
newHostSetId := boundary.CreateNewHostSetCli(t, ctx, newHostCatalogId)
|
||||
newHostId := boundary.CreateNewHostCli(t, ctx, newHostCatalogId, c.TargetIp)
|
||||
boundary.AddHostToHostSetCli(t, ctx, newHostSetId, newHostId)
|
||||
newTargetId := boundary.CreateNewTargetCli(t, ctx, newProjectId, c.TargetPort)
|
||||
boundary.AddHostSourceToTargetCli(t, ctx, newTargetId, newHostSetId)
|
||||
|
||||
// Connect to target and print host's IP address
|
||||
ctx := context.Background()
|
||||
output := e2e.RunCommand(ctx, "boundary",
|
||||
e2e.WithArgs(
|
||||
"connect",
|
||||
|
||||
@@ -21,15 +21,16 @@ func TestSessionCancelAdminCli(t *testing.T) {
|
||||
c, err := loadConfig()
|
||||
require.NoError(t, err)
|
||||
|
||||
boundary.AuthenticateAdminCli(t)
|
||||
newOrgId := boundary.CreateNewOrgCli(t)
|
||||
newProjectId := boundary.CreateNewProjectCli(t, newOrgId)
|
||||
newHostCatalogId := boundary.CreateNewHostCatalogCli(t, newProjectId)
|
||||
newHostSetId := boundary.CreateNewHostSetCli(t, newHostCatalogId)
|
||||
newHostId := boundary.CreateNewHostCli(t, newHostCatalogId, c.TargetIp)
|
||||
boundary.AddHostToHostSetCli(t, newHostSetId, newHostId)
|
||||
newTargetId := boundary.CreateNewTargetCli(t, newProjectId, c.TargetPort)
|
||||
boundary.AddHostSourceToTargetCli(t, newTargetId, newHostSetId)
|
||||
ctx := context.Background()
|
||||
boundary.AuthenticateAdminCli(t, ctx)
|
||||
newOrgId := boundary.CreateNewOrgCli(t, ctx)
|
||||
newProjectId := boundary.CreateNewProjectCli(t, ctx, newOrgId)
|
||||
newHostCatalogId := boundary.CreateNewHostCatalogCli(t, ctx, newProjectId)
|
||||
newHostSetId := boundary.CreateNewHostSetCli(t, ctx, newHostCatalogId)
|
||||
newHostId := boundary.CreateNewHostCli(t, ctx, newHostCatalogId, c.TargetIp)
|
||||
boundary.AddHostToHostSetCli(t, ctx, newHostSetId, newHostId)
|
||||
newTargetId := boundary.CreateNewTargetCli(t, ctx, newProjectId, c.TargetPort)
|
||||
boundary.AddHostSourceToTargetCli(t, ctx, newTargetId, newHostSetId)
|
||||
|
||||
// Connect to target to create a session
|
||||
ctxCancel, cancel := context.WithCancel(context.Background())
|
||||
@@ -55,7 +56,6 @@ func TestSessionCancelAdminCli(t *testing.T) {
|
||||
t.Cleanup(cancel)
|
||||
|
||||
// Get list of sessions
|
||||
ctx := context.Background()
|
||||
var session *sessions.Session
|
||||
err = backoff.RetryNotify(
|
||||
func() error {
|
||||
|
||||
@@ -25,23 +25,23 @@ func TestSessionCancelUserCli(t *testing.T) {
|
||||
c, err := loadConfig()
|
||||
require.NoError(t, err)
|
||||
|
||||
boundary.AuthenticateAdminCli(t)
|
||||
newOrgId := boundary.CreateNewOrgCli(t)
|
||||
newProjectId := boundary.CreateNewProjectCli(t, newOrgId)
|
||||
newHostCatalogId := boundary.CreateNewHostCatalogCli(t, newProjectId)
|
||||
newHostSetId := boundary.CreateNewHostSetCli(t, newHostCatalogId)
|
||||
newHostId := boundary.CreateNewHostCli(t, newHostCatalogId, c.TargetIp)
|
||||
boundary.AddHostToHostSetCli(t, newHostSetId, newHostId)
|
||||
newTargetId := boundary.CreateNewTargetCli(t, newProjectId, c.TargetPort)
|
||||
boundary.AddHostSourceToTargetCli(t, newTargetId, newHostSetId)
|
||||
ctx := context.Background()
|
||||
boundary.AuthenticateAdminCli(t, ctx)
|
||||
newOrgId := boundary.CreateNewOrgCli(t, ctx)
|
||||
newProjectId := boundary.CreateNewProjectCli(t, ctx, newOrgId)
|
||||
newHostCatalogId := boundary.CreateNewHostCatalogCli(t, ctx, newProjectId)
|
||||
newHostSetId := boundary.CreateNewHostSetCli(t, ctx, newHostCatalogId)
|
||||
newHostId := boundary.CreateNewHostCli(t, ctx, newHostCatalogId, c.TargetIp)
|
||||
boundary.AddHostToHostSetCli(t, ctx, newHostSetId, newHostId)
|
||||
newTargetId := boundary.CreateNewTargetCli(t, ctx, newProjectId, c.TargetPort)
|
||||
boundary.AddHostSourceToTargetCli(t, ctx, newTargetId, newHostSetId)
|
||||
acctName := "e2e-account"
|
||||
newAccountId, acctPassword := boundary.CreateNewAccountCli(t, acctName)
|
||||
newUserId := boundary.CreateNewUserCli(t, "global")
|
||||
boundary.SetAccountToUserCli(t, newUserId, newAccountId)
|
||||
newAccountId, acctPassword := boundary.CreateNewAccountCli(t, ctx, acctName)
|
||||
newUserId := boundary.CreateNewUserCli(t, ctx, "global")
|
||||
boundary.SetAccountToUserCli(t, ctx, newUserId, newAccountId)
|
||||
|
||||
// Try to connect to the target as a user without permissions
|
||||
ctx := context.Background()
|
||||
boundary.AuthenticateCli(t, acctName, acctPassword)
|
||||
boundary.AuthenticateCli(t, ctx, acctName, acctPassword)
|
||||
output := e2e.RunCommand(ctx, "boundary",
|
||||
e2e.WithArgs(
|
||||
"connect",
|
||||
@@ -66,7 +66,7 @@ func TestSessionCancelUserCli(t *testing.T) {
|
||||
t.Log("Successfully received an error when connecting to target as a user without permissions")
|
||||
|
||||
// Create a role
|
||||
boundary.AuthenticateAdminCli(t)
|
||||
boundary.AuthenticateAdminCli(t, ctx)
|
||||
output = e2e.RunCommand(ctx, "boundary",
|
||||
e2e.WithArgs(
|
||||
"roles", "create",
|
||||
@@ -106,7 +106,7 @@ func TestSessionCancelUserCli(t *testing.T) {
|
||||
ctxCancel, cancel := context.WithCancel(context.Background())
|
||||
errChan := make(chan *e2e.CommandResult)
|
||||
go func() {
|
||||
boundary.AuthenticateCli(t, acctName, acctPassword)
|
||||
boundary.AuthenticateCli(t, ctx, acctName, acctPassword)
|
||||
t.Log("Starting session as user...")
|
||||
errChan <- e2e.RunCommand(ctxCancel, "boundary",
|
||||
e2e.WithArgs(
|
||||
|
||||
@@ -20,13 +20,13 @@ func TestStaticCredentialStoreCli(t *testing.T) {
|
||||
c, err := loadConfig()
|
||||
require.NoError(t, err)
|
||||
|
||||
boundary.AuthenticateAdminCli(t)
|
||||
newOrgId := boundary.CreateNewOrgCli(t)
|
||||
newProjectId := boundary.CreateNewProjectCli(t, newOrgId)
|
||||
newCredentialStoreId := boundary.CreateNewCredentialStoreStaticCli(t, newProjectId)
|
||||
ctx := context.Background()
|
||||
boundary.AuthenticateAdminCli(t, ctx)
|
||||
newOrgId := boundary.CreateNewOrgCli(t, ctx)
|
||||
newProjectId := boundary.CreateNewProjectCli(t, ctx, newOrgId)
|
||||
newCredentialStoreId := boundary.CreateNewCredentialStoreStaticCli(t, ctx, newProjectId)
|
||||
|
||||
// Create ssh key credentials
|
||||
ctx := context.Background()
|
||||
output := e2e.RunCommand(ctx, "boundary",
|
||||
e2e.WithArgs(
|
||||
"credentials", "create", "ssh-private-key",
|
||||
|
||||
Reference in new issue
Block a user