-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathkeys_test.go
More file actions
51 lines (45 loc) · 1.32 KB
/
keys_test.go
File metadata and controls
51 lines (45 loc) · 1.32 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
package _tests_test
import (
"os"
"os/user"
"path"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Keys", func() {
key := testUser
Context("when logged in as a normal user", func() {
BeforeEach(func() {
login(url, testUser, testPassword)
createKey(testUser)
})
AfterEach(func() {
// remove the generated ssh key
var home string
if user, err := user.Current(); err != nil {
home = "~"
} else {
home = user.HomeDir
}
path := path.Join(home, ".ssh", testUser)
err := os.Remove(path)
Expect(err).NotTo(HaveOccurred())
err = os.Remove(path + ".pub")
Expect(err).NotTo(HaveOccurred())
})
It("can add, list, and remove a key", func() {
output, err := execute("deis keys:add ~/.ssh/%s.pub", key)
Expect(err).NotTo(HaveOccurred())
Expect(output).To(ContainSubstring("Uploading %s.pub to deis... done", key))
output, err = execute("deis keys:list")
Expect(err).NotTo(HaveOccurred())
Expect(output).To(ContainSubstring("%s ssh-rsa", key))
output, err = execute("deis keys:remove %s", key)
Expect(err).NotTo(HaveOccurred())
Expect(output).To(ContainSubstring("Removing %s SSH Key... done", key))
output, err = execute("deis keys")
Expect(err).NotTo(HaveOccurred())
Expect(output).NotTo(ContainSubstring("%s ssh-rsa", key))
})
})
})