Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add e2e test if channel implementation exposes OIDC audience #7381

Merged
merged 2 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions test/auth/features/oidc/addressable_oidc_conformance.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ func AddressableOIDCTokenConformance(gvr schema.GroupVersionResource, kind, name
fs := feature.FeatureSet{
Name: fmt.Sprintf("%s handles requests with OIDC tokens correctly", kind),
Features: []*feature.Feature{
AddressableRejectInvalidAudience(gvr, kind, name),
AddressableRejectCorruptedSignature(gvr, kind, name),
AddressableRejectExpiredToken(gvr, kind, name),
AddressableAllowsValidRequest(gvr, kind, name),
addressableRejectInvalidAudience(gvr, kind, name),
addressableRejectCorruptedSignature(gvr, kind, name),
addressableRejectExpiredToken(gvr, kind, name),
addressableAllowsValidRequest(gvr, kind, name),
},
}

Expand All @@ -73,7 +73,7 @@ func AddressableHasAudiencePopulated(gvr schema.GroupVersionResource, kind, name
return f
}

func AddressableRejectInvalidAudience(gvr schema.GroupVersionResource, kind, name string) *feature.Feature {
func addressableRejectInvalidAudience(gvr schema.GroupVersionResource, kind, name string) *feature.Feature {
f := feature.NewFeatureNamed(fmt.Sprintf("%s reject event for wrong OIDC audience", kind))

source := feature.MakeRandomK8sName("source")
Expand All @@ -97,7 +97,7 @@ func AddressableRejectInvalidAudience(gvr schema.GroupVersionResource, kind, nam
return f
}

func AddressableRejectExpiredToken(gvr schema.GroupVersionResource, kind, name string) *feature.Feature {
func addressableRejectExpiredToken(gvr schema.GroupVersionResource, kind, name string) *feature.Feature {
f := feature.NewFeatureNamed(fmt.Sprintf("%s reject event with expired OIDC token", kind))

source := feature.MakeRandomK8sName("source")
Expand All @@ -121,7 +121,7 @@ func AddressableRejectExpiredToken(gvr schema.GroupVersionResource, kind, name s
return f
}

func AddressableRejectCorruptedSignature(gvr schema.GroupVersionResource, kind, name string) *feature.Feature {
func addressableRejectCorruptedSignature(gvr schema.GroupVersionResource, kind, name string) *feature.Feature {
f := feature.NewFeatureNamed(fmt.Sprintf("%s reject event with corrupted OIDC token signature", kind))

source := feature.MakeRandomK8sName("source")
Expand All @@ -145,7 +145,7 @@ func AddressableRejectCorruptedSignature(gvr schema.GroupVersionResource, kind,
return f
}

func AddressableAllowsValidRequest(gvr schema.GroupVersionResource, kind, name string) *feature.Feature {
func addressableAllowsValidRequest(gvr schema.GroupVersionResource, kind, name string) *feature.Feature {
f := feature.NewFeatureNamed(fmt.Sprintf("%s handles event with valid OIDC token", kind))

source := feature.MakeRandomK8sName("source")
Expand Down
20 changes: 20 additions & 0 deletions test/auth/oidc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ import (

"knative.dev/eventing/test/auth/features/oidc"
brokerfeatures "knative.dev/eventing/test/rekt/features/broker"
"knative.dev/eventing/test/rekt/features/channel"
"knative.dev/eventing/test/rekt/resources/broker"
"knative.dev/eventing/test/rekt/resources/channel_impl"
)

func TestBrokerSupportsOIDC(t *testing.T) {
Expand All @@ -52,3 +54,21 @@ func TestBrokerSupportsOIDC(t *testing.T) {
env.TestSet(ctx, t, oidc.AddressableOIDCConformance(broker.GVR(), "Broker", name, env.Namespace()))
env.Test(ctx, t, oidc.BrokerSendEventWithOIDCToken())
}

func TestChannelImplSupportsOIDC(t *testing.T) {
t.Parallel()

ctx, env := global.Environment(
knative.WithKnativeNamespace(system.Namespace()),
knative.WithLoggingConfig,
knative.WithTracingConfig,
k8s.WithEventListener,
environment.Managed(t),
environment.WithPollTimings(4*time.Second, 12*time.Minute),
)

name := feature.MakeRandomK8sName("channelimpl")
env.Prerequisite(ctx, t, channel.ImplGoesReady(name))

env.Test(ctx, t, oidc.AddressableHasAudiencePopulated(channel_impl.GVR(), channel_impl.GVK().Kind, name, env.Namespace()))
}