-
Notifications
You must be signed in to change notification settings - Fork 112
Expand file tree
/
Copy pathauth_test.go
More file actions
68 lines (57 loc) · 1.81 KB
/
auth_test.go
File metadata and controls
68 lines (57 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package _tests_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Auth", func() {
Context("when logged out", func() {
BeforeEach(func() {
logout()
})
It("won't print the current user", func() {
output, err := execute("deis auth:whoami")
Expect(err).To(HaveOccurred())
Expect(output).To(ContainSubstring("Not logged in."))
Expect(output).NotTo(ContainSubstring(testUser))
})
})
Context("when logged in", func() {
BeforeEach(func() {
login(url, testUser, testPassword)
})
It("can log out", func() {
logout()
})
It("won't register twice", func() {
cmd := "deis register %s --username=%s --password=%s --email=%s"
output, err := execute(cmd, url, testUser, testPassword, testEmail)
Expect(err).To(HaveOccurred())
Expect(output).To(ContainSubstring("Registration failed"))
})
It("prints the current user", func() {
output, err := execute("deis auth:whoami")
Expect(err).NotTo(HaveOccurred())
Expect(output).To(ContainSubstring("You are %s", testUser))
})
It("regenerates the token for the current user", func() {
output, err := execute("deis auth:regenerate")
Expect(err).NotTo(HaveOccurred())
Expect(output).To(ContainSubstring("Token Regenerated"))
})
})
Context("when logged in as an admin", func() {
BeforeEach(func() {
login(url, testAdminUser, testAdminPassword)
})
It("regenerates the token for a specified user", func() {
output, err := execute("deis auth:regenerate -u %s", testUser)
Expect(err).NotTo(HaveOccurred())
Expect(output).To(ContainSubstring("Token Regenerated"))
})
It("regenerates the token for all users", func() {
output, err := execute("deis auth:regenerate --all")
Expect(err).NotTo(HaveOccurred())
Expect(output).To(ContainSubstring("Token Regenerated"))
})
})
})