Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,6 @@ jobs:
INTEGRATION_TEST_USERNAME: ${{ secrets.INTEGRATION_TEST_USERNAME }}
INTEGRATION_TEST_PASSWORD: ${{ secrets.INTEGRATION_TEST_PASSWORD }}
INTEGRATION_TEST_TOKEN: ${{ secrets.INTEGRATION_TEST_TOKEN }}
PLATFORM_API_TOKEN: ${{ secrets.PLATFORM_API_TOKEN }}

- # === Check if Unit Tests Failed ===
name: Check if Unit Tests Failed
Expand Down
36 changes: 0 additions & 36 deletions internal/testhelpers/e2e/clean.go
Original file line number Diff line number Diff line change
@@ -1,31 +1,12 @@
package e2e

import (
"testing"

"github.com/ActiveState/cli/internal/errs"
"github.com/ActiveState/cli/pkg/platform/api/mono/mono_client/projects"
"github.com/ActiveState/cli/pkg/platform/api/mono/mono_client/users"
"github.com/ActiveState/cli/pkg/platform/api/mono/mono_models"
"github.com/ActiveState/cli/pkg/platform/authentication"
"github.com/ActiveState/cli/pkg/platform/model"
)

func cleanUser(t *testing.T, username string, auth *authentication.Auth) error {
projects, err := getProjects(username, auth)
if err != nil {
return err
}
for _, proj := range projects {
err = model.DeleteProject(username, proj.Name, auth)
if err != nil {
return err
}
}

return deleteUser(username, auth)
}

func getProjects(org string, auth *authentication.Auth) ([]*mono_models.Project, error) {
authClient, err := auth.Client()
if err != nil {
Expand All @@ -40,20 +21,3 @@ func getProjects(org string, auth *authentication.Auth) ([]*mono_models.Project,

return listProjectsOK.Payload, nil
}

func deleteUser(name string, auth *authentication.Auth) error {
authClient, err := auth.Client()
if err != nil {
return errs.Wrap(err, "Could not get auth client")
}

params := users.NewDeleteUserParams()
params.SetUsername(name)

_, err = authClient.Users.DeleteUser(params, auth.ClientAuth())
if err != nil {
return err
}

return nil
}
20 changes: 4 additions & 16 deletions internal/testhelpers/e2e/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ type Session struct {
Env []string
retainDirs bool
createdProjects []*project.Namespaced
// users created during session
users []string
T *testing.T
Exe string
SvcExe string
Expand Down Expand Up @@ -542,11 +540,6 @@ func (s *Session) Close() error {

s.spawned = []*SpawnedCmd{}

if os.Getenv("PLATFORM_API_TOKEN") == "" {
s.T.Log("PLATFORM_API_TOKEN env var not set, not running suite tear down")
return nil
}

auth := authentication.New(cfg)

if os.Getenv(constants.APIHostEnvVarName) == "" {
Expand All @@ -560,9 +553,11 @@ func (s *Session) Close() error {
}

err = auth.AuthenticateWithModel(&mono_models.Credentials{
Token: os.Getenv("PLATFORM_API_TOKEN"),
Username: PersistentUsername,
Password: PersistentPassword,
})
if err != nil {
s.T.Errorf("Could not login: %v", errs.JoinMessage(err))
return err
}

Expand All @@ -586,14 +581,7 @@ func (s *Session) Close() error {
for _, proj := range s.createdProjects {
err := model.DeleteProject(proj.Owner, proj.Project, auth)
if err != nil {
s.T.Errorf("Could not delete project %s: %v", proj.Project, errs.JoinMessage(err))
}
}

for _, user := range s.users {
err := cleanUser(s.T, user, auth)
if err != nil {
s.T.Errorf("Could not delete user %s: %v", user, errs.JoinMessage(err))
s.T.Errorf("Could not delete project %s/%s: %v", proj.Owner, proj.Project, errs.JoinMessage(err))
}
}

Expand Down