@@ -2729,6 +2729,53 @@ func TestReconcile_TLSAlignment(t *testing.T) {
27292729 }
27302730}
27312731
2732+ func TestReconcile_TLSWithServicePort443 (t * testing.T ) {
2733+ ensureGatewaySchemeRegistered (t )
2734+ ctx := context .Background ()
2735+
2736+ cp := & coderv1alpha1.CoderControlPlane {
2737+ ObjectMeta : metav1.ObjectMeta {Name : "test-tls-service-port-443" , Namespace : "default" },
2738+ Spec : coderv1alpha1.CoderControlPlaneSpec {
2739+ Image : "test-tls-443:latest" ,
2740+ Service : coderv1alpha1.ServiceSpec {
2741+ Port : 443 ,
2742+ },
2743+ TLS : coderv1alpha1.TLSSpec {
2744+ SecretNames : []string {"my-tls-443" },
2745+ },
2746+ },
2747+ }
2748+ if err := k8sClient .Create (ctx , cp ); err != nil {
2749+ t .Fatalf ("create control plane: %v" , err )
2750+ }
2751+ t .Cleanup (func () {
2752+ _ = k8sClient .Delete (ctx , cp )
2753+ })
2754+
2755+ r := & controller.CoderControlPlaneReconciler {Client : k8sClient , Scheme : scheme }
2756+ if _ , err := r .Reconcile (ctx , ctrl.Request {NamespacedName : types.NamespacedName {Name : cp .Name , Namespace : cp .Namespace }}); err != nil {
2757+ t .Fatalf ("reconcile control plane: %v" , err )
2758+ }
2759+
2760+ service := & corev1.Service {}
2761+ if err := k8sClient .Get (ctx , types.NamespacedName {Name : cp .Name , Namespace : cp .Namespace }, service ); err != nil {
2762+ t .Fatalf ("get service: %v" , err )
2763+ }
2764+ if len (service .Spec .Ports ) != 1 {
2765+ t .Fatalf ("expected exactly one service port when service.port=443 and TLS is enabled, got %+v" , service .Spec .Ports )
2766+ }
2767+ port := service .Spec .Ports [0 ]
2768+ if port .Name != "https" {
2769+ t .Fatalf ("expected single service port to be named https, got %q" , port .Name )
2770+ }
2771+ if port .Port != 443 {
2772+ t .Fatalf ("expected single service port number 443, got %d" , port .Port )
2773+ }
2774+ if port .TargetPort != intstr .FromInt (8443 ) {
2775+ t .Fatalf ("expected single service port target 8443, got %+v" , port .TargetPort )
2776+ }
2777+ }
2778+
27322779func TestReconcile_PassThroughConfiguration (t * testing.T ) {
27332780 ensureGatewaySchemeRegistered (t )
27342781 ctx := context .Background ()
0 commit comments