@@ -70,6 +70,124 @@ func TestPostgresConfigParametersV1beta1(t *testing.T) {
7070 }
7171 })
7272 })
73+
74+ t .Run ("ssl_groups and ssl_ecdh_curve" , func (t * testing.T ) {
75+ t .Run ("ssl_groups not allowed for pg17" , func (t * testing.T ) {
76+ for _ , tt := range []struct {
77+ key string
78+ value any
79+ }{
80+ {key : "ssl_groups" , value : "anything" },
81+ } {
82+ t .Run (tt .key , func (t * testing.T ) {
83+ cluster := u .DeepCopy ()
84+ require .UnmarshalIntoField (t , cluster ,
85+ require .Value (yaml .Marshal (17 )),
86+ "spec" , "postgresVersion" )
87+ require .UnmarshalIntoField (t , cluster ,
88+ require .Value (yaml .Marshal (tt .value )),
89+ "spec" , "config" , "parameters" , tt .key )
90+
91+ err := cc .Create (ctx , cluster , client .DryRunAll )
92+ assert .Assert (t , apierrors .IsInvalid (err ))
93+
94+ details := require .StatusErrorDetails (t , err )
95+ assert .Assert (t , cmp .Len (details .Causes , 1 ))
96+ })
97+ }
98+ })
99+
100+ t .Run ("ssl_groups allowed for pg18" , func (t * testing.T ) {
101+ for _ , tt := range []struct {
102+ key string
103+ value any
104+ }{
105+ {key : "ssl_groups" , value : "anything" },
106+ } {
107+ t .Run (tt .key , func (t * testing.T ) {
108+ cluster := u .DeepCopy ()
109+ require .UnmarshalIntoField (t , cluster ,
110+ require .Value (yaml .Marshal (18 )),
111+ "spec" , "postgresVersion" )
112+ require .UnmarshalIntoField (t , cluster ,
113+ require .Value (yaml .Marshal (tt .value )),
114+ "spec" , "config" , "parameters" , tt .key )
115+
116+ assert .NilError (t , cc .Create (ctx , cluster , client .DryRunAll ))
117+ })
118+ }
119+ })
120+
121+ t .Run ("ssl_ecdh_curve allowed for both" , func (t * testing.T ) {
122+ for _ , tt := range []struct {
123+ key string
124+ value any
125+ }{
126+ {key : "ssl_ecdh_curve" , value : "anything" },
127+ } {
128+ t .Run (tt .key , func (t * testing.T ) {
129+ cluster := u .DeepCopy ()
130+ require .UnmarshalIntoField (t , cluster ,
131+ require .Value (yaml .Marshal (17 )),
132+ "spec" , "postgresVersion" )
133+ require .UnmarshalIntoField (t , cluster ,
134+ require .Value (yaml .Marshal (tt .value )),
135+ "spec" , "config" , "parameters" , tt .key )
136+
137+ assert .NilError (t , cc .Create (ctx , cluster , client .DryRunAll ))
138+
139+ cluster2 := u .DeepCopy ()
140+ require .UnmarshalIntoField (t , cluster2 ,
141+ require .Value (yaml .Marshal (18 )),
142+ "spec" , "postgresVersion" )
143+ require .UnmarshalIntoField (t , cluster2 ,
144+ require .Value (yaml .Marshal (tt .value )),
145+ "spec" , "config" , "parameters" , tt .key )
146+
147+ assert .NilError (t , cc .Create (ctx , cluster2 , client .DryRunAll ))
148+ })
149+ }
150+ })
151+
152+ t .Run ("other ssl_* parameters not allowed for any pg version" , func (t * testing.T ) {
153+ for _ , tt := range []struct {
154+ key string
155+ value any
156+ }{
157+ {key : "ssl_anything" , value : "anything" },
158+ } {
159+ t .Run (tt .key , func (t * testing.T ) {
160+ cluster := u .DeepCopy ()
161+ require .UnmarshalIntoField (t , cluster ,
162+ require .Value (yaml .Marshal (17 )),
163+ "spec" , "postgresVersion" )
164+ require .UnmarshalIntoField (t , cluster ,
165+ require .Value (yaml .Marshal (tt .value )),
166+ "spec" , "config" , "parameters" , tt .key )
167+
168+ err := cc .Create (ctx , cluster , client .DryRunAll )
169+ assert .Assert (t , apierrors .IsInvalid (err ))
170+
171+ details := require .StatusErrorDetails (t , err )
172+ assert .Assert (t , cmp .Len (details .Causes , 1 ))
173+
174+ cluster1 := u .DeepCopy ()
175+ require .UnmarshalIntoField (t , cluster1 ,
176+ require .Value (yaml .Marshal (18 )),
177+ "spec" , "postgresVersion" )
178+ require .UnmarshalIntoField (t , cluster1 ,
179+ require .Value (yaml .Marshal (tt .value )),
180+ "spec" , "config" , "parameters" , tt .key )
181+
182+ err = cc .Create (ctx , cluster1 , client .DryRunAll )
183+ assert .Assert (t , apierrors .IsInvalid (err ))
184+
185+ details = require .StatusErrorDetails (t , err )
186+ assert .Assert (t , cmp .Len (details .Causes , 1 ))
187+ })
188+ }
189+ })
190+ })
73191}
74192
75193func TestPostgresConfigParametersV1 (t * testing.T ) {
0 commit comments