@@ -17,8 +17,13 @@ limitations under the License.
17
17
package integrationsink
18
18
19
19
import (
20
+ "context"
20
21
"time"
21
22
23
+ "k8s.io/apimachinery/pkg/runtime/schema"
24
+ "knative.dev/eventing/pkg/auth"
25
+ "knative.dev/reconciler-test/pkg/environment"
26
+
22
27
cetest "github.com/cloudevents/sdk-go/v2/test"
23
28
"github.com/google/uuid"
24
29
"knative.dev/eventing/test/rekt/features/featureflags"
@@ -95,3 +100,71 @@ func SuccessTLS() *feature.Feature {
95
100
96
101
return f
97
102
}
103
+
104
+ func OIDC () * feature.Feature {
105
+ f := feature .NewFeature ()
106
+
107
+ integrationSink := feature .MakeRandomK8sName ("integrationsink" )
108
+ source := feature .MakeRandomK8sName ("source" )
109
+ sourceNoAudience := feature .MakeRandomK8sName ("source-no-audience" )
110
+
111
+ //sinkURL := &apis.URL{Scheme: "http", Host: sink}
112
+
113
+ event := cetest .FullEvent ()
114
+ event .SetID (uuid .NewString ())
115
+
116
+ eventNoAudience := cetest .FullEvent ()
117
+ eventNoAudience .SetID (uuid .NewString ())
118
+
119
+ f .Prerequisite ("OIDC authentication is enabled" , featureflags .AuthenticationOIDCEnabled ())
120
+ f .Prerequisite ("transport encryption is strict" , featureflags .TransportEncryptionStrict ())
121
+ f .Prerequisite ("should not run when Istio is enabled" , featureflags .IstioDisabled ())
122
+
123
+ f .Setup ("install integration sink" , integrationsink .Install (integrationSink ))
124
+
125
+ f .Setup ("integrationsink is addressable" , integrationsink .IsAddressable (integrationSink ))
126
+ f .Setup ("integrationsink is ready" , integrationsink .IsReady (integrationSink ))
127
+
128
+ f .Requirement ("install source for ksink" , eventshub .Install (source ,
129
+ eventshub .StartSenderToResource (integrationsink .GVR (), integrationSink ),
130
+ eventshub .InputEvent (event ),
131
+ eventshub .AddSequence ,
132
+ eventshub .SendMultipleEvents (2 , time .Millisecond )))
133
+
134
+ f .Requirement ("install source for ksink without audience" , func (ctx context.Context , t feature.T ) {
135
+ addr , err := integrationsink .Address (ctx , sourceNoAudience )
136
+ if err != nil {
137
+ t .Error (err )
138
+ return
139
+ }
140
+
141
+ eventshub .Install (sourceNoAudience ,
142
+ eventshub .StartSenderURLTLS (addr .URL .String (), addr .CACerts ),
143
+ eventshub .InputEvent (eventNoAudience ))(ctx , t )
144
+ })
145
+
146
+ f .Assert ("IntegrationSink has audience in address" , func (ctx context.Context , t feature.T ) {
147
+ gvk := schema.GroupVersionKind {
148
+ Group : integrationsink .GVR ().Group ,
149
+ Version : integrationsink .GVR ().Version ,
150
+ Kind : "IntegrationSink" ,
151
+ }
152
+ addressable .ValidateAddress (integrationsink .GVR (), integrationSink , addressable .AssertAddressWithAudience (
153
+ auth .GetAudienceDirect (gvk , environment .FromContext (ctx ).Namespace (), integrationSink )),
154
+ )(ctx , t )
155
+ })
156
+
157
+ f .Assert ("Source sent the event" , assert .OnStore (source ).
158
+ Match (assert .MatchKind (eventshub .EventResponse )).
159
+ Match (assert .MatchStatusCode (204 )).
160
+ AtLeast (1 ),
161
+ )
162
+
163
+ f .Assert ("Source sent the event" , assert .OnStore (sourceNoAudience ).
164
+ Match (assert .MatchKind (eventshub .EventResponse )).
165
+ Match (assert .MatchStatusCode (404 )).
166
+ AtLeast (1 ),
167
+ )
168
+
169
+ return f
170
+ }
0 commit comments