Skip to content

Commit

Permalink
scaffold integ test for custom metadata assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
thyton committed Jan 3, 2024
1 parent 19556d7 commit 9254c8f
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 25 deletions.
19 changes: 19 additions & 0 deletions integrationtest/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,25 @@ func TestFailWithBadTokenReviewerJwt(t *testing.T) {
}
}

func TestAuthAliasCustomMetadataAssignment(t *testing.T) {
// TODO annotate serviceaccount with "auth-metadata.vault.hashicorp.com/foo" : "bar"

client, cleanup := setupKubernetesAuth(t, "vault", nil, nil)
defer cleanup()

_, err := client.Logical().Write("auth/kubernetes/login", map[string]interface{}{
"role": "test-role",
"jwt": createToken(t, "vault", nil),
})
if err != nil {
t.Fatalf("Expected successful login but got: %v", err)
}

// TODO query the alias that has the entity ID matching the service account uid

// TODO compare its custom metadata to the vault auth annotations
}

func TestUnauthorizedServiceAccountErrorCode(t *testing.T) {
client, cleanup := setupKubernetesAuth(t, "badServiceAccount", nil, nil)
defer cleanup()
Expand Down
50 changes: 25 additions & 25 deletions integrationtest/vault/serviceAccountControllerBinding.yaml
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: test-service-account-getter-account-binding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: system:controller:service-account-controller
subjects:
- kind: ServiceAccount
name: test-token-reviewer-account
namespace: test
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: test-service-account-getter-account-binding-vault
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: system:controller:service-account-controller
subjects:
- kind: ServiceAccount
name: vault
namespace: test
#apiVersion: rbac.authorization.k8s.io/v1
#kind: ClusterRoleBinding
#metadata:
# name: test-service-account-getter-account-binding
#roleRef:
# apiGroup: rbac.authorization.k8s.io
# kind: ClusterRole
# name: system:controller:service-account-controller
#subjects:
# - kind: ServiceAccount
# name: test-token-reviewer-account
# namespace: test
#---
#apiVersion: rbac.authorization.k8s.io/v1
#kind: ClusterRoleBinding
#metadata:
# name: test-service-account-getter-account-binding-vault
#roleRef:
# apiGroup: rbac.authorization.k8s.io
# kind: ClusterRole
# name: system:controller:service-account-controller
#subjects:
# - kind: ServiceAccount
# name: vault
# namespace: test


0 comments on commit 9254c8f

Please sign in to comment.