Skip to content

Commit

Permalink
Merge pull request #51 from patoarvizu/add-config-to-auth-struct
Browse files Browse the repository at this point in the history
Add config to auth struct
  • Loading branch information
patoarvizu authored Jan 1, 2022
2 parents 6343be5 + 877048f commit bdebb30
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ jobs:
name: Run all tests
command: |
export KUBECONFIG=~/.k3d/k3s-default-config
k3d cluster create --wait
k3d cluster create --image rancher/k3s:v1.21.8-k3s1 # --k3s-server-arg "--kube-apiserver-arg=feature-gates=ServerSideApply=false"
k3d image import patoarvizu/vault-dynamic-configuration-operator:latest
kubectl apply -f https://raw.githubusercontent.com/patoarvizu/common-manifests/master/prometheus-operator/crds.yaml
sleep 10
Expand Down
5 changes: 3 additions & 2 deletions controllers/serviceaccount_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ type BankVaultsConfig struct {
}

type Auth struct {
Roles []Role `json:"roles"`
Type string `json:"type"`
Roles []Role `json:"roles"`
Type string `json:"type"`
Config map[string]interface{} `json:"config,omitempty"`
}

type Policy struct {
Expand Down
23 changes: 23 additions & 0 deletions test/e2e/operator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ var _ = AfterSuite(func() {
By("tearing down the test environment")
err := testEnv.Stop()
Expect(err).ToNot(HaveOccurred())
err = testKubernetesConfigStillExists()
Expect(err).ToNot(HaveOccurred())
})

func newTrue() *bool {
Expand Down Expand Up @@ -180,6 +182,27 @@ func namespaceIsInAllowedList(namespace string, allowedNamespaces interface{}) b
return false
}

func testKubernetesConfigStillExists() error {
vaultCR := &bankvaultsv1alpha1.Vault{}
bvConfig := controllers.BankVaultsConfig{}
err := wait.Poll(time.Second*2, time.Second*20, func() (done bool, err error) {
k8sClient.Get(context.TODO(), types.NamespacedName{Name: "vault", Namespace: "vault"}, vaultCR)
jsonData, wErr := json.Marshal(vaultCR.Spec.ExternalConfig)
if wErr != nil {
return false, nil
}
wErr = json.Unmarshal(jsonData, &bvConfig)
if wErr != nil {
return false, nil
}
if len(bvConfig.Auth[0].Config) == 0 || bvConfig.Auth[0].Config == nil {
return true, errors.New("Kubernetes config map got wiped")
}
return true, nil
})
return err
}

func testVaultRole(name string, namespaces []string) error {
vaultCR := &bankvaultsv1alpha1.Vault{}
bvConfig := controllers.BankVaultsConfig{}
Expand Down

0 comments on commit bdebb30

Please sign in to comment.