44 "context"
55 "fmt"
66 "slices"
7+ "strings"
78 "testing"
89
910 cmv1 "github.com/cert-manager/cert-manager/pkg/apis/certmanager/v1"
@@ -14,6 +15,7 @@ import (
1415 apimeta "k8s.io/apimachinery/pkg/api/meta"
1516 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1617 "k8s.io/apimachinery/pkg/runtime"
18+ "k8s.io/apimachinery/pkg/types"
1719 "k8s.io/apimachinery/pkg/util/intstr"
1820 "k8s.io/apimachinery/pkg/util/uuid"
1921 "k8s.io/client-go/kubernetes/scheme"
@@ -1017,6 +1019,44 @@ func TestEnsureHostnamesClaimed(t *testing.T) {
10171019 assert .NoError (t , cl .Get (ctx , domainObjectKey , & networkingv1alpha.Domain {}), "expected to find a domain, but encountered an errro" )
10181020 },
10191021 },
1022+ {
1023+ name : "legacy and current datum-managed hostnames bypass claiming" ,
1024+ upstreamGateway : func () * gatewayv1.Gateway {
1025+ legacyUID := types .UID ("11111111-1111-1111-1111-111111111111" )
1026+ legacyHostname := fmt .Sprintf ("%s.%s" , strings .ReplaceAll (string (legacyUID ), "-" , "" ), testConfig .Gateway .TargetDomain )
1027+ gateway := newGateway (testConfig , upstreamNamespace .Name , "test" , func (g * gatewayv1.Gateway ) {
1028+ g .UID = legacyUID
1029+ g .Spec .Listeners = []gatewayv1.Listener {
1030+ {
1031+ Name : gatewayutil .DefaultHTTPListenerName ,
1032+ Port : DefaultHTTPPort ,
1033+ Protocol : gatewayv1 .HTTPProtocolType ,
1034+ Hostname : ptr .To (gatewayv1 .Hostname (legacyHostname )),
1035+ },
1036+ }
1037+ })
1038+ gateway .Status .Addresses = []gatewayv1.GatewayStatusAddress {
1039+ {
1040+ Type : ptr .To (gatewayv1 .HostnameAddressType ),
1041+ Value : legacyHostname ,
1042+ },
1043+ }
1044+ return gateway
1045+ }(),
1046+ existingDownstreamObjects : []client.Object {
1047+ & corev1.ConfigMap {
1048+ ObjectMeta : metav1.ObjectMeta {
1049+ Namespace : testConfig .Gateway .DownstreamHostnameAccountingNamespace ,
1050+ Name : "11111111111111111111111111111111.test-suite.com" ,
1051+ },
1052+ Data : map [string ]string {
1053+ "owner" : "some/other/gateway" ,
1054+ },
1055+ },
1056+ },
1057+ expectedVerifiedHostnames : []string {"11111111111111111111111111111111.test-suite.com" },
1058+ expectedClaimedHostnames : []string {"11111111111111111111111111111111.test-suite.com" },
1059+ },
10201060 {
10211061 name : "hostname matches address" ,
10221062 upstreamGateway : newGateway (testConfig , upstreamNamespace .Name , "test" , func (g * gatewayv1.Gateway ) {
0 commit comments