Skip to content

Commit 88a9d29

Browse files
committed
Update credential provider tests for actor identities
Use the actor SPIFFE format after the ateom identity split, and verify that an ateom certificate identity is rejected by credential authorization. Signed-off-by: Eitan Yarmush <eitan.yarmush@solo.io>
1 parent 80f37cf commit 88a9d29

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

‎cmd/credential-provider/kubernetes-secrets/kubeprovider_test.go‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,12 @@ func TestFetchSecretAuthorization(t *testing.T) {
170170
uri: "ate-secret://k8s.io/default/ns1/example-api/token",
171171
wantCode: codes.PermissionDenied,
172172
},
173+
{
174+
name: "ateom identity",
175+
actorSpiffeID: "spiffe://substrate-actor.local/ateom-for-actor/team-a/my-actor",
176+
uri: "ate-secret://k8s.io/default/ns1/example-api/token",
177+
wantCode: codes.PermissionDenied,
178+
},
173179
{
174180
name: "garbage identity",
175181
actorSpiffeID: "not-a-spiffe-uri",
@@ -268,7 +274,7 @@ func TestFetchSecret(t *testing.T) {
268274
t.Run(tc.name, func(t *testing.T) {
269275
client := fake.NewSimpleClientset(secret, multiKey)
270276
srv := NewServer(client, &NamespaceAuthorizer{allowed: map[string]map[string]struct{}{"team-a": {"ns1": {}}}})
271-
resp, err := srv.FetchSecret(context.Background(), &credproviderpb.FetchSecretRequest{Uri: tc.uri, ActorSpiffeId: "spiffe://substrate-actor.local/atespace/team-a/actor/my-actor"})
277+
resp, err := srv.FetchSecret(context.Background(), &credproviderpb.FetchSecretRequest{Uri: tc.uri, ActorSpiffeId: "spiffe://substrate-actor.local/actor/team-a/my-actor"})
272278
if tc.wantCode != codes.OK {
273279
if status.Code(err) != tc.wantCode {
274280
t.Fatalf("FetchSecret(%q) code = %v, want %v (err=%v)", tc.uri, status.Code(err), tc.wantCode, err)
@@ -331,7 +337,7 @@ func TestFetchSecretKubernetesErrors(t *testing.T) {
331337
client.PrependReactor("get", "secrets", func(k8stesting.Action) (bool, runtime.Object, error) { return true, nil, tc.err })
332338
srv := NewServer(client, &NamespaceAuthorizer{allowed: map[string]map[string]struct{}{"team-a": {"ns1": {}}}})
333339
_, err := srv.FetchSecret(t.Context(), &credproviderpb.FetchSecretRequest{
334-
Uri: "ate-secret://k8s.io/default/ns1/api/token", ActorSpiffeId: "spiffe://substrate-actor.local/atespace/team-a/actor/a",
340+
Uri: "ate-secret://k8s.io/default/ns1/api/token", ActorSpiffeId: "spiffe://substrate-actor.local/actor/team-a/a",
335341
})
336342
if status.Code(err) != tc.code {
337343
t.Fatalf("FetchSecret: %v, want %v", err, tc.code)
@@ -347,7 +353,7 @@ func TestFetchSecretObservesRotation(t *testing.T) {
347353
secret := &corev1.Secret{ObjectMeta: metav1.ObjectMeta{Name: "api", Namespace: "ns1"}, Data: map[string][]byte{"token": []byte("first")}}
348354
client := fake.NewSimpleClientset(secret)
349355
srv := NewServer(client, &NamespaceAuthorizer{allowed: map[string]map[string]struct{}{"team-a": {"ns1": {}}}})
350-
req := &credproviderpb.FetchSecretRequest{Uri: "ate-secret://k8s.io/default/ns1/api/token", ActorSpiffeId: "spiffe://substrate-actor.local/atespace/team-a/actor/a"}
356+
req := &credproviderpb.FetchSecretRequest{Uri: "ate-secret://k8s.io/default/ns1/api/token", ActorSpiffeId: "spiffe://substrate-actor.local/actor/team-a/a"}
351357
first, err := srv.FetchSecret(t.Context(), req)
352358
if err != nil || string(first.GetOpaqueBytes()) != "first" {
353359
t.Fatalf("first fetch: %v, %v", first, err)

‎cmd/credential-provider/kubernetes-secrets/main_test.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ func TestProviderMTLS(t *testing.T) {
368368
defer cancel()
369369
before := len(client.Actions())
370370
resp, err := credproviderpb.NewCredentialProviderClient(conn).FetchSecret(ctx, &credproviderpb.FetchSecretRequest{
371-
Uri: "ate-secret://k8s.io/default/ns1/api/token", ActorSpiffeId: "spiffe://substrate-actor.local/atespace/team-a/actor/a",
371+
Uri: "ate-secret://k8s.io/default/ns1/api/token", ActorSpiffeId: "spiffe://substrate-actor.local/actor/team-a/a",
372372
})
373373
if tc.allowed {
374374
if err != nil || string(resp.GetOpaqueBytes()) != "credential" {

0 commit comments

Comments
 (0)