|
|
@@ -7,6 +7,7 @@ import (
|
|
|
|
|
|
"github.com/porter-dev/porter/internal/kubernetes"
|
|
|
"github.com/porter-dev/porter/internal/models"
|
|
|
+ "k8s.io/client-go/tools/clientcmd"
|
|
|
)
|
|
|
|
|
|
type kubeConfigTest struct {
|
|
|
@@ -165,6 +166,331 @@ func TestGetRestrictedClientConfig(t *testing.T) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+type saCandidatesTest struct {
|
|
|
+ name string
|
|
|
+ raw []byte
|
|
|
+ expected []*models.ServiceAccountCandidate
|
|
|
+}
|
|
|
+
|
|
|
+var SACandidatesTests = []saCandidatesTest{
|
|
|
+ saCandidatesTest{
|
|
|
+ name: "test without cluster ca data",
|
|
|
+ raw: []byte(ClusterCAWithoutData),
|
|
|
+ expected: []*models.ServiceAccountCandidate{
|
|
|
+ &models.ServiceAccountCandidate{
|
|
|
+ Actions: []models.ServiceAccountAction{
|
|
|
+ models.ServiceAccountAction{
|
|
|
+ Name: "upload-cluster-ca-data",
|
|
|
+ Resolved: false,
|
|
|
+ Filename: "/fake/path/to/ca.pem",
|
|
|
+ },
|
|
|
+ },
|
|
|
+ Kind: "connector",
|
|
|
+ ClusterName: "cluster-test",
|
|
|
+ ClusterEndpoint: "https://localhost",
|
|
|
+ AuthMechanism: models.X509,
|
|
|
+ Kubeconfig: []byte(ClusterCAWithoutData),
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ saCandidatesTest{
|
|
|
+ name: "x509 test with cert and key data",
|
|
|
+ raw: []byte(x509WithData),
|
|
|
+ expected: []*models.ServiceAccountCandidate{
|
|
|
+ &models.ServiceAccountCandidate{
|
|
|
+ Actions: []models.ServiceAccountAction{},
|
|
|
+ Kind: "connector",
|
|
|
+ ClusterName: "cluster-test",
|
|
|
+ ClusterEndpoint: "https://localhost",
|
|
|
+ AuthMechanism: models.X509,
|
|
|
+ Kubeconfig: []byte(x509WithData),
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ saCandidatesTest{
|
|
|
+ name: "x509 test without cert data",
|
|
|
+ raw: []byte(x509WithoutCertData),
|
|
|
+ expected: []*models.ServiceAccountCandidate{
|
|
|
+ &models.ServiceAccountCandidate{
|
|
|
+ Actions: []models.ServiceAccountAction{
|
|
|
+ models.ServiceAccountAction{
|
|
|
+ Name: "upload-client-cert-data",
|
|
|
+ Resolved: false,
|
|
|
+ Filename: "/fake/path/to/cert.pem",
|
|
|
+ },
|
|
|
+ },
|
|
|
+ Kind: "connector",
|
|
|
+ ClusterName: "cluster-test",
|
|
|
+ ClusterEndpoint: "https://localhost",
|
|
|
+ AuthMechanism: models.X509,
|
|
|
+ Kubeconfig: []byte(x509WithoutCertData),
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ saCandidatesTest{
|
|
|
+ name: "x509 test without key data",
|
|
|
+ raw: []byte(x509WithoutKeyData),
|
|
|
+ expected: []*models.ServiceAccountCandidate{
|
|
|
+ &models.ServiceAccountCandidate{
|
|
|
+ Actions: []models.ServiceAccountAction{
|
|
|
+ models.ServiceAccountAction{
|
|
|
+ Name: "upload-client-key-data",
|
|
|
+ Resolved: false,
|
|
|
+ Filename: "/fake/path/to/key.pem",
|
|
|
+ },
|
|
|
+ },
|
|
|
+ Kind: "connector",
|
|
|
+ ClusterName: "cluster-test",
|
|
|
+ ClusterEndpoint: "https://localhost",
|
|
|
+ AuthMechanism: models.X509,
|
|
|
+ Kubeconfig: []byte(x509WithoutKeyData),
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ saCandidatesTest{
|
|
|
+ name: "x509 test without cert and key data",
|
|
|
+ raw: []byte(x509WithoutCertAndKeyData),
|
|
|
+ expected: []*models.ServiceAccountCandidate{
|
|
|
+ &models.ServiceAccountCandidate{
|
|
|
+ Actions: []models.ServiceAccountAction{
|
|
|
+ models.ServiceAccountAction{
|
|
|
+ Name: "upload-client-cert-data",
|
|
|
+ Resolved: false,
|
|
|
+ Filename: "/fake/path/to/cert.pem",
|
|
|
+ },
|
|
|
+ models.ServiceAccountAction{
|
|
|
+ Name: "upload-client-key-data",
|
|
|
+ Resolved: false,
|
|
|
+ Filename: "/fake/path/to/key.pem",
|
|
|
+ },
|
|
|
+ },
|
|
|
+ Kind: "connector",
|
|
|
+ ClusterName: "cluster-test",
|
|
|
+ ClusterEndpoint: "https://localhost",
|
|
|
+ AuthMechanism: models.X509,
|
|
|
+ Kubeconfig: []byte(x509WithoutCertAndKeyData),
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ saCandidatesTest{
|
|
|
+ name: "bearer token test with data",
|
|
|
+ raw: []byte(BearerTokenWithData),
|
|
|
+ expected: []*models.ServiceAccountCandidate{
|
|
|
+ &models.ServiceAccountCandidate{
|
|
|
+ Actions: []models.ServiceAccountAction{},
|
|
|
+ Kind: "connector",
|
|
|
+ ClusterName: "cluster-test",
|
|
|
+ ClusterEndpoint: "https://localhost",
|
|
|
+ AuthMechanism: models.Bearer,
|
|
|
+ Kubeconfig: []byte(BearerTokenWithData),
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ saCandidatesTest{
|
|
|
+ name: "bearer token test without data",
|
|
|
+ raw: []byte(BearerTokenWithoutData),
|
|
|
+ expected: []*models.ServiceAccountCandidate{
|
|
|
+ &models.ServiceAccountCandidate{
|
|
|
+ Actions: []models.ServiceAccountAction{
|
|
|
+ models.ServiceAccountAction{
|
|
|
+ Name: "upload-token-data",
|
|
|
+ Resolved: false,
|
|
|
+ Filename: "/path/to/token/file.txt",
|
|
|
+ },
|
|
|
+ },
|
|
|
+ Kind: "connector",
|
|
|
+ ClusterName: "cluster-test",
|
|
|
+ ClusterEndpoint: "https://localhost",
|
|
|
+ AuthMechanism: models.Bearer,
|
|
|
+ Kubeconfig: []byte(BearerTokenWithoutData),
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ saCandidatesTest{
|
|
|
+ name: "gcp test",
|
|
|
+ raw: []byte(GCPPlugin),
|
|
|
+ expected: []*models.ServiceAccountCandidate{
|
|
|
+ &models.ServiceAccountCandidate{
|
|
|
+ Actions: []models.ServiceAccountAction{
|
|
|
+ models.ServiceAccountAction{
|
|
|
+ Name: "upload-gcp-key-data",
|
|
|
+ Resolved: false,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ Kind: "connector",
|
|
|
+ ClusterName: "cluster-test",
|
|
|
+ ClusterEndpoint: "https://localhost",
|
|
|
+ AuthMechanism: models.GCP,
|
|
|
+ Kubeconfig: []byte(GCPPlugin),
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ saCandidatesTest{
|
|
|
+ name: "aws iam authenticator test",
|
|
|
+ raw: []byte(AWSIamAuthenticatorExec),
|
|
|
+ expected: []*models.ServiceAccountCandidate{
|
|
|
+ &models.ServiceAccountCandidate{
|
|
|
+ Actions: []models.ServiceAccountAction{
|
|
|
+ models.ServiceAccountAction{
|
|
|
+ Name: "upload-aws-key-data",
|
|
|
+ Resolved: false,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ Kind: "connector",
|
|
|
+ ClusterName: "cluster-test",
|
|
|
+ ClusterEndpoint: "https://localhost",
|
|
|
+ AuthMechanism: models.AWS,
|
|
|
+ Kubeconfig: []byte(AWSIamAuthenticatorExec),
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ saCandidatesTest{
|
|
|
+ name: "aws eks get-token test",
|
|
|
+ raw: []byte(AWSEKSGetTokenExec),
|
|
|
+ expected: []*models.ServiceAccountCandidate{
|
|
|
+ &models.ServiceAccountCandidate{
|
|
|
+ Actions: []models.ServiceAccountAction{
|
|
|
+ models.ServiceAccountAction{
|
|
|
+ Name: "upload-aws-key-data",
|
|
|
+ Resolved: false,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ Kind: "connector",
|
|
|
+ ClusterName: "cluster-test",
|
|
|
+ ClusterEndpoint: "https://localhost",
|
|
|
+ AuthMechanism: models.AWS,
|
|
|
+ Kubeconfig: []byte(AWSEKSGetTokenExec),
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ saCandidatesTest{
|
|
|
+ name: "oidc without ca data",
|
|
|
+ raw: []byte(OIDCAuthWithoutData),
|
|
|
+ expected: []*models.ServiceAccountCandidate{
|
|
|
+ &models.ServiceAccountCandidate{
|
|
|
+ Actions: []models.ServiceAccountAction{
|
|
|
+ models.ServiceAccountAction{
|
|
|
+ Name: "upload-oidc-idp-issuer-ca-data",
|
|
|
+ Resolved: false,
|
|
|
+ Filename: "/fake/path/to/ca.pem",
|
|
|
+ },
|
|
|
+ },
|
|
|
+ Kind: "connector",
|
|
|
+ ClusterName: "cluster-test",
|
|
|
+ ClusterEndpoint: "https://localhost",
|
|
|
+ AuthMechanism: models.OIDC,
|
|
|
+ Kubeconfig: []byte(OIDCAuthWithoutData),
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ saCandidatesTest{
|
|
|
+ name: "oidc with ca data",
|
|
|
+ raw: []byte(OIDCAuthWithData),
|
|
|
+ expected: []*models.ServiceAccountCandidate{
|
|
|
+ &models.ServiceAccountCandidate{
|
|
|
+ Actions: []models.ServiceAccountAction{},
|
|
|
+ Kind: "connector",
|
|
|
+ ClusterName: "cluster-test",
|
|
|
+ ClusterEndpoint: "https://localhost",
|
|
|
+ AuthMechanism: models.OIDC,
|
|
|
+ Kubeconfig: []byte(OIDCAuthWithData),
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ saCandidatesTest{
|
|
|
+ name: "basic auth test",
|
|
|
+ raw: []byte(BasicAuth),
|
|
|
+ expected: []*models.ServiceAccountCandidate{
|
|
|
+ &models.ServiceAccountCandidate{
|
|
|
+ Actions: []models.ServiceAccountAction{},
|
|
|
+ Kind: "connector",
|
|
|
+ ClusterName: "cluster-test",
|
|
|
+ ClusterEndpoint: "https://localhost",
|
|
|
+ AuthMechanism: models.Basic,
|
|
|
+ Kubeconfig: []byte(BasicAuth),
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+}
|
|
|
+
|
|
|
+func TestGetServiceAccountCandidates(t *testing.T) {
|
|
|
+ for _, c := range SACandidatesTests {
|
|
|
+ result, err := kubernetes.GetServiceAccountCandidates(c.raw)
|
|
|
+
|
|
|
+ if err != nil {
|
|
|
+ t.Fatalf("error occurred %v\n", err)
|
|
|
+ }
|
|
|
+
|
|
|
+ // make result into a map so it's easier to compare
|
|
|
+ resMap := make(map[string]*models.ServiceAccountCandidate)
|
|
|
+
|
|
|
+ for _, res := range result {
|
|
|
+ resMap[res.Kind+"-"+res.ClusterEndpoint+"-"+res.AuthMechanism] = res
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, exp := range c.expected {
|
|
|
+ res, ok := resMap[exp.Kind+"-"+exp.ClusterEndpoint+"-"+exp.AuthMechanism]
|
|
|
+
|
|
|
+ if !ok {
|
|
|
+ t.Fatalf("%s failed: no matching result for %s\n", c.name,
|
|
|
+ exp.Kind+"-"+exp.ClusterEndpoint+"-"+exp.AuthMechanism)
|
|
|
+ }
|
|
|
+
|
|
|
+ // compare basic string fields
|
|
|
+ if exp.AuthMechanism != res.AuthMechanism {
|
|
|
+ t.Errorf("%s failed on auth mechanism: expected %s, got %s\n",
|
|
|
+ c.name, exp.AuthMechanism, res.AuthMechanism)
|
|
|
+ }
|
|
|
+
|
|
|
+ if exp.ClusterName != res.ClusterName {
|
|
|
+ t.Errorf("%s failed on cluster name: expected %s, got %s\n",
|
|
|
+ c.name, exp.ClusterName, res.ClusterName)
|
|
|
+ }
|
|
|
+
|
|
|
+ if exp.ClusterEndpoint != res.ClusterEndpoint {
|
|
|
+ t.Errorf("%s failed on cluster endpoint: expected %s, got %s\n",
|
|
|
+ c.name, exp.ClusterEndpoint, res.ClusterEndpoint)
|
|
|
+ }
|
|
|
+
|
|
|
+ if len(res.Actions) != len(exp.Actions) {
|
|
|
+ t.Errorf("%s failed on action names: expected length %d, got length %d\n",
|
|
|
+ c.name, len(res.Actions), len(exp.Actions))
|
|
|
+ } else {
|
|
|
+ for i, action := range exp.Actions {
|
|
|
+ if res.Actions[i].Name != action.Name {
|
|
|
+ t.Errorf("%s failed on action names: expected res to contain %s, got %s\n",
|
|
|
+ c.name, action.Name, res.Actions[i].Name)
|
|
|
+ }
|
|
|
+
|
|
|
+ if res.Actions[i].Filename != action.Filename {
|
|
|
+ t.Errorf("%s failed on action file names: expected res to contain %s, got %s\n",
|
|
|
+ c.name, action.Filename, res.Actions[i].Filename)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // compare kubeconfig by transforming into a client config
|
|
|
+ resConfig, _ := clientcmd.NewClientConfigFromBytes(res.Kubeconfig)
|
|
|
+ expConfig, err := clientcmd.NewClientConfigFromBytes(exp.Kubeconfig)
|
|
|
+
|
|
|
+ if err != nil {
|
|
|
+ t.Fatalf("config from bytes, error occurred %v\n", err)
|
|
|
+ }
|
|
|
+
|
|
|
+ resRawConf, _ := resConfig.RawConfig()
|
|
|
+ expRawConf, err := expConfig.RawConfig()
|
|
|
+
|
|
|
+ if err != nil {
|
|
|
+ t.Fatalf("raw config conversion, error occurred %v\n", err)
|
|
|
+ }
|
|
|
+
|
|
|
+ if !reflect.DeepEqual(resRawConf, expRawConf) {
|
|
|
+ t.Errorf("%s failed: expected %v, got %v\n", c.name, expRawConf, resRawConf)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
const noContexts string = `
|
|
|
apiVersion: v1
|
|
|
kind: Config
|
|
|
@@ -266,7 +592,28 @@ users:
|
|
|
- name: test-admin
|
|
|
`
|
|
|
|
|
|
-const oidcPlugin string = `
|
|
|
+const ClusterCAWithoutData string = `
|
|
|
+apiVersion: v1
|
|
|
+kind: Config
|
|
|
+clusters:
|
|
|
+- name: cluster-test
|
|
|
+ cluster:
|
|
|
+ server: https://localhost
|
|
|
+ certificate-authority: /fake/path/to/ca.pem
|
|
|
+contexts:
|
|
|
+- context:
|
|
|
+ cluster: cluster-test
|
|
|
+ user: test-admin
|
|
|
+ name: context-test
|
|
|
+users:
|
|
|
+- name: test-admin
|
|
|
+ user:
|
|
|
+ client-certificate-data: LS0tLS1CRUdJTiBDRVJ=
|
|
|
+ client-key-data: LS0tLS1CRUdJTiBDRVJ=
|
|
|
+current-context: context-test
|
|
|
+`
|
|
|
+
|
|
|
+const x509WithData string = `
|
|
|
apiVersion: v1
|
|
|
kind: Config
|
|
|
preferences: {}
|
|
|
@@ -281,16 +628,262 @@ contexts:
|
|
|
user: test-admin
|
|
|
name: context-test
|
|
|
users:
|
|
|
- - name: test-admin
|
|
|
- - name: test-admin
|
|
|
+- name: test-admin
|
|
|
+ user:
|
|
|
+ client-certificate-data: LS0tLS1CRUdJTiBDRVJ=
|
|
|
+ client-key-data: LS0tLS1CRUdJTiBDRVJ=
|
|
|
+`
|
|
|
+
|
|
|
+const x509WithoutCertData string = `
|
|
|
+apiVersion: v1
|
|
|
+kind: Config
|
|
|
+preferences: {}
|
|
|
+current-context: context-test
|
|
|
+clusters:
|
|
|
+- cluster:
|
|
|
+ server: https://localhost
|
|
|
+ name: cluster-test
|
|
|
+contexts:
|
|
|
+- context:
|
|
|
+ cluster: cluster-test
|
|
|
+ user: test-admin
|
|
|
+ name: context-test
|
|
|
+users:
|
|
|
+- name: test-admin
|
|
|
+ user:
|
|
|
+ client-certificate: /fake/path/to/cert.pem
|
|
|
+ client-key-data: LS0tLS1CRUdJTiBDRVJ=
|
|
|
+`
|
|
|
+
|
|
|
+const x509WithoutKeyData string = `
|
|
|
+apiVersion: v1
|
|
|
+kind: Config
|
|
|
+preferences: {}
|
|
|
+current-context: context-test
|
|
|
+clusters:
|
|
|
+- cluster:
|
|
|
+ server: https://localhost
|
|
|
+ name: cluster-test
|
|
|
+contexts:
|
|
|
+- context:
|
|
|
+ cluster: cluster-test
|
|
|
+ user: test-admin
|
|
|
+ name: context-test
|
|
|
+users:
|
|
|
+- name: test-admin
|
|
|
+ user:
|
|
|
+ client-certificate-data: LS0tLS1CRUdJTiBDRVJ=
|
|
|
+ client-key: /fake/path/to/key.pem
|
|
|
+`
|
|
|
+
|
|
|
+const x509WithoutCertAndKeyData string = `
|
|
|
+apiVersion: v1
|
|
|
+kind: Config
|
|
|
+preferences: {}
|
|
|
+current-context: context-test
|
|
|
+clusters:
|
|
|
+- cluster:
|
|
|
+ server: https://localhost
|
|
|
+ name: cluster-test
|
|
|
+contexts:
|
|
|
+- context:
|
|
|
+ cluster: cluster-test
|
|
|
+ user: test-admin
|
|
|
+ name: context-test
|
|
|
+users:
|
|
|
+- name: test-admin
|
|
|
+ user:
|
|
|
+ client-certificate: /fake/path/to/cert.pem
|
|
|
+ client-key: /fake/path/to/key.pem
|
|
|
+`
|
|
|
+
|
|
|
+const BearerTokenWithData string = `
|
|
|
+apiVersion: v1
|
|
|
+kind: Config
|
|
|
+preferences: {}
|
|
|
+current-context: context-test
|
|
|
+clusters:
|
|
|
+- cluster:
|
|
|
+ server: https://localhost
|
|
|
+ name: cluster-test
|
|
|
+contexts:
|
|
|
+- context:
|
|
|
+ cluster: cluster-test
|
|
|
+ user: test-admin
|
|
|
+ name: context-test
|
|
|
+users:
|
|
|
+- name: test-admin
|
|
|
+ user:
|
|
|
+ token: LS0tLS1CRUdJTiBDRVJ=
|
|
|
+`
|
|
|
+
|
|
|
+const BearerTokenWithoutData string = `
|
|
|
+apiVersion: v1
|
|
|
+kind: Config
|
|
|
+preferences: {}
|
|
|
+current-context: context-test
|
|
|
+clusters:
|
|
|
+- cluster:
|
|
|
+ server: https://localhost
|
|
|
+ name: cluster-test
|
|
|
+contexts:
|
|
|
+- context:
|
|
|
+ cluster: cluster-test
|
|
|
+ user: test-admin
|
|
|
+ name: context-test
|
|
|
+users:
|
|
|
+- name: test-admin
|
|
|
+ user:
|
|
|
+ tokenFile: /path/to/token/file.txt
|
|
|
+`
|
|
|
+const GCPPlugin string = `
|
|
|
+apiVersion: v1
|
|
|
+kind: Config
|
|
|
+clusters:
|
|
|
+- name: cluster-test
|
|
|
+ cluster:
|
|
|
+ server: https://localhost
|
|
|
+ certificate-authority-data: LS0tLS1CRUdJTiBDRVJ=
|
|
|
+users:
|
|
|
+- name: test-admin
|
|
|
+ user:
|
|
|
+ auth-provider:
|
|
|
+ name: gcp
|
|
|
+contexts:
|
|
|
+- context:
|
|
|
+ cluster: cluster-test
|
|
|
+ user: test-admin
|
|
|
+ name: context-test
|
|
|
+current-context: context-test
|
|
|
+`
|
|
|
+
|
|
|
+const AWSIamAuthenticatorExec = `
|
|
|
+apiVersion: v1
|
|
|
+clusters:
|
|
|
+- cluster:
|
|
|
+ server: https://localhost
|
|
|
+ certificate-authority-data: LS0tLS1CRUdJTiBDRVJ=
|
|
|
+ name: cluster-test
|
|
|
+contexts:
|
|
|
+- context:
|
|
|
+ cluster: cluster-test
|
|
|
+ user: test-admin
|
|
|
+ name: context-test
|
|
|
+current-context: context-test
|
|
|
+kind: Config
|
|
|
+preferences: {}
|
|
|
+users:
|
|
|
+- name: test-admin
|
|
|
+ user:
|
|
|
+ exec:
|
|
|
+ apiVersion: client.authentication.k8s.io/v1alpha1
|
|
|
+ command: aws-iam-authenticator
|
|
|
+ args:
|
|
|
+ - "token"
|
|
|
+ - "-i"
|
|
|
+ - "cluster-test"
|
|
|
+`
|
|
|
+
|
|
|
+const AWSEKSGetTokenExec = `
|
|
|
+apiVersion: v1
|
|
|
+clusters:
|
|
|
+- cluster:
|
|
|
+ server: https://localhost
|
|
|
+ certificate-authority-data: LS0tLS1CRUdJTiBDRVJ=
|
|
|
+ name: cluster-test
|
|
|
+contexts:
|
|
|
+- context:
|
|
|
+ cluster: cluster-test
|
|
|
+ user: test-admin
|
|
|
+ name: context-test
|
|
|
+current-context: context-test
|
|
|
+kind: Config
|
|
|
+preferences: {}
|
|
|
+users:
|
|
|
+- name: test-admin
|
|
|
+ user:
|
|
|
+ exec:
|
|
|
+ apiVersion: client.authentication.k8s.io/v1alpha1
|
|
|
+ command: aws
|
|
|
+ args:
|
|
|
+ - "eks"
|
|
|
+ - "get-token"
|
|
|
+ - "--cluster-name"
|
|
|
+ - "cluster-test"
|
|
|
+`
|
|
|
+
|
|
|
+const OIDCAuthWithoutData = `
|
|
|
+apiVersion: v1
|
|
|
+clusters:
|
|
|
+- cluster:
|
|
|
+ server: https://localhost
|
|
|
+ certificate-authority-data: LS0tLS1CRUdJTiBDRVJ=
|
|
|
+ name: cluster-test
|
|
|
+contexts:
|
|
|
+- context:
|
|
|
+ cluster: cluster-test
|
|
|
+ user: test-admin
|
|
|
+ name: context-test
|
|
|
+current-context: context-test
|
|
|
+kind: Config
|
|
|
+preferences: {}
|
|
|
+users:
|
|
|
+- name: test-admin
|
|
|
user:
|
|
|
auth-provider:
|
|
|
config:
|
|
|
- client-id: sampleclientid
|
|
|
- client-secret: sampleclientsecret
|
|
|
- id-token: IDTOKEN
|
|
|
- idp-issuer-url: https://login.example.com/
|
|
|
- refresh-token: REFRESHTOKEN
|
|
|
- idp-certificate-authority: /example/file/on/system.pem
|
|
|
+ client-id: porter-api
|
|
|
+ id-token: token
|
|
|
+ idp-issuer-url: https://localhost
|
|
|
+ idp-certificate-authority: /fake/path/to/ca.pem
|
|
|
name: oidc
|
|
|
`
|
|
|
+
|
|
|
+const OIDCAuthWithData = `
|
|
|
+apiVersion: v1
|
|
|
+clusters:
|
|
|
+- cluster:
|
|
|
+ server: https://localhost
|
|
|
+ certificate-authority-data: LS0tLS1CRUdJTiBDRVJ=
|
|
|
+ name: cluster-test
|
|
|
+contexts:
|
|
|
+- context:
|
|
|
+ cluster: cluster-test
|
|
|
+ user: test-admin
|
|
|
+ name: context-test
|
|
|
+current-context: context-test
|
|
|
+kind: Config
|
|
|
+preferences: {}
|
|
|
+users:
|
|
|
+- name: test-admin
|
|
|
+ user:
|
|
|
+ auth-provider:
|
|
|
+ config:
|
|
|
+ client-id: porter-api
|
|
|
+ id-token: token
|
|
|
+ idp-issuer-url: https://localhost
|
|
|
+ idp-certificate-authority-data: LS0tLS1CRUdJTiBDRVJ=
|
|
|
+ name: oidc
|
|
|
+`
|
|
|
+
|
|
|
+const BasicAuth = `
|
|
|
+apiVersion: v1
|
|
|
+clusters:
|
|
|
+- cluster:
|
|
|
+ server: https://localhost
|
|
|
+ certificate-authority-data: LS0tLS1CRUdJTiBDRVJ=
|
|
|
+ name: cluster-test
|
|
|
+contexts:
|
|
|
+- context:
|
|
|
+ cluster: cluster-test
|
|
|
+ user: test-admin
|
|
|
+ name: context-test
|
|
|
+current-context: context-test
|
|
|
+kind: Config
|
|
|
+preferences: {}
|
|
|
+users:
|
|
|
+- name: test-admin
|
|
|
+ user:
|
|
|
+ username: admin
|
|
|
+ password: changeme
|
|
|
+`
|