github.com/deis/workflow-e2e@v2.12.2-0.20180227201524-4105be7001fe+incompatible/tests/users_test.go (about)

     1  package tests
     2  
     3  import (
     4  	deis "github.com/deis/controller-sdk-go"
     5  	"github.com/deis/workflow-e2e/tests/cmd"
     6  	"github.com/deis/workflow-e2e/tests/cmd/auth"
     7  	"github.com/deis/workflow-e2e/tests/model"
     8  	"github.com/deis/workflow-e2e/tests/settings"
     9  	"github.com/deis/workflow-e2e/tests/util"
    10  
    11  	. "github.com/onsi/ginkgo"
    12  	. "github.com/onsi/gomega"
    13  	. "github.com/onsi/gomega/gbytes"
    14  	. "github.com/onsi/gomega/gexec"
    15  )
    16  
    17  var _ = Describe("deis users", func() {
    18  
    19  	Context("with an existing admin", func() {
    20  
    21  		admin := model.Admin
    22  
    23  		Specify("that admin can list all users", func() {
    24  			sess, err := cmd.Start("deis users:list", &admin)
    25  			Eventually(sess).Should(Say("=== Users"))
    26  			output := string(sess.Out.Contents())
    27  			Expect(output).To(ContainSubstring(admin.Username))
    28  			Expect(err).NotTo(HaveOccurred())
    29  			Eventually(sess).Should(Exit(0))
    30  		})
    31  
    32  	})
    33  
    34  	Context("with an existing non-admin user", func() {
    35  
    36  		var user model.User
    37  
    38  		BeforeEach(func() {
    39  			user = auth.RegisterAndLogin()
    40  		})
    41  
    42  		AfterEach(func() {
    43  			auth.Cancel(user)
    44  		})
    45  
    46  		Specify("that user cannot list all users", func() {
    47  			sess, err := cmd.Start("deis users:list", &user)
    48  			Eventually(sess.Err, settings.MaxEventuallyTimeout).Should(Say(util.PrependError(deis.ErrForbidden)))
    49  			Expect(err).NotTo(HaveOccurred())
    50  			Eventually(sess).Should(Exit(1))
    51  		})
    52  	})
    53  
    54  })