Skip to content

Commit

Permalink
Merge branch version/0-42-0-RC1 to adopt changes from PR #2852
Browse files Browse the repository at this point in the history
  • Loading branch information
as-builds committed Oct 30, 2023
2 parents 5da4d8d + b3c8db6 commit a855228
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 40 deletions.
29 changes: 1 addition & 28 deletions internal/runners/auth/auth.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
package auth

import (
"github.com/ActiveState/cli/internal/errs"
"github.com/ActiveState/cli/internal/keypairs"
"github.com/ActiveState/cli/internal/locale"
"github.com/ActiveState/cli/internal/output"
"github.com/ActiveState/cli/internal/primer"
"github.com/ActiveState/cli/internal/prompt"
authlet "github.com/ActiveState/cli/pkg/cmdlets/auth"
"github.com/ActiveState/cli/pkg/platform/authentication"
"github.com/ActiveState/cli/pkg/platform/model"
)

type Auth struct {
Expand Down Expand Up @@ -72,37 +70,12 @@ func (a *Auth) Run(params *AuthParams) error {
}

username := a.Auth.WhoAmI()
organization, err := model.FetchOrgByURLName(username, a.Auth)
if err != nil {
return errs.Wrap(err, "Could not fetch organizations")
}

tiers, err := model.FetchTiers()
if err != nil {
return errs.Wrap(err, "Could not fetch tiers")
}

tier := organization.Tier
privateProjects := false
for _, t := range tiers {
if tier == t.Name && t.RequiresPayment {
privateProjects = true
break
}
}

a.Outputer.Print(output.Prepare(
locale.T("logged_in_as", map[string]string{"Name": username}),
&struct {
Username string `json:"username,omitempty"`
URLName string `json:"urlname,omitempty"`
Tier string `json:"tier,omitempty"`
PrivateProjects bool `json:"privateProjects"`
Username string `json:"username"`
}{
username,
organization.URLname,
tier,
privateProjects,
},
))

Expand Down
17 changes: 5 additions & 12 deletions test/integration/auth_int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,20 +87,13 @@ func (suite *AuthIntegrationTestSuite) ensureLogout(ts *e2e.Session) {
}

type userJSON struct {
Username string `json:"username,omitempty"`
URLName string `json:"urlname,omitempty"`
Tier string `json:"tier,omitempty"`
PrivateProjects bool `json:"privateProjects"`
Username string `json:"username,omitempty"`
}

func (suite *AuthIntegrationTestSuite) authOutput(method string) {
user := userJSON{
Username: e2e.PersistentUsername,
URLName: e2e.PersistentUsername,
Tier: "free",
PrivateProjects: false,
}
data, err := json.Marshal(user)
data, err := json.Marshal(userJSON{
Username: e2e.PersistentUsername,
})
suite.Require().NoError(err)

ts := e2e.New(suite.T(), false)
Expand All @@ -109,7 +102,7 @@ func (suite *AuthIntegrationTestSuite) authOutput(method string) {
expected := string(data)
ts.LoginAsPersistentUser()
cp := ts.Spawn(tagsuite.Auth, "--output", method)
cp.Expect("false}")
cp.Expect(`"}`)
cp.ExpectExitCode(0)
suite.Contains(cp.Output(), fmt.Sprintf("%s", string(expected)))
}
Expand Down

0 comments on commit a855228

Please sign in to comment.