@@ -63,7 +63,7 @@ func (s *DeployTestSuite) Test_applyReleaseWithValues() {
6363 }
6464
6565 // mocks
66- s .clientMock .EXPECT ().Get (mock .Anything , types.NamespacedName {Namespace : "default" , Name : "rebac-authz-webhook-cert" }, mock .Anything ).Return (nil ).Once ()
66+ s .clientMock .EXPECT ().Get (mock .Anything , types.NamespacedName {Namespace : "default" , Name : "rebac-authz-webhook-cert" }, mock .Anything ).Return (nil ).Twice ()
6767 s .clientMock .EXPECT ().Patch (mock .Anything , mock .Anything , mock .Anything , mock .Anything ).RunAndReturn (
6868 func (ctx context.Context , obj client.Object , patch client.Patch , opts ... client.PatchOption ) error {
6969 // Simulate a successful patch operation
@@ -86,7 +86,7 @@ func (s *DeployTestSuite) Test_applyReleaseWithValues() {
8686 specJSON , ok := specValues .(apiextensionsv1.JSON )
8787 s .Require ().True (ok , "spec.values should be of type apiextensionsv1.JSON" )
8888
89- expected := `{"baseDomain":"portal.dev.local","iamWebhookCA":"","port":"8443","protocol":"https","services":{"services":{"platform-mesh-operator":{"version":"v1.0.0"}}}}`
89+ expected := `{"baseDomain":"portal.dev.local","baseDomainPort":"portal.dev.local:8443"," iamWebhookCA":"","port":"8443","protocol":"https","services":{"services":{"platform-mesh-operator":{"version":"v1.0.0"}}}}`
9090 s .Require ().Equal (expected , string (specJSON .Raw ), "spec.values.Raw should match expected JSON string" )
9191
9292 return nil
@@ -109,4 +109,48 @@ func (s *DeployTestSuite) Test_applyReleaseWithValues() {
109109
110110 err = s .testObj .ApplyReleaseWithValues (ctx , "../../manifests/k8s/platform-mesh-operator-components/release.yaml" , s .clientMock , mergedValues )
111111 s .Assert ().NoError (err , "ApplyReleaseWithValues should not return an error" )
112+
113+ // switch to standard port 443
114+ inst .Spec .Exposure = & v1alpha1.ExposureConfig {
115+ Port : 443 ,
116+ }
117+
118+ templateVars , err = subroutines .TemplateVars (ctx , inst , s .clientMock )
119+ s .Assert ().NoError (err , "TemplateVars should not return an error" )
120+
121+ s .clientMock .EXPECT ().Patch (mock .Anything , mock .Anything , mock .Anything , mock .Anything ).RunAndReturn (
122+ func (ctx context.Context , obj client.Object , patch client.Patch , opts ... client.PatchOption ) error {
123+ // Simulate a successful patch operation
124+ hr := obj .(* unstructured.Unstructured )
125+
126+ // Extract .spec
127+ spec , found , err := unstructured .NestedFieldNoCopy (hr .Object , "spec" )
128+ s .Require ().NoError (err , "should be able to get spec" )
129+ s .Require ().True (found , "spec should be present" )
130+
131+ // Check if spec is a map
132+ specMap , ok := spec .(map [string ]interface {})
133+ s .Require ().True (ok , "spec should be a map[string]interface{}" )
134+
135+ // Extract .spec.values
136+ specValues , found , err := unstructured .NestedFieldNoCopy (specMap , "values" )
137+ s .Require ().NoError (err , "should be able to get spec.values" )
138+ s .Require ().True (found , "spec.values should be present" )
139+
140+ specJSON , ok := specValues .(apiextensionsv1.JSON )
141+ s .Require ().True (ok , "spec.values should be of type apiextensionsv1.JSON" )
142+
143+ expected := `{"baseDomain":"portal.dev.local","baseDomainPort":"portal.dev.local","iamWebhookCA":"","port":"443","protocol":"https","services":{"services":{"platform-mesh-operator":{"version":"v1.0.0"}}}}`
144+ s .Require ().Equal (expected , string (specJSON .Raw ), "spec.values.Raw should match expected JSON string" )
145+
146+ return nil
147+ },
148+ ).Once ()
149+
150+ mergedValues , err = subroutines .MergeValuesAndServices (instance , templateVars )
151+ s .Assert ().NoError (err , "MergeValuesAndServices should not return an error" )
152+
153+ err = s .testObj .ApplyReleaseWithValues (ctx , "../../manifests/k8s/platform-mesh-operator-components/release.yaml" , s .clientMock , mergedValues )
154+ s .Assert ().NoError (err , "ApplyReleaseWithValues should not return an error" )
155+
112156}
0 commit comments