Skip to content

Commit c6ab0ff

Browse files
committed
tests(perms): implement half of permissions tests
The remaining TODO: items depend on an application being deployed, which ideally would have been done once already in BeforeSuite.
1 parent 5ca102d commit c6ab0ff

1 file changed

Lines changed: 43 additions & 11 deletions

File tree

_tests/perms_test.go

Lines changed: 43 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,39 @@ package _tests_test
22

33
import (
44
. "github.com/onsi/ginkgo"
5-
// . "github.com/onsi/gomega"
5+
. "github.com/onsi/gomega"
66
)
77

88
var _ = Describe("Perms", func() {
99
Context("when logged in as an admin user", func() {
10+
BeforeEach(func() {
11+
login(url, testAdminUser, testAdminPassword)
12+
})
1013

11-
XIt("can create, list, and delete admin permissions", func() {
12-
// "deis perms:create %s --admin", user
13-
// "deis perms:list --app=%s", app
14-
// "deis perms:delete %s --admin", user
15-
// "deis perms:list --app=%s", app
14+
It("can create, list, and delete admin permissions", func() {
15+
output, err := execute("deis perms:create %s --admin", testUser)
16+
Expect(err).NotTo(HaveOccurred())
17+
Expect(output).To(
18+
ContainSubstring("Adding %s to system administrators... done\n", testUser))
19+
output, err = execute("deis perms:list --admin")
20+
Expect(err).NotTo(HaveOccurred())
21+
Expect(output).To(SatisfyAll(
22+
HavePrefix("=== Administrators"),
23+
ContainSubstring(testUser),
24+
ContainSubstring(testAdminUser)))
25+
output, err = execute("deis perms:delete %s --admin", testUser)
26+
Expect(err).NotTo(HaveOccurred())
27+
Expect(output).To(
28+
ContainSubstring("Removing %s from system administrators... done", testUser))
29+
output, err = execute("deis perms:list --admin")
30+
Expect(err).NotTo(HaveOccurred())
31+
Expect(output).To(SatisfyAll(
32+
HavePrefix("=== Administrators"),
33+
ContainSubstring(testAdminUser)))
34+
Expect(output).NotTo(ContainSubstring(testUser))
1635
})
1736

37+
// TODO: need an app already deployed--do this in BeforeSuite
1838
XIt("can create, list, and delete app permissions", func() {
1939
// "deis perms:create %s --app=%s", user, app
2040
// "deis perms:list --app=%s", app
@@ -24,14 +44,26 @@ var _ = Describe("Perms", func() {
2444
})
2545

2646
Context("when logged in as a normal user", func() {
47+
BeforeEach(func() {
48+
login(url, testUser, testPassword)
49+
})
2750

28-
XIt("can't create, list, or delete admin permissions", func() {
29-
// "deis perms:create %s --admin", user
30-
// "deis perms:list --app=%s", app
31-
// "deis perms:delete %s --admin", user
32-
// "deis perms:list --app=%s", app
51+
It("can't create, list, or delete admin permissions", func() {
52+
output, err := execute("deis perms:create %s --admin", testAdminUser)
53+
Expect(err).To(HaveOccurred())
54+
Expect(output).To(ContainSubstring("403 FORBIDDEN"))
55+
output, err = execute("deis perms:list --admin")
56+
Expect(err).To(HaveOccurred())
57+
Expect(output).To(ContainSubstring("403 FORBIDDEN"))
58+
output, err = execute("deis perms:delete %s --admin", testAdminUser)
59+
Expect(err).To(HaveOccurred())
60+
Expect(output).To(ContainSubstring("403 FORBIDDEN"))
61+
output, err = execute("deis perms:list --admin")
62+
Expect(err).To(HaveOccurred())
63+
Expect(output).To(ContainSubstring("403 FORBIDDEN"))
3364
})
3465

66+
// TODO: need an app already deployed--do this in BeforeSuite
3567
XIt("can create, list, and delete app permissions", func() {
3668
// "deis perms:create %s --app=%s", user, app
3769
// "deis perms:list --app=%s", app

0 commit comments

Comments
 (0)