Skip to content

Commit

Permalink
login: Restore minimum version check example
Browse files Browse the repository at this point in the history
- We want coverage on current login and experimental login

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

Co-authored-by: Alexander Berezovsky <aberezovsky@pivotal.io>
  • Loading branch information
acrmp and Alexander Berezovsky committed Jul 10, 2019
1 parent 3b19f53 commit 5be5439
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 11 deletions.
41 changes: 40 additions & 1 deletion integration/shared/experimental/login_command_test.go
@@ -1,16 +1,56 @@
package experimental

import (
"net/http"

"code.cloudfoundry.org/cli/integration/helpers"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gbytes"
. "github.com/onsi/gomega/gexec"
"github.com/onsi/gomega/ghttp"
)

var _ = Describe("login command", func() {
BeforeEach(func() {
helpers.SkipIfClientCredentialsTestMode()
helpers.TurnOnExperimentalLogin()
})

AfterEach(func() {
helpers.TurnOffExperimentalLogin()
})

Describe("Minimum Version Check", func() {
When("the CLI version is lower than the minimum supported version by the CC", func() {
var server *ghttp.Server

BeforeEach(func() {
server = helpers.StartServerWithMinimumCLIVersion("9000.0.0")

fakeTokenResponse := map[string]string{
"access_token": "",
"token_type": "bearer",
}
server.RouteToHandler(http.MethodPost, "/oauth/token",
ghttp.RespondWithJSONEncoded(http.StatusOK, fakeTokenResponse))
server.RouteToHandler(http.MethodGet, "/v3/organizations",
ghttp.RespondWith(http.StatusOK, `{
"total_results": 0,
"total_pages": 1,
"resources": []}`))
})

AfterEach(func() {
server.Close()
})

It("displays the warning and exits successfully", func() {
session := helpers.CF("login", "-a", server.URL(), "--skip-ssl-validation")
Eventually(session.Err).Should(Say(`Cloud Foundry API version .+ requires CLI version .+\. You are currently on version .+\. To upgrade your CLI, please visit: https://github.com/cloudfoundry/cli#downloads`))
Eventually(session).Should(Exit(0))
})
})
})

Describe("Target Space", func() {
Expand All @@ -32,7 +72,6 @@ var _ = Describe("login command", func() {
var spaceName string

BeforeEach(func() {
helpers.TurnOnExperimentalLogin()
spaceName = helpers.NewSpaceName()
session := helpers.CF("create-space", "-o", orgName, spaceName)
Eventually(session).Should(Exit(0))
Expand Down
13 changes: 3 additions & 10 deletions integration/shared/isolated/login_command_test.go
Expand Up @@ -110,30 +110,23 @@ var _ = Describe("login command", func() {
var server *ghttp.Server

BeforeEach(func() {
helpers.TurnOnExperimentalLogin()
server = helpers.StartServerWithMinimumCLIVersion("9000.0.0")

fakeTokenResponse := map[string]string{
"access_token": "",
"token_type": "bearer",
}
server.RouteToHandler(http.MethodPost, "/oauth/token",
ghttp.RespondWithJSONEncoded(http.StatusOK, fakeTokenResponse))
server.RouteToHandler(http.MethodGet, "/v3/organizations",
helpers.AddLoginRoutes(server)
server.RouteToHandler(http.MethodGet, "/v2/organizations",
ghttp.RespondWith(http.StatusOK, `{
"total_results": 0,
"total_pages": 1,
"resources": []}`))
})

AfterEach(func() {
helpers.TurnOffExperimentalLogin()
server.Close()
})

It("displays the warning and exits successfully", func() {
session := helpers.CF("login", "-a", server.URL(), "--skip-ssl-validation")
Eventually(session.Err).Should(Say(`Cloud Foundry API version .+ requires CLI version .+\. You are currently on version .+\. To upgrade your CLI, please visit: https://github.com/cloudfoundry/cli#downloads`))
Eventually(session.Out).Should(Say(`Cloud Foundry API version .+ requires CLI version .+\. You are currently on version .+\. To upgrade your CLI, please visit: https://github.com/cloudfoundry/cli#downloads`))
Eventually(session).Should(Exit(0))
})
})
Expand Down

0 comments on commit 5be5439

Please sign in to comment.