github.com/deis/workflow-e2e@v2.12.2-0.20180227201524-4105be7001fe+incompatible/tests/cmd/perms/commands.go (about) 1 package perms 2 3 import ( 4 "github.com/deis/workflow-e2e/tests/cmd" 5 "github.com/deis/workflow-e2e/tests/model" 6 "github.com/deis/workflow-e2e/tests/settings" 7 8 . "github.com/onsi/gomega" 9 . "github.com/onsi/gomega/gbytes" 10 . "github.com/onsi/gomega/gexec" 11 ) 12 13 // The functions in this file implement SUCCESS CASES for commonly used `deis perms` subcommands. 14 // This allows each of these to be re-used easily in multiple contexts. 15 16 // Create executes `deis perms:create` as the specified user to grant permissions on the specified 17 // app to a second user. 18 func Create(user model.User, app model.App, grantUser model.User) { 19 sess, err := cmd.Start("deis perms:create %s --app=%s", &user, grantUser.Username, app.Name) 20 Eventually(sess, settings.MaxEventuallyTimeout).Should(Say("Adding %s to %s collaborators... done\n", grantUser.Username, app.Name)) 21 Expect(err).NotTo(HaveOccurred()) 22 Eventually(sess).Should(Exit(0)) 23 } 24 25 // Delete executes `deis perms:delete` as the specified user to revoke permissions on the specified 26 // app from a second user. 27 func Delete(user model.User, app model.App, revokeUser model.User) { 28 sess, err := cmd.Start("deis perms:delete %s --app=%s", &user, revokeUser.Username, app.Name) 29 Eventually(sess, settings.MaxEventuallyTimeout).Should(Say("Removing %s from %s collaborators... done", revokeUser.Username, app.Name)) 30 Expect(err).NotTo(HaveOccurred()) 31 Eventually(sess).Should(Exit(0)) 32 }