@@ -17,6 +17,11 @@ import (
1717 "testing"
1818)
1919
20+ const (
21+ deisWorkflowServiceHost = "DEIS_WORKFLOW_SERVICE_HOST"
22+ deisWorkflowServicePort = "DEIS_WORKFLOW_SERVICE_PORT"
23+ )
24+
2025func init () {
2126 rand .Seed (GinkgoConfig .RandomSeed )
2227}
@@ -41,19 +46,22 @@ var (
4146)
4247
4348var _ = BeforeSuite (func () {
44- workflowHost := os .Getenv ("DEIS_WORKFLOW_SERVICE_HOST" )
45- Expect (workflowHost ).ShouldNot (BeEmpty ())
4649 // use the "deis" executable in the search $PATH
4750 _ , err := exec .LookPath ("deis" )
4851 Expect (err ).NotTo (HaveOccurred ())
4952
5053 // register the test-admin user
5154 register (url , testAdminUser , testAdminPassword , testAdminEmail )
52- // TODO: verify that this user is actually an admin
55+ // verify this user is an admin by running a privileged command
56+ _ , err = execute ("deis users:list" )
57+ Expect (err ).NotTo (HaveOccurred ())
5358
5459 // register the test user and add a key
5560 register (url , testUser , testPassword , testEmail )
56- addKey ("deis-test" )
61+ createKey ("deis-test" )
62+ output , err := execute ("deis keys:add ~/.ssh/deis-test.pub" )
63+ Expect (err ).NotTo (HaveOccurred ())
64+ Expect (output ).To (ContainSubstring ("Uploading deis-test.pub to deis... done" ))
5765})
5866
5967var _ = AfterSuite (func () {
@@ -108,7 +116,7 @@ func execute(cmdLine string, args ...interface{}) (string, error) {
108116 return stdout .String (), nil
109117}
110118
111- func addKey (name string ) {
119+ func createKey (name string ) {
112120 var home string
113121 if user , err := user .Current (); err != nil {
114122 home = "~"
@@ -118,24 +126,24 @@ func addKey(name string) {
118126 path := path .Join (home , ".ssh" , name )
119127 // create the key under ~/.ssh/<name> if it doesn't already exist
120128 if _ , err := os .Stat (path ); os .IsNotExist (err ) {
121- cmd := "ssh-keygen -q -t rsa -b 4096 -C otto.test@deis.com -f %s -N ''"
122- _ , err := execute (cmd , path )
129+ cmd := "ssh-keygen -q -t rsa -b 4096 -C %s -f %s -N ''"
130+ _ , err := execute (cmd , name , path )
123131 Expect (err ).NotTo (HaveOccurred ())
124132 }
125133 // add the key to ssh-agent
126134 _ , err := execute ("eval $(ssh-agent) && ssh-add %s" , path )
127135 Expect (err ).NotTo (HaveOccurred ())
128- // add the public key to deis (assumes the user is logged in)
129- _ , err = execute ("deis keys:add %s.pub" , path )
130- Expect (err ).NotTo (HaveOccurred ())
131136}
132137
133138func getController () string {
134- host := os .Getenv ("DEIS_WORKFLOW_SERVICE_HOST" )
139+ host := os .Getenv (deisWorkflowServiceHost )
135140 if host == "" {
136- panic ("DEIS_WORKFLOW_SERVICE_HOST isn't set" )
141+ panicStr := fmt .Sprintf (`Set %s to the workflow controller hostname for tests, such as:
142+
143+ $ %s=deis.10.245.1.3.xip.io make test-integration` , deisWorkflowServiceHost , deisWorkflowServiceHost )
144+ panic (panicStr )
137145 }
138- port := os .Getenv ("DEIS_WORKFLOW_SERVICE_PORT" )
146+ port := os .Getenv (deisWorkflowServicePort )
139147 switch port {
140148 case "443" :
141149 return "https://" + host
0 commit comments