Skip to content

Commit

Permalink
Under custom client test re-authentication
Browse files Browse the repository at this point in the history
Add test that re-authentication succeeds when user authenticated via a
custom client

[#165318179](https://www.pivotaltracker.com/story/show/165318179)

Co-authored-by: Andrew Crump <acrump@pivotal.io>
  • Loading branch information
Alexander Berezovsky and acrmp committed Apr 30, 2019
1 parent 6f3091b commit 1d3f62d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
15 changes: 14 additions & 1 deletion integration/shared/isolated/auth_command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ var _ = Describe("auth command", func() {
accessTokenExpiration = 120 // this was configured in the pipeline
})

It("expects access token validity to match custom client", func() {
It("access token validity matches custom client configuration", func() {
config := helpers.GetConfig()

jwt := helpers.ParseTokenString(config.ConfigFile.AccessToken)
Expand All @@ -360,5 +360,18 @@ var _ = Describe("auth command", func() {
Expect(iatIsSet).To(BeTrue())
Expect(expires.Sub(iat)).To(Equal(accessTokenExpiration * time.Second))
})

When("the token has expired", func() {
BeforeEach(func() {
helpers.SetConfig(func(config *configv3.Config) {
config.ConfigFile.AccessToken = helpers.ExpiredAccessToken()
})
})

It("re-authenticates using the custom client", func() {
session := helpers.CF("orgs")
Eventually(session).Should(Exit(0))
})
})
})
})
15 changes: 14 additions & 1 deletion integration/shared/isolated/login_command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1161,7 +1161,7 @@ var _ = Describe("login command", func() {
accessTokenExpiration = 120 // this was configured in the pipeline
})

It("expects access token validity to match custom client", func() {
It("access token validity matches custom client configuration", func() {
config := helpers.GetConfig()

jwt := helpers.ParseTokenString(config.ConfigFile.AccessToken)
Expand All @@ -1173,5 +1173,18 @@ var _ = Describe("login command", func() {
Expect(iatIsSet).To(BeTrue())
Expect(expires.Sub(iat)).To(Equal(accessTokenExpiration * time.Second))
})

When("the token has expired", func() {
BeforeEach(func() {
helpers.SetConfig(func(config *configv3.Config) {
config.ConfigFile.AccessToken = helpers.ExpiredAccessToken()
})
})

It("re-authenticates using the custom client", func() {
session := helpers.CF("orgs")
Eventually(session).Should(Exit(0))
})
})
})
})

0 comments on commit 1d3f62d

Please sign in to comment.