-
Notifications
You must be signed in to change notification settings - Fork 133
E2E tests for broker: TLS key pair rotation #3287
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
Merged
knative-prow
merged 28 commits into
knative-extensions:main
from
Leo6Leo:rekt-test-_for_TLS_key_pair_rotation
Oct 6, 2023
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
0d5d695
progress save
Leo6Leo 216b605
Merge main branch
Leo6Leo 204c66b
add the new cert rotation test
Leo6Leo 9d85eed
Update the rekt test
Leo6Leo ae3403a
Format the files
Leo6Leo 049d830
workspace save
Leo6Leo a38f82f
Merge branch 'main' into rekt-test-_for_TLS_key_pair_rotation
Leo6Leo a43d93b
maven
Leo6Leo 2c526f2
Merge branch 'main' into rekt-test-_for_TLS_key_pair_rotation
Leo6Leo 72f5b72
Clean up
Leo6Leo 041293f
Clean up
Leo6Leo 1225253
Format
Leo6Leo e1e581c
Merge branch 'main' into rekt-test-_for_TLS_key_pair_rotation
Leo6Leo f7c1392
Fix the rekt test CA cert issue on Source
Leo6Leo 1a65cc9
Format fix
Leo6Leo 72b0723
Re-order the prerequisite
Leo6Leo f5aacb0
Enable the strict transportation mode in TLS rekt tests
Leo6Leo 54d1f04
Fix the reviewDog comment
Leo6Leo 52188f6
Update test/e2e_new/broker_eventing_tls_test.go
Leo6Leo 93f3884
Fix the format of the shell script
Leo6Leo 4e87518
Fix the format of the shell script
Leo6Leo 0686a45
Update the Strict feature flag
Leo6Leo 1ce6ca0
Merge branch 'main' into rekt-test-_for_TLS_key_pair_rotation
Leo6Leo f48b148
Add the code to inject the feature flag to the context in the broker …
Leo6Leo e975fc0
Run go import
Leo6Leo 9fd2fdd
Fix the controller tests
Leo6Leo 83c4714
Merge branch 'main' into rekt-test-_for_TLS_key_pair_rotation
Leo6Leo 36c265b
Set the default value to all other feature flags when we are updating…
Leo6Leo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Copyright 2021 The Knative Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: config-features | ||
namespace: knative-eventing | ||
labels: | ||
knative.dev/config-propagation: original | ||
knative.dev/config-category: eventing | ||
data: | ||
authentication.oidc: "disabled" | ||
delivery-retryafter: "disabled" | ||
delivery-timeout: "enabled" | ||
eventtype-auto-create: "disabled" | ||
kreference-group: "disabled" | ||
kreference-mapping: "disabled" | ||
new-trigger-filters: "enabled" | ||
strict-subscriber: "disabled" | ||
transport-encryption: "Strict" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
//go:build e2e | ||
// +build e2e | ||
|
||
/* | ||
* Copyright 2023 The Knative Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package e2e_new | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
"knative.dev/eventing-kafka-broker/test/rekt/features" | ||
"knative.dev/pkg/system" | ||
"knative.dev/reconciler-test/pkg/environment" | ||
"knative.dev/reconciler-test/pkg/eventshub" | ||
"knative.dev/reconciler-test/pkg/k8s" | ||
"knative.dev/reconciler-test/pkg/knative" | ||
) | ||
|
||
func TestBrokerTLSCARotation(t *testing.T) { | ||
t.Parallel() | ||
|
||
ctx, env := global.Environment( | ||
knative.WithKnativeNamespace(system.Namespace()), | ||
knative.WithLoggingConfig, | ||
knative.WithTracingConfig, | ||
k8s.WithEventListener, | ||
environment.Managed(t), | ||
eventshub.WithTLS(t), | ||
environment.WithPollTimings(5*time.Second, 4*time.Minute), | ||
) | ||
|
||
env.Test(ctx, t, features.RotateBrokerTLSCertificates()) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
/* | ||
* Copyright 2023 The Knative Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package features | ||
|
||
import ( | ||
"context" | ||
"time" | ||
|
||
"k8s.io/apimachinery/pkg/types" | ||
"knative.dev/eventing/test/rekt/resources/addressable" | ||
"knative.dev/reconciler-test/resources/certificate" | ||
|
||
testpkg "knative.dev/eventing-kafka-broker/test/pkg" | ||
|
||
cetest "github.com/cloudevents/sdk-go/v2/test" | ||
"github.com/google/uuid" | ||
|
||
brokerconfigmap "knative.dev/eventing-kafka-broker/test/rekt/resources/configmap/broker" | ||
"knative.dev/eventing/test/rekt/features/featureflags" | ||
"knative.dev/eventing/test/rekt/resources/broker" | ||
"knative.dev/eventing/test/rekt/resources/trigger" | ||
"knative.dev/pkg/system" | ||
"knative.dev/reconciler-test/pkg/eventshub" | ||
"knative.dev/reconciler-test/pkg/eventshub/assert" | ||
"knative.dev/reconciler-test/pkg/feature" | ||
"knative.dev/reconciler-test/pkg/resources/service" | ||
) | ||
|
||
func RotateBrokerTLSCertificates() *feature.Feature { | ||
|
||
ingressCertificateName := "kafka-broker-ingress-server-tls" | ||
ingressSecretName := "kafka-broker-ingress-server-tls" | ||
|
||
brokerName := feature.MakeRandomK8sName("broker") | ||
triggerName := feature.MakeRandomK8sName("trigger") | ||
sink := feature.MakeRandomK8sName("sink") | ||
source := feature.MakeRandomK8sName("source") | ||
|
||
f := feature.NewFeatureNamed("Rotate Kafka Broker TLS certificate") | ||
|
||
brokerConfig := feature.MakeRandomK8sName("brokercfg") | ||
|
||
f.Prerequisite("transport encryption is strict", featureflags.TransportEncryptionStrict()) | ||
f.Prerequisite("should not run when Istio is enabled", featureflags.IstioDisabled()) | ||
|
||
f.Setup("Create broker config", brokerconfigmap.Install(brokerConfig, | ||
brokerconfigmap.WithNumPartitions(1), | ||
brokerconfigmap.WithReplicationFactor(1), | ||
brokerconfigmap.WithBootstrapServer(testpkg.BootstrapServersPlaintext))) | ||
|
||
f.Setup("Rotate ingress certificate", certificate.Rotate(certificate.RotateCertificate{ | ||
Certificate: types.NamespacedName{ | ||
Namespace: system.Namespace(), | ||
Name: ingressCertificateName, | ||
}, | ||
})) | ||
|
||
f.Setup("install sink", eventshub.Install(sink, eventshub.StartReceiverTLS)) | ||
f.Setup("Install broker", broker.Install(brokerName, append( | ||
broker.WithEnvConfig(), | ||
broker.WithConfig(brokerConfig))..., | ||
)) | ||
f.Setup("Broker is ready", broker.IsReady(brokerName)) | ||
f.Setup("install trigger", func(ctx context.Context, t feature.T) { | ||
d := service.AsDestinationRef(sink) | ||
d.CACerts = eventshub.GetCaCerts(ctx) | ||
trigger.Install(triggerName, brokerName, trigger.WithSubscriberFromDestination(d))(ctx, t) | ||
}) | ||
f.Setup("trigger is ready", trigger.IsReady(triggerName)) | ||
f.Setup("Broker has HTTPS address", broker.ValidateAddress(brokerName, addressable.AssertHTTPSAddress)) | ||
|
||
event := cetest.FullEvent() | ||
event.SetID(uuid.New().String()) | ||
|
||
f.Requirement("install source", eventshub.Install(source, | ||
eventshub.StartSenderToResourceTLS(broker.GVR(), brokerName, nil), | ||
eventshub.InputEvent(event), | ||
// Send multiple events so that we take into account that the certificate rotation might | ||
// be detected by the server after some time. | ||
eventshub.SendMultipleEvents(100, 3*time.Second), | ||
)) | ||
|
||
f.Assert("Event sent", assert.OnStore(source). | ||
MatchSentEvent(cetest.HasId(event.ID())). | ||
AtLeast(1), | ||
) | ||
f.Assert("Event received", assert.OnStore(sink). | ||
MatchReceivedEvent(cetest.HasId(event.ID())). | ||
AtLeast(1), | ||
) | ||
f.Assert("Source match updated peer certificate", assert.OnStore(source). | ||
MatchPeerCertificatesReceived(assert.MatchPeerCertificatesFromSecret(system.Namespace(), ingressSecretName, "tls.crt")). | ||
AtLeast(1), | ||
) | ||
|
||
return f | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.