Skip to content

Commit 1bc3c37

Browse files
authored
Merge pull request #3613 from ActiveState/mitchell/dx-3189
Stop creating new users.
2 parents 43b2860 + 3654714 commit 1bc3c37

File tree

4 files changed

+16
-63
lines changed

4 files changed

+16
-63
lines changed

internal/testhelpers/e2e/session.go

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ import (
2828
"github.com/ActiveState/cli/internal/subshell/bash"
2929
"github.com/ActiveState/cli/internal/subshell/sscommon"
3030
"github.com/ActiveState/cli/internal/testhelpers/tagsuite"
31-
"github.com/ActiveState/cli/pkg/platform/api"
32-
"github.com/ActiveState/cli/pkg/platform/api/mono"
33-
"github.com/ActiveState/cli/pkg/platform/api/mono/mono_client/users"
3431
"github.com/ActiveState/cli/pkg/platform/api/mono/mono_models"
3532
"github.com/ActiveState/cli/pkg/platform/authentication"
3633
"github.com/ActiveState/cli/pkg/platform/model"
@@ -39,7 +36,6 @@ import (
3936
"github.com/ActiveState/cli/pkg/projectfile"
4037
"github.com/ActiveState/termtest"
4138
"github.com/go-openapi/strfmt"
42-
"github.com/google/uuid"
4339
"github.com/phayes/permbits"
4440
"github.com/stretchr/testify/require"
4541
)
@@ -448,48 +444,8 @@ func (s *Session) LogoutUser() {
448444
p.ExpectExitCode(0)
449445
}
450446

451-
func (s *Session) CreateNewUser() *mono_models.UserEditable {
452-
uid, err := uuid.NewRandom()
453-
require.NoError(s.T, err)
454-
455-
username := fmt.Sprintf("user-%s", uid.String()[0:8])
456-
password := uid.String()[8:]
457-
email := fmt.Sprintf("%[email protected]", username)
458-
user := &mono_models.UserEditable{
459-
Username: username,
460-
Password: password,
461-
Name: username,
462-
Email: email,
463-
}
464-
465-
params := users.NewAddUserParams()
466-
params.SetUser(user)
467-
468-
// The default mono API client host is "testing.tld" inside unit tests.
469-
// Since we actually want to create production users, we need to manually instantiate a mono API
470-
// client with the right host.
471-
serviceURL := api.GetServiceURL(api.ServiceMono)
472-
host := os.Getenv(constants.APIHostEnvVarName)
473-
if host == "" {
474-
host = constants.DefaultAPIHost
475-
}
476-
serviceURL.Host = strings.Replace(serviceURL.Host, string(api.ServiceMono)+api.TestingPlatform, host, 1)
477-
_, err = mono.Init(serviceURL, nil).Users.AddUser(params)
478-
require.NoError(s.T, err, "Error creating new user")
479-
480-
p := s.Spawn(tagsuite.Auth, "--username", username, "--password", password)
481-
p.Expect("logged in")
482-
p.ExpectExitCode(0)
483-
484-
s.users = append(s.users, username)
485-
486-
return user
487-
}
488-
489447
// NotifyProjectCreated indicates that the given project was created on the Platform and needs to
490448
// be deleted when the session is closed.
491-
// This only needs to be called for projects created by PersistentUsername, not projects created by
492-
// users created with CreateNewUser(). Created users' projects are auto-deleted.
493449
func (s *Session) NotifyProjectCreated(org, name string) {
494450
s.createdProjects = append(s.createdProjects, project.NewNamespace(org, name, ""))
495451
}

test/integration/fork_int_test.go

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@ package integration
22

33
import (
44
"testing"
5-
"time"
6-
7-
"github.com/ActiveState/cli/internal/testhelpers/suite"
8-
"github.com/ActiveState/termtest"
95

6+
"github.com/ActiveState/cli/internal/strutils"
107
"github.com/ActiveState/cli/internal/testhelpers/e2e"
8+
"github.com/ActiveState/cli/internal/testhelpers/suite"
119
"github.com/ActiveState/cli/internal/testhelpers/tagsuite"
1210
)
1311

@@ -26,17 +24,13 @@ func (suite *ForkIntegrationTestSuite) TestFork() {
2624
ts := e2e.New(suite.T(), false)
2725
defer suite.cleanup(ts)
2826

29-
user := ts.CreateNewUser()
27+
ts.LoginAsPersistentUser()
28+
pname := strutils.UUID()
3029

31-
cp := ts.Spawn("fork", "ActiveState-CLI/Python3", "--name", "Test-Python3", "--org", user.Username)
30+
cp := ts.Spawn("fork", "ActiveState-CLI/Python3", "--name", pname.String(), "--org", e2e.PersistentUsername)
3231
cp.Expect("fork has been successfully created")
3332
cp.ExpectExitCode(0)
34-
35-
// Check if we error out on conflicts properly
36-
cp = ts.Spawn("fork", "ActiveState-CLI/Python3", "--name", "Test-Python3", "--org", user.Username)
37-
cp.Expect(`You already have a project with the name`)
38-
cp.ExpectExitCode(1)
39-
ts.IgnoreLogErrors()
33+
ts.NotifyProjectCreated(e2e.PersistentUsername, pname.String())
4034
}
4135

4236
func (suite *ForkIntegrationTestSuite) TestFork_FailNameExists() {
@@ -46,7 +40,7 @@ func (suite *ForkIntegrationTestSuite) TestFork_FailNameExists() {
4640
ts.LoginAsPersistentUser()
4741

4842
cp := ts.Spawn("fork", "ActiveState-CLI/Python3", "--org", e2e.PersistentUsername)
49-
cp.Expect("You already have a project with the name 'Python3'", termtest.OptExpectTimeout(30*time.Second))
43+
cp.Expect("You already have a project with the name 'Python3'")
5044
cp.ExpectNotExitCode(0)
5145
ts.IgnoreLogErrors()
5246
}

test/integration/import_int_test.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"github.com/ActiveState/termtest"
1212

1313
"github.com/ActiveState/cli/internal/constants"
14+
"github.com/ActiveState/cli/internal/strutils"
1415
"github.com/ActiveState/cli/internal/testhelpers/e2e"
1516
"github.com/ActiveState/cli/internal/testhelpers/osutil"
1617
"github.com/ActiveState/cli/internal/testhelpers/suite"
@@ -85,12 +86,14 @@ func (suite *ImportIntegrationTestSuite) TestImport() {
8586
ts := e2e.New(suite.T(), false)
8687
defer ts.Close()
8788

88-
user := ts.CreateNewUser()
89-
namespace := fmt.Sprintf("%s/%s", user.Username, "Python3")
89+
ts.LoginAsPersistentUser()
90+
pname := strutils.UUID()
91+
namespace := fmt.Sprintf("%s/%s", e2e.PersistentUsername, pname.String())
9092

9193
cp := ts.Spawn("init", "--language", "python", namespace, ts.Dirs.Work)
9294
cp.Expect("successfully initialized", e2e.RuntimeSourcingTimeoutOpt)
9395
cp.ExpectExitCode(0)
96+
ts.NotifyProjectCreated(e2e.PersistentUsername, pname.String())
9497

9598
reqsFilePath := filepath.Join(cp.WorkDirectory(), reqsFileName)
9699

test/integration/push_int_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,15 @@ func (suite *PushIntegrationTestSuite) TestInitAndPush() {
109109

110110
// Test pushing without permission, and choosing to create a new project
111111
func (suite *PushIntegrationTestSuite) TestPush_NoPermission_NewProject() {
112+
suite.T().Skip("Cannot create new unprivileged users") // DX-3190
112113
if runtime.GOOS == "windows" {
113114
suite.T().Skip("Skipped on Windows for now because SendKeyDown() doesnt work (regardless of bash/cmd)")
114115
}
115116

116117
suite.OnlyRunForTags(tagsuite.Push)
117118
ts := e2e.New(suite.T(), false)
118119
defer ts.Close()
119-
user := ts.CreateNewUser()
120+
ts.LoginAsPersistentUser()
120121
pname := strutils.UUID()
121122

122123
cp := ts.Spawn("config", "set", constants.AsyncRuntimeConfig, "true")
@@ -155,12 +156,11 @@ func (suite *PushIntegrationTestSuite) TestPush_NoPermission_NewProject() {
155156
cp.SendLine(pname.String())
156157
cp.Expect("Project created")
157158
cp.ExpectExitCode(0)
158-
// Note: no need for ts.NotifyProjectCreated because newly created users and their projects are
159-
// auto-cleaned by e2e.
159+
ts.NotifyProjectCreated(e2e.PersistentUsername, pname.String())
160160

161161
pjfile, err = projectfile.Parse(pjfilepath)
162162
suite.Require().NoError(err)
163-
suite.Require().Contains(pjfile.Project, user.Username)
163+
suite.Require().Contains(pjfile.Project, e2e.PersistentUsername)
164164
suite.Require().Contains(pjfile.Project, pname.String())
165165
}
166166

0 commit comments

Comments
 (0)