Skip to content

Commit 00d88b9

Browse files
authored
Merge pull request #3790 from ActiveState/mitchell/cp-1277
Login as the integration test user during teardown.
2 parents 8127b02 + 1088462 commit 00d88b9

File tree

3 files changed

+4
-53
lines changed

3 files changed

+4
-53
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,6 @@ jobs:
336336
INTEGRATION_TEST_USERNAME: ${{ secrets.INTEGRATION_TEST_USERNAME }}
337337
INTEGRATION_TEST_PASSWORD: ${{ secrets.INTEGRATION_TEST_PASSWORD }}
338338
INTEGRATION_TEST_TOKEN: ${{ secrets.INTEGRATION_TEST_TOKEN }}
339-
PLATFORM_API_TOKEN: ${{ secrets.PLATFORM_API_TOKEN }}
340339

341340
- # === Check if Unit Tests Failed ===
342341
name: Check if Unit Tests Failed

internal/testhelpers/e2e/clean.go

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,12 @@
11
package e2e
22

33
import (
4-
"testing"
5-
64
"github.com/ActiveState/cli/internal/errs"
75
"github.com/ActiveState/cli/pkg/platform/api/mono/mono_client/projects"
8-
"github.com/ActiveState/cli/pkg/platform/api/mono/mono_client/users"
96
"github.com/ActiveState/cli/pkg/platform/api/mono/mono_models"
107
"github.com/ActiveState/cli/pkg/platform/authentication"
11-
"github.com/ActiveState/cli/pkg/platform/model"
128
)
139

14-
func cleanUser(t *testing.T, username string, auth *authentication.Auth) error {
15-
projects, err := getProjects(username, auth)
16-
if err != nil {
17-
return err
18-
}
19-
for _, proj := range projects {
20-
err = model.DeleteProject(username, proj.Name, auth)
21-
if err != nil {
22-
return err
23-
}
24-
}
25-
26-
return deleteUser(username, auth)
27-
}
28-
2910
func getProjects(org string, auth *authentication.Auth) ([]*mono_models.Project, error) {
3011
authClient, err := auth.Client()
3112
if err != nil {
@@ -40,20 +21,3 @@ func getProjects(org string, auth *authentication.Auth) ([]*mono_models.Project,
4021

4122
return listProjectsOK.Payload, nil
4223
}
43-
44-
func deleteUser(name string, auth *authentication.Auth) error {
45-
authClient, err := auth.Client()
46-
if err != nil {
47-
return errs.Wrap(err, "Could not get auth client")
48-
}
49-
50-
params := users.NewDeleteUserParams()
51-
params.SetUsername(name)
52-
53-
_, err = authClient.Users.DeleteUser(params, auth.ClientAuth())
54-
if err != nil {
55-
return err
56-
}
57-
58-
return nil
59-
}

internal/testhelpers/e2e/session.go

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ type Session struct {
5656
Env []string
5757
retainDirs bool
5858
createdProjects []*project.Namespaced
59-
// users created during session
60-
users []string
6159
T *testing.T
6260
Exe string
6361
SvcExe string
@@ -542,11 +540,6 @@ func (s *Session) Close() error {
542540

543541
s.spawned = []*SpawnedCmd{}
544542

545-
if os.Getenv("PLATFORM_API_TOKEN") == "" {
546-
s.T.Log("PLATFORM_API_TOKEN env var not set, not running suite tear down")
547-
return nil
548-
}
549-
550543
auth := authentication.New(cfg)
551544

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

562555
err = auth.AuthenticateWithModel(&mono_models.Credentials{
563-
Token: os.Getenv("PLATFORM_API_TOKEN"),
556+
Username: PersistentUsername,
557+
Password: PersistentPassword,
564558
})
565559
if err != nil {
560+
s.T.Errorf("Could not login: %v", errs.JoinMessage(err))
566561
return err
567562
}
568563

@@ -586,14 +581,7 @@ func (s *Session) Close() error {
586581
for _, proj := range s.createdProjects {
587582
err := model.DeleteProject(proj.Owner, proj.Project, auth)
588583
if err != nil {
589-
s.T.Errorf("Could not delete project %s: %v", proj.Project, errs.JoinMessage(err))
590-
}
591-
}
592-
593-
for _, user := range s.users {
594-
err := cleanUser(s.T, user, auth)
595-
if err != nil {
596-
s.T.Errorf("Could not delete user %s: %v", user, errs.JoinMessage(err))
584+
s.T.Errorf("Could not delete project %s/%s: %v", proj.Owner, proj.Project, errs.JoinMessage(err))
597585
}
598586
}
599587

0 commit comments

Comments
 (0)