Skip to content

Commit

Permalink
Revert "Fix selfcontained tests failing due to /whoami (#2266)"
Browse files Browse the repository at this point in the history
This reverts commit 9e316e2.
  • Loading branch information
gururajsh committed May 17, 2022
1 parent c4303e7 commit 63d883e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 93 deletions.
20 changes: 6 additions & 14 deletions integration/v7/selfcontained/kubernetes_auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@ import (
"net/http"
"path/filepath"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gexec"
apiv1 "k8s.io/client-go/tools/clientcmd/api/v1"

"code.cloudfoundry.org/cli/integration/helpers"
"code.cloudfoundry.org/cli/integration/v7/selfcontained/fake"
"code.cloudfoundry.org/cli/resources"
"code.cloudfoundry.org/cli/util/configv3"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gexec"
apiv1 "k8s.io/client-go/tools/clientcmd/api/v1"
)

var _ = Describe("auth-provider", func() {
Expand All @@ -30,19 +29,13 @@ var _ = Describe("auth-provider", func() {
"resources": []resources.Application{},
},
},
"GET /whoami": {
Code: http.StatusOK, Body: map[string]interface{}{
"name": "my-user",
"kind": "User",
},
},
},
}
apiServer.SetConfiguration(apiConfig)
helpers.SetConfig(func(config *configv3.Config) {
config.ConfigFile.Target = apiServer.URL()
config.ConfigFile.CFOnK8s.Enabled = true
config.ConfigFile.CFOnK8s.AuthInfo = "my-user"
config.ConfigFile.CFOnK8s.AuthInfo = "one"
config.ConfigFile.TargetedOrganization = configv3.Organization{
GUID: "my-org",
Name: "My Org",
Expand All @@ -59,8 +52,7 @@ var _ = Describe("auth-provider", func() {
APIVersion: "v1",
AuthInfos: []apiv1.NamedAuthInfo{
{
Name: "my-user",
AuthInfo: apiv1.AuthInfo{
Name: "one", AuthInfo: apiv1.AuthInfo{
AuthProvider: &apiv1.AuthProviderConfig{
Name: "oidc",
Config: map[string]string{
Expand Down
17 changes: 5 additions & 12 deletions integration/v7/selfcontained/login_command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,16 @@ import (
"os"
"path/filepath"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gbytes"
"github.com/onsi/gomega/gexec"
apiv1 "k8s.io/client-go/tools/clientcmd/api/v1"

"code.cloudfoundry.org/cli/api/cloudcontroller/ccv3"
"code.cloudfoundry.org/cli/integration/helpers"
"code.cloudfoundry.org/cli/integration/v7/selfcontained/fake"
"code.cloudfoundry.org/cli/resources"
"code.cloudfoundry.org/cli/util/configv3"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gbytes"
"github.com/onsi/gomega/gexec"
apiv1 "k8s.io/client-go/tools/clientcmd/api/v1"
)

var _ = Describe("LoginCommand", func() {
Expand Down Expand Up @@ -46,12 +45,6 @@ var _ = Describe("LoginCommand", func() {
"resources": []resources.Organization{},
},
},
"GET /whoami": {
Code: http.StatusOK, Body: map[string]interface{}{
"name": "two",
"kind": "User",
},
},
},
}
apiServer.SetConfiguration(apiConfig)
Expand Down
71 changes: 4 additions & 67 deletions integration/v7/selfcontained/logout_command_test.go
Original file line number Diff line number Diff line change
@@ -1,86 +1,23 @@
package selfcontained_test

import (
"net/http"
"path/filepath"

"code.cloudfoundry.org/cli/integration/helpers"
"code.cloudfoundry.org/cli/util/configv3"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gexec"
apiv1 "k8s.io/client-go/tools/clientcmd/api/v1"

"code.cloudfoundry.org/cli/integration/helpers"
"code.cloudfoundry.org/cli/integration/v7/selfcontained/fake"
"code.cloudfoundry.org/cli/util/configv3"
)

var _ = Describe("cf logout", func() {
BeforeEach(func() {
helpers.SetConfig(func(config *configv3.Config) {
config.ConfigFile.CFOnK8s.Enabled = true
config.ConfigFile.CFOnK8s.AuthInfo = "my-user"
config.ConfigFile.CFOnK8s.AuthInfo = "something"
})

apiServer.SetConfiguration(fake.CFAPIConfig{Routes: map[string]fake.Response{
"GET /whoami": {
Code: http.StatusOK, Body: map[string]interface{}{
"name": "my-user",
"kind": "User",
},
},
}})

kubeConfig := apiv1.Config{
Kind: "Config",
APIVersion: "v1",
AuthInfos: []apiv1.NamedAuthInfo{
{
Name: "my-user",
AuthInfo: apiv1.AuthInfo{
AuthProvider: &apiv1.AuthProviderConfig{
Name: "oidc",
Config: map[string]string{
"id-token": string(token),
"idp-issuer-url": "-",
"client-id": "-",
},
},
},
},
},
Clusters: []apiv1.NamedCluster{
{
Name: "my-cluster",
Cluster: apiv1.Cluster{
Server: "https://example.org",
},
},
},
Contexts: []apiv1.NamedContext{
{
Name: "my-context",
Context: apiv1.Context{
Cluster: "my-cluster",
AuthInfo: "my-auth-info",
Namespace: "my-namespace",
},
},
},
CurrentContext: "my-context",
}

kubeConfigPath := filepath.Join(homeDir, ".kube", "config")
storeKubeConfig(kubeConfig, kubeConfigPath)

env = helpers.CFEnv{
EnvVars: map[string]string{
"KUBECONFIG": kubeConfigPath,
},
}
})

JustBeforeEach(func() {
Eventually(helpers.CustomCF(env, "logout")).Should(gexec.Exit(0))
Eventually(helpers.CF("logout")).Should(gexec.Exit(0))
})

It("clears the auth-info", func() {
Expand Down

0 comments on commit 63d883e

Please sign in to comment.