Skip to content

Commit a31e7e6

Browse files
author
Matthew Fisher
authored
feat(cmd): add auth:whoami --all tests (#250)
1 parent 404cc5d commit a31e7e6

File tree

3 files changed

+28
-9
lines changed

3 files changed

+28
-9
lines changed

tests/auth_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ var _ = Describe("deis auth", func() {
6565
auth.Whoami(user)
6666
})
6767

68+
Specify("that user can print extensive information about themself", func() {
69+
auth.WhoamiAll(user)
70+
})
71+
6872
Specify("that user can regenerates their own token", func() {
6973
auth.Regenerate(user)
7074
})

tests/cmd/auth/commands.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,18 @@ func Whoami(user model.User) {
7272
Expect(err).NotTo(HaveOccurred())
7373
}
7474

75+
func WhoamiAll(user model.User) {
76+
sess, err := cmd.Start("deis auth:whoami --all", &user)
77+
Eventually(sess).Should(Say("ID: 0\nUsername: %s\nEmail: %s", user.Username, user.Email))
78+
Eventually(sess).Should(Say(`First Name: `))
79+
Eventually(sess).Should(Say(`Last Name: `))
80+
Eventually(sess).Should(Say(`Last Login: `))
81+
Eventually(sess).Should(Say("Is Superuser: %t\nIs Staff: %t\nIs Active: true\n", user.IsSuperuser, user.IsSuperuser))
82+
Eventually(sess).Should(Say(`Date Joined: `))
83+
Eventually(sess).Should(Exit(0))
84+
Expect(err).NotTo(HaveOccurred())
85+
}
86+
7587
// Regenerate executes `deis auth:regenerate` as the specified user.
7688
func Regenerate(user model.User) {
7789
sess, err := cmd.Start("deis auth:regenerate", &user)

tests/model/model.go

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,26 @@ import (
1313
)
1414

1515
var Admin = User{
16-
Username: "admin",
17-
Password: "admin",
18-
16+
Username: "admin",
17+
Password: "admin",
18+
19+
IsSuperuser: false,
1920
}
2021

2122
type User struct {
22-
Username string
23-
Password string
24-
Email string
23+
Username string
24+
Password string
25+
Email string
26+
IsSuperuser bool
2527
}
2628

2729
func NewUser() User {
2830
randSuffix := rand.Intn(999999999)
2931
return User{
30-
Username: fmt.Sprintf("test-%d", randSuffix),
31-
Password: "asdf1234",
32-
Email: fmt.Sprintf("test-%[email protected]", randSuffix),
32+
Username: fmt.Sprintf("test-%d", randSuffix),
33+
Password: "asdf1234",
34+
Email: fmt.Sprintf("test-%[email protected]", randSuffix),
35+
IsSuperuser: false,
3336
}
3437
}
3538

0 commit comments

Comments
 (0)