-
Notifications
You must be signed in to change notification settings - Fork 929
/
token_refresh.go
64 lines (54 loc) · 1.98 KB
/
token_refresh.go
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
52
53
54
55
56
57
58
59
60
61
62
63
64
package isolated
import (
"fmt"
"code.cloudfoundry.org/cli/integration/helpers"
"code.cloudfoundry.org/cli/util/configv3"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gbytes"
. "github.com/onsi/gomega/gexec"
)
var _ = Describe("Token Refreshing", func() {
Context("when running a v2 command with an invalid token", func() {
BeforeEach(func() {
helpers.LoginCF()
helpers.SetConfig(func(config *configv3.Config) {
config.ConfigFile.AccessToken = helpers.InvalidAccessToken()
config.ConfigFile.TargetedOrganization.GUID = "fake-org"
config.ConfigFile.TargetedSpace.GUID = "fake-space"
})
})
Context("when the cloud controller client encounters an invalid token response", func() {
It("refreshes the token", func() {
session := helpers.CF("unbind-service", "app", "service")
Eventually(session.Err).Should(Say("App app not found"))
Eventually(session).Should(Exit(1))
})
})
Context("when the UAA client encounters an invalid token response", func() {
It("refreshes the token", func() {
username, _ := helpers.GetCredentials()
session := helpers.CF("create-user", username, helpers.NewPassword())
Eventually(session.Err).Should(Say(fmt.Sprintf("user %s already exists", username)))
Eventually(session).Should(Exit(0))
})
})
})
Context("when running a v3 command with an invalid token", func() {
BeforeEach(func() {
helpers.LoginCF()
helpers.SetConfig(func(config *configv3.Config) {
config.ConfigFile.AccessToken = helpers.InvalidAccessToken()
config.ConfigFile.TargetedOrganization.GUID = "fake-org"
config.ConfigFile.TargetedSpace.GUID = "fake-space"
})
})
Context("when the cloud controller client encounters an invalid token response", func() {
It("refreshes the token", func() {
session := helpers.CF("-v", "run-task", "app", "'echo banana'")
Eventually(session.Err).Should(Say("App app not found"))
Eventually(session).Should(Exit(1))
})
})
})
})