Skip to content

Commit

Permalink
Add e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
creydr committed Aug 20, 2024
1 parent 12e301e commit d97ddc2
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/rekt/job_sink_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,17 @@ package rekt
import (
"testing"

"knative.dev/eventing/test/rekt/features/authz"

"knative.dev/pkg/system"
"knative.dev/reconciler-test/pkg/environment"
"knative.dev/reconciler-test/pkg/eventshub"
"knative.dev/reconciler-test/pkg/feature"
"knative.dev/reconciler-test/pkg/k8s"
"knative.dev/reconciler-test/pkg/knative"

"knative.dev/eventing/test/rekt/features/jobsink"
jsresource "knative.dev/eventing/test/rekt/resources/jobsink"
)

func TestJobSinkSuccess(t *testing.T) {
Expand Down Expand Up @@ -74,3 +78,21 @@ func TestJobSinkOIDC(t *testing.T) {

env.Test(ctx, t, jobsink.OIDC())
}

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

ctx, env := global.Environment(
knative.WithKnativeNamespace(system.Namespace()),
knative.WithLoggingConfig,
knative.WithTracingConfig,
k8s.WithEventListener,
eventshub.WithTLS(t),
environment.Managed(t),
)

name := feature.MakeRandomK8sName("jobsink")
env.Prerequisite(ctx, t, jsresource.GoesReadySimple(name))

env.TestSet(ctx, t, authz.AddressableAuthZConformance(jsresource.GVR(), "JobSink", name))
}
20 changes: 20 additions & 0 deletions test/rekt/resources/jobsink/jobsink.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@ import (
"context"
"embed"
"encoding/json"
"fmt"
"strings"
"time"

"knative.dev/pkg/apis"

batchv1 "k8s.io/api/batch/v1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
Expand Down Expand Up @@ -203,3 +206,20 @@ func AsKReference(name string) *duckv1.KReference {
APIVersion: GVR().GroupVersion().String(),
}
}

// GoesReadySimple returns a feature that will create a JobSink with a simple sink
// and confirm it becomes ready with an address.
func GoesReadySimple(name string) *feature.Feature {
f := new(feature.Feature)

sink := feature.MakeRandomK8sName("sink")
sinkURL := &apis.URL{Scheme: "http", Host: sink}

f.Setup("Install sink", eventshub.Install(sink, eventshub.StartReceiver))

f.Setup(fmt.Sprintf("install JobSink %q", name), Install(name, WithForwarderJob(sinkURL.String())))
f.Setup("JobSink is ready", IsReady(name))
f.Setup("JobSink is addressable", IsAddressable(name))

return f
}

0 comments on commit d97ddc2

Please sign in to comment.