github.com/randomtask1155/cli@v6.41.1-0.20181227003417-a98eed78cbde+incompatible/integration/shared/isolated/token_refresh.go (about) 1 package isolated 2 3 import ( 4 "fmt" 5 6 "code.cloudfoundry.org/cli/integration/helpers" 7 "code.cloudfoundry.org/cli/util/configv3" 8 9 . "github.com/onsi/ginkgo" 10 . "github.com/onsi/gomega" 11 . "github.com/onsi/gomega/gbytes" 12 . "github.com/onsi/gomega/gexec" 13 ) 14 15 var _ = Describe("Token Refreshing", func() { 16 Describe("password grant type", func() { 17 BeforeEach(func() { 18 helpers.LoginCF() 19 }) 20 21 When("the token is invalid", func() { 22 BeforeEach(func() { 23 helpers.SetConfig(func(config *configv3.Config) { 24 config.ConfigFile.AccessToken = helpers.InvalidAccessToken() 25 config.ConfigFile.TargetedOrganization.GUID = "fake-org" 26 config.ConfigFile.TargetedSpace.GUID = "fake-space" 27 }) 28 }) 29 30 When("running a v6 command", func() { 31 When("the cloud controller client encounters an invalid token response", func() { 32 It("refreshes the token", func() { 33 session := helpers.CF("unbind-service", "app", "service") 34 Eventually(session.Err).Should(Say("App app not found")) 35 Eventually(session).Should(Exit(1)) 36 }) 37 }) 38 39 When("the UAA client encounters an invalid token response", func() { 40 It("refreshes the token", func() { 41 username, _ := helpers.GetCredentials() 42 session := helpers.CF("create-user", username, helpers.NewPassword()) 43 Eventually(session.Err).Should(Say(fmt.Sprintf("user %s already exists", username))) 44 Eventually(session).Should(Exit(0)) 45 }) 46 }) 47 }) 48 49 When("running a v7 command", func() { 50 When("the cloud controller client encounters an invalid token response", func() { 51 It("refreshes the token", func() { 52 session := helpers.CF("run-task", "app", "'echo banana'") 53 Eventually(session.Err).Should(Say("App app not found")) 54 Eventually(session).Should(Exit(1)) 55 }) 56 }) 57 }) 58 }) 59 }) 60 61 Describe("client grant type", func() { 62 BeforeEach(func() { 63 helpers.LoginCFWithClientCredentials() 64 }) 65 66 When("the token is invalid", func() { 67 BeforeEach(func() { 68 helpers.SetConfig(func(config *configv3.Config) { 69 config.ConfigFile.AccessToken = helpers.InvalidAccessToken() 70 config.ConfigFile.TargetedOrganization.GUID = "fake-org" 71 config.ConfigFile.TargetedSpace.GUID = "fake-space" 72 }) 73 }) 74 75 When("running a v6 refactored command", func() { 76 When("the cloud controller client encounters an invalid token response", func() { 77 It("refreshes the token", func() { 78 session := helpers.CF("unbind-service", "app", "service") 79 Eventually(session.Err).Should(Say("App app not found")) 80 Eventually(session).Should(Exit(1)) 81 }) 82 }) 83 84 When("the UAA client encounters an invalid token response", func() { 85 It("refreshes the token", func() { 86 username := helpers.NewUsername() 87 session := helpers.CF("create-user", username, helpers.NewPassword()) 88 Eventually(session).Should(Say("OK")) 89 Eventually(session).Should(Exit(0)) 90 }) 91 }) 92 }) 93 94 When("running a v6 unrefactored command", func() { 95 When("the cloud controller client encounters an invalid token response", func() { 96 It("refreshes the token", func() { 97 username, _ := helpers.GetCredentials() 98 session := helpers.CF("quotas") 99 Eventually(session).Should(Say("Getting quotas as %s", username)) 100 Eventually(session).Should(Say("OK")) 101 Eventually(session).Should(Exit(0)) 102 }) 103 }) 104 }) 105 106 When("running a v7 command", func() { 107 When("the cloud controller client encounters an invalid token response", func() { 108 It("refreshes the token", func() { 109 session := helpers.CF("run-task", "app", "'echo banana'") 110 Eventually(session.Err).Should(Say("App app not found")) 111 Eventually(session).Should(Exit(1)) 112 }) 113 }) 114 }) 115 }) 116 }) 117 })