| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873 |
- package forms_test
- import (
- "testing"
- "github.com/go-test/deep"
- "github.com/porter-dev/porter/internal/forms"
- "github.com/porter-dev/porter/internal/models"
- "gorm.io/gorm"
- ints "github.com/porter-dev/porter/internal/models/integrations"
- )
- func TestClusterLocal(t *testing.T) {
- tester := &tester{
- dbFileName: "./cluster_local.db",
- }
- setupTestEnv(tester, t)
- initUser(tester, t)
- initProject(tester, t)
- defer cleanup(tester, t)
- // create cluster candidate
- ccForm := &forms.CreateClusterCandidatesForm{
- ProjectID: tester.initProjects[0].ID,
- Kubeconfig: ClusterCAWithData,
- IsLocal: true,
- }
- ccs, err := ccForm.ToClusterCandidates(true)
- if err != nil {
- t.Fatalf("%v\n", err)
- }
- var cc *models.ClusterCandidate
- for _, _cc := range ccs {
- cc, err = tester.repo.Cluster.CreateClusterCandidate(_cc)
- if err != nil {
- t.Fatalf("%v\n", err)
- }
- cc, err = tester.repo.Cluster.ReadClusterCandidate(cc.ID)
- if err != nil {
- t.Fatalf("%v\n", err)
- }
- }
- form := &forms.ResolveClusterForm{
- Resolver: &models.ClusterResolverAll{},
- ClusterCandidateID: cc.ID,
- ProjectID: tester.initProjects[0].ID,
- UserID: tester.initUsers[0].ID,
- }
- // resolve integration (should be kube with local)
- err = form.ResolveIntegration(*tester.repo)
- if err != nil {
- t.Fatalf("%v\n", err)
- }
- expIntegration := &ints.KubeIntegration{
- Mechanism: ints.KubeLocal,
- UserID: tester.initUsers[0].ID,
- ProjectID: tester.initProjects[0].ID,
- Kubeconfig: cc.Kubeconfig,
- }
- // make sure integration is equal, read integration from DB
- gotIntegration, err := tester.repo.KubeIntegration.ReadKubeIntegration(form.IntegrationID)
- if err != nil {
- t.Fatalf("%v\n", err)
- }
- // reset got integration model
- gotIntegration.Model = gorm.Model{}
- if diff := deep.Equal(expIntegration, gotIntegration); diff != nil {
- t.Errorf("incorrect integration")
- t.Error(diff)
- }
- // resolve cluster
- gotCluster, err := form.ResolveCluster(*tester.repo)
- if err != nil {
- t.Fatalf("%v\n", err)
- }
- expCluster := &models.Cluster{
- AuthMechanism: models.Local,
- ProjectID: 1,
- Name: "cluster-test",
- Server: "https://localhost",
- KubeIntegrationID: 1,
- CertificateAuthorityData: []byte("-----BEGIN CER"),
- }
- gotCluster.Model = gorm.Model{}
- if diff := deep.Equal(expCluster, gotCluster); diff != nil {
- t.Errorf("incorrect cluster")
- t.Error(diff)
- }
- }
- // func TestPopulateServiceAccountBasic(t *testing.T) {
- // // create the in-memory repository
- // repo := test.NewRepository(true)
- // // create a new project
- // repo.Project.CreateProject(&models.Project{
- // Name: "test-project",
- // })
- // // create a ServiceAccountCandidate from a kubeconfig
- // saCandidates, err := kubernetes.GetServiceAccountCandidates([]byte(ClusterCAWithData), false)
- // if err != nil {
- // t.Fatalf("%v\n", err)
- // }
- // for _, saCandidate := range saCandidates {
- // repo.ServiceAccount.CreateServiceAccountCandidate(saCandidate)
- // }
- // // create a new form
- // form := forms.ServiceAccountActionResolver{
- // ServiceAccountCandidateID: 1,
- // }
- // err = form.PopulateServiceAccount(repo.ServiceAccount)
- // if err != nil {
- // t.Fatalf("%v\n", err)
- // }
- // sa, err := repo.ServiceAccount.CreateServiceAccount(form.SA)
- // decodedStr, _ := base64.StdEncoding.DecodeString("LS0tLS1CRUdJTiBDRVJ=")
- // if len(sa.Clusters) != 1 {
- // t.Fatalf("cluster not written\n")
- // }
- // if sa.Clusters[0].ServiceAccountID != 1 {
- // t.Errorf("service account ID of joined cluster is not 1")
- // }
- // if string(sa.Clusters[0].CertificateAuthorityData) != string(decodedStr) {
- // t.Errorf("cluster ca data and input do not match: expected %s, got %s\n",
- // string(sa.Clusters[0].CertificateAuthorityData), string(decodedStr))
- // }
- // if sa.Integration != "x509" {
- // t.Errorf("service account auth mechanism is not x509")
- // }
- // if string(sa.ClientCertificateData) != string(decodedStr) {
- // t.Errorf("service account cert data and input do not match: expected %s, got %s\n",
- // string(sa.ClientCertificateData), string(decodedStr))
- // }
- // if string(sa.ClientKeyData) != string(decodedStr) {
- // t.Errorf("service account key data and input do not match: expected %s, got %s\n",
- // string(sa.ClientKeyData), string(decodedStr))
- // }
- // }
- // func TestPopulateServiceAccountClusterDataAction(t *testing.T) {
- // // create the in-memory repository
- // repo := test.NewRepository(true)
- // // create a new project
- // repo.Project.CreateProject(&models.Project{
- // Name: "test-project",
- // })
- // // create a ServiceAccountCandidate from a kubeconfig
- // saCandidates, err := kubernetes.GetServiceAccountCandidates([]byte(ClusterCAWithoutData), false)
- // if err != nil {
- // t.Fatalf("%v\n", err)
- // }
- // for _, saCandidate := range saCandidates {
- // repo.ServiceAccount.CreateServiceAccountCandidate(saCandidate)
- // }
- // // create a new form
- // form := forms.ClusterCADataAction{
- // ServiceAccountActionResolver: &forms.ServiceAccountActionResolver{
- // ServiceAccountCandidateID: 1,
- // },
- // ClusterCAData: "LS0tLS1CRUdJTiBDRVJ=",
- // }
- // err = form.PopulateServiceAccount(repo.ServiceAccount)
- // if err != nil {
- // t.Fatalf("%v\n", err)
- // }
- // sa, err := repo.ServiceAccount.CreateServiceAccount(form.ServiceAccountActionResolver.SA)
- // decodedStr, _ := base64.StdEncoding.DecodeString("LS0tLS1CRUdJTiBDRVJ=")
- // if len(sa.Clusters) != 1 {
- // t.Fatalf("cluster not written\n")
- // }
- // if sa.Clusters[0].ServiceAccountID != 1 {
- // t.Errorf("service account ID of joined cluster is not 1")
- // }
- // if string(sa.Clusters[0].CertificateAuthorityData) != string(decodedStr) {
- // t.Errorf("cluster ca data and input do not match: expected %s, got %s\n",
- // string(sa.Clusters[0].CertificateAuthorityData), string(decodedStr))
- // }
- // if sa.Integration != "x509" {
- // t.Errorf("service account auth mechanism is not x509")
- // }
- // if string(sa.ClientCertificateData) != string(decodedStr) {
- // t.Errorf("service account cert data and input do not match: expected %s, got %s\n",
- // string(sa.ClientCertificateData), string(decodedStr))
- // }
- // if string(sa.ClientKeyData) != string(decodedStr) {
- // t.Errorf("service account key data and input do not match: expected %s, got %s\n",
- // string(sa.ClientKeyData), string(decodedStr))
- // }
- // }
- // func TestPopulateServiceAccountClusterLocalhostAction(t *testing.T) {
- // // create the in-memory repository
- // repo := test.NewRepository(true)
- // // create a new project
- // repo.Project.CreateProject(&models.Project{
- // Name: "test-project",
- // })
- // // create a ServiceAccountCandidate from a kubeconfig
- // saCandidates, err := kubernetes.GetServiceAccountCandidates([]byte(ClusterLocalhost), false)
- // if err != nil {
- // t.Fatalf("%v\n", err)
- // }
- // for _, saCandidate := range saCandidates {
- // repo.ServiceAccount.CreateServiceAccountCandidate(saCandidate)
- // }
- // // create a new form
- // form := forms.ClusterLocalhostAction{
- // ServiceAccountActionResolver: &forms.ServiceAccountActionResolver{
- // ServiceAccountCandidateID: 1,
- // },
- // ClusterHostname: "host.docker.internal",
- // }
- // err = form.PopulateServiceAccount(repo.ServiceAccount)
- // if err != nil {
- // t.Fatalf("%v\n", err)
- // }
- // sa, err := repo.ServiceAccount.CreateServiceAccount(form.ServiceAccountActionResolver.SA)
- // decodedStr, _ := base64.StdEncoding.DecodeString("LS0tLS1CRUdJTiBDRVJ=")
- // if len(sa.Clusters) != 1 {
- // t.Fatalf("cluster not written\n")
- // }
- // if sa.Clusters[0].ServiceAccountID != 1 {
- // t.Errorf("service account ID of joined cluster is not 1")
- // }
- // if sa.Clusters[0].Server != "https://host.docker.internal:30000" {
- // t.Errorf("service account cluster server is incorrect: expected %s, got %s\n",
- // "https://host.docker.internal:30000", sa.Clusters[0].Server)
- // }
- // if sa.Integration != "x509" {
- // t.Errorf("service account auth mechanism is not x509")
- // }
- // if string(sa.ClientCertificateData) != string(decodedStr) {
- // t.Errorf("service account cert data and input do not match: expected %s, got %s\n",
- // string(sa.ClientCertificateData), string(decodedStr))
- // }
- // if string(sa.ClientKeyData) != string(decodedStr) {
- // t.Errorf("service account key data and input do not match: expected %s, got %s\n",
- // string(sa.ClientKeyData), string(decodedStr))
- // }
- // }
- // func TestPopulateServiceAccountClientCertAction(t *testing.T) {
- // // create the in-memory repository
- // repo := test.NewRepository(true)
- // // create a new project
- // repo.Project.CreateProject(&models.Project{
- // Name: "test-project",
- // })
- // // create a ServiceAccountCandidate from a kubeconfig
- // saCandidates, err := kubernetes.GetServiceAccountCandidates([]byte(ClientWithoutCertData), false)
- // if err != nil {
- // t.Fatalf("%v\n", err)
- // }
- // for _, saCandidate := range saCandidates {
- // repo.ServiceAccount.CreateServiceAccountCandidate(saCandidate)
- // }
- // // create a new form
- // form := forms.ClientCertDataAction{
- // ServiceAccountActionResolver: &forms.ServiceAccountActionResolver{
- // ServiceAccountCandidateID: 1,
- // },
- // ClientCertData: "LS0tLS1CRUdJTiBDRVJ=",
- // }
- // err = form.PopulateServiceAccount(repo.ServiceAccount)
- // if err != nil {
- // t.Fatalf("%v\n", err)
- // }
- // sa, err := repo.ServiceAccount.CreateServiceAccount(form.ServiceAccountActionResolver.SA)
- // decodedStr, _ := base64.StdEncoding.DecodeString("LS0tLS1CRUdJTiBDRVJ=")
- // if len(sa.Clusters) != 1 {
- // t.Fatalf("cluster not written\n")
- // }
- // if sa.Clusters[0].ServiceAccountID != 1 {
- // t.Errorf("service account ID of joined cluster is not 1")
- // }
- // if string(sa.Clusters[0].CertificateAuthorityData) != string(decodedStr) {
- // t.Errorf("cluster ca data and input do not match: expected %s, got %s\n",
- // string(sa.Clusters[0].CertificateAuthorityData), string(decodedStr))
- // }
- // if sa.Integration != "x509" {
- // t.Errorf("service account auth mechanism is not x509")
- // }
- // if string(sa.ClientCertificateData) != string(decodedStr) {
- // t.Errorf("service account cert data and input do not match: expected %s, got %s\n",
- // string(sa.ClientCertificateData), string(decodedStr))
- // }
- // if string(sa.ClientKeyData) != string(decodedStr) {
- // t.Errorf("service account key data and input do not match: expected %s, got %s\n",
- // string(sa.ClientKeyData), string(decodedStr))
- // }
- // }
- // func TestPopulateServiceAccountClientCertAndKeyActions(t *testing.T) {
- // // create the in-memory repository
- // repo := test.NewRepository(true)
- // // create a new project
- // repo.Project.CreateProject(&models.Project{
- // Name: "test-project",
- // })
- // // create a ServiceAccountCandidate from a kubeconfig
- // saCandidates, err := kubernetes.GetServiceAccountCandidates([]byte(ClientWithoutCertAndKeyData), false)
- // if err != nil {
- // t.Fatalf("%v\n", err)
- // }
- // for _, saCandidate := range saCandidates {
- // repo.ServiceAccount.CreateServiceAccountCandidate(saCandidate)
- // }
- // // create a new form
- // form := forms.ClientCertDataAction{
- // ServiceAccountActionResolver: &forms.ServiceAccountActionResolver{
- // ServiceAccountCandidateID: 1,
- // },
- // ClientCertData: "LS0tLS1CRUdJTiBDRVJ=",
- // }
- // err = form.PopulateServiceAccount(repo.ServiceAccount)
- // if err != nil {
- // t.Fatalf("%v\n", err)
- // }
- // keyForm := forms.ClientKeyDataAction{
- // ServiceAccountActionResolver: form.ServiceAccountActionResolver,
- // ClientKeyData: "LS0tLS1CRUdJTiBDRVJ=",
- // }
- // err = keyForm.PopulateServiceAccount(repo.ServiceAccount)
- // if err != nil {
- // t.Fatalf("%v\n", err)
- // }
- // sa, err := repo.ServiceAccount.CreateServiceAccount(keyForm.ServiceAccountActionResolver.SA)
- // decodedStr, _ := base64.StdEncoding.DecodeString("LS0tLS1CRUdJTiBDRVJ=")
- // if len(sa.Clusters) != 1 {
- // t.Fatalf("cluster not written\n")
- // }
- // if sa.Clusters[0].ServiceAccountID != 1 {
- // t.Errorf("service account ID of joined cluster is not 1")
- // }
- // if string(sa.Clusters[0].CertificateAuthorityData) != string(decodedStr) {
- // t.Errorf("cluster ca data and input do not match: expected %s, got %s\n",
- // string(sa.Clusters[0].CertificateAuthorityData), string(decodedStr))
- // }
- // if sa.Integration != "x509" {
- // t.Errorf("service account auth mechanism is not x509")
- // }
- // if string(sa.ClientCertificateData) != string(decodedStr) {
- // t.Errorf("service account cert data and input do not match: expected %s, got %s\n",
- // string(sa.ClientCertificateData), string(decodedStr))
- // }
- // if string(sa.ClientKeyData) != string(decodedStr) {
- // t.Errorf("service account cert data and input do not match: expected %s, got %s\n",
- // string(sa.ClientKeyData), string(decodedStr))
- // }
- // }
- // func TestPopulateServiceAccountTokenDataAction(t *testing.T) {
- // // create the in-memory repository
- // repo := test.NewRepository(true)
- // tokenData := "abcdefghijklmnop"
- // // create a new project
- // repo.Project.CreateProject(&models.Project{
- // Name: "test-project",
- // })
- // // create a ServiceAccountCandidate from a kubeconfig
- // saCandidates, err := kubernetes.GetServiceAccountCandidates([]byte(BearerTokenWithoutData), false)
- // if err != nil {
- // t.Fatalf("%v\n", err)
- // }
- // for _, saCandidate := range saCandidates {
- // repo.ServiceAccount.CreateServiceAccountCandidate(saCandidate)
- // }
- // // create a new form
- // form := forms.TokenDataAction{
- // ServiceAccountActionResolver: &forms.ServiceAccountActionResolver{
- // ServiceAccountCandidateID: 1,
- // },
- // TokenData: tokenData,
- // }
- // err = form.PopulateServiceAccount(repo.ServiceAccount)
- // if err != nil {
- // t.Fatalf("%v\n", err)
- // }
- // sa, err := repo.ServiceAccount.CreateServiceAccount(form.ServiceAccountActionResolver.SA)
- // if len(sa.Clusters) != 1 {
- // t.Fatalf("cluster not written\n")
- // }
- // if sa.Clusters[0].ServiceAccountID != 1 {
- // t.Errorf("service account ID of joined cluster is not 1")
- // }
- // if sa.Integration != models.Bearer {
- // t.Errorf("service account auth mechanism is not %s\n", models.Bearer)
- // }
- // if string(sa.Token) != tokenData {
- // t.Errorf("service account token data is wrong: expected %s, got %s\n",
- // tokenData, sa.Token)
- // }
- // }
- // func TestPopulateServiceAccountGCPKeyDataAction(t *testing.T) {
- // // create the in-memory repository
- // repo := test.NewRepository(true)
- // gcpKeyData := []byte(`{"key": "data"}`)
- // // create a new project
- // repo.Project.CreateProject(&models.Project{
- // Name: "test-project",
- // })
- // // create a ServiceAccountCandidate from a kubeconfig
- // saCandidates, err := kubernetes.GetServiceAccountCandidates([]byte(GCPPlugin), false)
- // if err != nil {
- // t.Fatalf("%v\n", err)
- // }
- // for _, saCandidate := range saCandidates {
- // repo.ServiceAccount.CreateServiceAccountCandidate(saCandidate)
- // }
- // // create a new form
- // form := forms.GCPKeyDataAction{
- // ServiceAccountActionResolver: &forms.ServiceAccountActionResolver{
- // ServiceAccountCandidateID: 1,
- // },
- // GCPKeyData: string(gcpKeyData),
- // }
- // err = form.PopulateServiceAccount(repo.ServiceAccount)
- // if err != nil {
- // t.Fatalf("%v\n", err)
- // }
- // sa, err := repo.ServiceAccount.CreateServiceAccount(form.ServiceAccountActionResolver.SA)
- // if len(sa.Clusters) != 1 {
- // t.Fatalf("cluster not written\n")
- // }
- // if sa.Clusters[0].ServiceAccountID != 1 {
- // t.Errorf("service account ID of joined cluster is not 1")
- // }
- // if sa.Integration != models.GCP {
- // t.Errorf("service account auth mechanism is not %s\n", models.GCP)
- // }
- // if string(sa.GCPKeyData) != string(gcpKeyData) {
- // t.Errorf("service account token data is wrong: expected %s, got %s\n",
- // string(sa.GCPKeyData), string(gcpKeyData))
- // }
- // }
- // func TestPopulateServiceAccountAWSKeyDataAction(t *testing.T) {
- // // create the in-memory repository
- // repo := test.NewRepository(true)
- // // create a new project
- // repo.Project.CreateProject(&models.Project{
- // Name: "test-project",
- // })
- // // create a ServiceAccountCandidate from a kubeconfig
- // saCandidates, err := kubernetes.GetServiceAccountCandidates([]byte(AWSEKSGetTokenExec), false)
- // if err != nil {
- // t.Fatalf("%v\n", err)
- // }
- // for _, saCandidate := range saCandidates {
- // repo.ServiceAccount.CreateServiceAccountCandidate(saCandidate)
- // }
- // // create a new form
- // form := forms.AWSDataAction{
- // ServiceAccountActionResolver: &forms.ServiceAccountActionResolver{
- // ServiceAccountCandidateID: 1,
- // },
- // AWSAccessKeyID: "ALSDKJFADSF",
- // AWSSecretAccessKey: "ASDLFKJALSDKFJ",
- // AWSClusterID: "cluster-test",
- // }
- // err = form.PopulateServiceAccount(repo.ServiceAccount)
- // if err != nil {
- // t.Fatalf("%v\n", err)
- // }
- // sa, err := repo.ServiceAccount.CreateServiceAccount(form.ServiceAccountActionResolver.SA)
- // if len(sa.Clusters) != 1 {
- // t.Fatalf("cluster not written\n")
- // }
- // if sa.Clusters[0].ServiceAccountID != 1 {
- // t.Errorf("service account ID of joined cluster is not 1")
- // }
- // if sa.Integration != models.AWS {
- // t.Errorf("service account auth mechanism is not %s\n", models.AWS)
- // }
- // if string(sa.AWSAccessKeyID) != "ALSDKJFADSF" {
- // t.Errorf("service account aws access key id is wrong: expected %s, got %s\n",
- // "ALSDKJFADSF", sa.AWSAccessKeyID)
- // }
- // if string(sa.AWSSecretAccessKey) != "ASDLFKJALSDKFJ" {
- // t.Errorf("service account aws access secret key is wrong: expected %s, got %s\n",
- // "ASDLFKJALSDKFJ", sa.AWSSecretAccessKey)
- // }
- // if string(sa.AWSClusterID) != "cluster-test" {
- // t.Errorf("service account aws cluster id is wrong: expected %s, got %s\n",
- // "cluster-test", sa.AWSClusterID)
- // }
- // }
- // func TestPopulateServiceAccountOIDCAction(t *testing.T) {
- // // create the in-memory repository
- // repo := test.NewRepository(true)
- // // create a new project
- // repo.Project.CreateProject(&models.Project{
- // Name: "test-project",
- // })
- // // create a ServiceAccountCandidate from a kubeconfig
- // saCandidates, err := kubernetes.GetServiceAccountCandidates([]byte(OIDCAuthWithoutData), false)
- // if err != nil {
- // t.Fatalf("%v\n", err)
- // }
- // for _, saCandidate := range saCandidates {
- // repo.ServiceAccount.CreateServiceAccountCandidate(saCandidate)
- // }
- // // create a new form
- // form := forms.OIDCIssuerDataAction{
- // ServiceAccountActionResolver: &forms.ServiceAccountActionResolver{
- // ServiceAccountCandidateID: 1,
- // },
- // OIDCIssuerCAData: "LS0tLS1CRUdJTiBDRVJ=",
- // }
- // err = form.PopulateServiceAccount(repo.ServiceAccount)
- // if err != nil {
- // t.Fatalf("%v\n", err)
- // }
- // sa, err := repo.ServiceAccount.CreateServiceAccount(form.ServiceAccountActionResolver.SA)
- // if len(sa.Clusters) != 1 {
- // t.Fatalf("cluster not written\n")
- // }
- // if sa.Clusters[0].ServiceAccountID != 1 {
- // t.Errorf("service account ID of joined cluster is not 1")
- // }
- // if sa.Integration != models.OIDC {
- // t.Errorf("service account auth mechanism is not %s\n", models.OIDC)
- // }
- // if string(sa.OIDCCertificateAuthorityData) != "LS0tLS1CRUdJTiBDRVJ=" {
- // t.Errorf("service account key data and input do not match: expected %s, got %s\n",
- // string(sa.OIDCCertificateAuthorityData), "LS0tLS1CRUdJTiBDRVJ=")
- // }
- // }
- const ClusterCAWithData string = `
- apiVersion: v1
- kind: Config
- clusters:
- - name: cluster-test
- cluster:
- server: https://localhost
- certificate-authority-data: LS0tLS1CRUdJTiBDRVJ=
- 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 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 ClusterLocalhost string = `
- apiVersion: v1
- kind: Config
- clusters:
- - name: cluster-test
- cluster:
- server: https://localhost:30000
- 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 ClientWithoutCertData string = `
- apiVersion: v1
- kind: Config
- clusters:
- - name: cluster-test
- cluster:
- server: https://localhost
- certificate-authority-data: LS0tLS1CRUdJTiBDRVJ=
- contexts:
- - context:
- cluster: cluster-test
- user: test-admin
- name: context-test
- users:
- - name: test-admin
- user:
- client-certificate: /fake/path/to/ca.pem
- client-key-data: LS0tLS1CRUdJTiBDRVJ=
- current-context: context-test
- `
- const ClientWithoutCertAndKeyData string = `
- apiVersion: v1
- kind: Config
- clusters:
- - name: cluster-test
- cluster:
- server: https://localhost
- certificate-authority-data: LS0tLS1CRUdJTiBDRVJ=
- contexts:
- - context:
- cluster: cluster-test
- user: test-admin
- name: context-test
- users:
- - name: test-admin
- user:
- client-certificate: /fake/path/to/ca.pem
- client-key: /fake/path/to/ca.pem
- current-context: context-test
- `
- 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 AWSEKSGetTokenExec string = `
- 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 string = `
- 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: /fake/path/to/ca.pem
- name: oidc
- `
|