|
7 | 7 |
|
8 | 8 | . "github.com/onsi/ginkgo/v2" |
9 | 9 | . "github.com/onsi/gomega" |
| 10 | + openshiftconfigv1 "github.com/openshift/api/config/v1" |
10 | 11 | corev1 "k8s.io/api/core/v1" |
11 | 12 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
12 | 13 | "k8s.io/apimachinery/pkg/types" |
@@ -163,6 +164,80 @@ var _ = Describe("AAQ tests", func() { |
163 | 164 | Expect(aaq.Spec.CertConfig.Server.Duration.Duration.String()).To(Equal("36h0m0s")) |
164 | 165 | Expect(aaq.Spec.CertConfig.Server.RenewBefore.Duration.String()).To(Equal("18h0m0s")) |
165 | 166 | }) |
| 167 | + |
| 168 | + Context("TLSSecurityProfile", func() { |
| 169 | + |
| 170 | + intermediateTLSSecurityProfile := &openshiftconfigv1.TLSSecurityProfile{ |
| 171 | + Type: openshiftconfigv1.TLSProfileIntermediateType, |
| 172 | + Intermediate: &openshiftconfigv1.IntermediateTLSProfile{}, |
| 173 | + } |
| 174 | + modernTLSSecurityProfile := &openshiftconfigv1.TLSSecurityProfile{ |
| 175 | + Type: openshiftconfigv1.TLSProfileModernType, |
| 176 | + Modern: &openshiftconfigv1.ModernTLSProfile{}, |
| 177 | + } |
| 178 | + |
| 179 | + It("should modify TLSSecurityProfile on AAQ CR according to ApiServer or HCO CR", func(ctx context.Context) { |
| 180 | + existingResource, err := NewAAQ(hco) |
| 181 | + Expect(err).ToNot(HaveOccurred()) |
| 182 | + Expect(existingResource.Spec.TLSSecurityProfile).To(Equal(openshift2AAQSecProfile(intermediateTLSSecurityProfile))) |
| 183 | + |
| 184 | + // now, modify HCO's TLSSecurityProfile |
| 185 | + hco.Spec.TLSSecurityProfile = modernTLSSecurityProfile |
| 186 | + hco.Spec.EnableApplicationAwareQuota = ptr.To(true) |
| 187 | + |
| 188 | + cl := commontestutils.InitClient([]client.Object{hco, existingResource}) |
| 189 | + handler := NewAAQHandler(cl, commontestutils.GetScheme()) |
| 190 | + res := handler.Ensure(req) |
| 191 | + Expect(res.UpgradeDone).To(BeFalse()) |
| 192 | + Expect(res.Updated).To(BeTrue()) |
| 193 | + Expect(res.Err).ToNot(HaveOccurred()) |
| 194 | + |
| 195 | + foundResource := &aaqv1alpha1.AAQ{} |
| 196 | + Expect( |
| 197 | + cl.Get(ctx, |
| 198 | + types.NamespacedName{Name: existingResource.Name, Namespace: existingResource.Namespace}, |
| 199 | + foundResource), |
| 200 | + ).ToNot(HaveOccurred()) |
| 201 | + |
| 202 | + Expect(foundResource.Spec.TLSSecurityProfile).To(Equal(openshift2AAQSecProfile(modernTLSSecurityProfile))) |
| 203 | + |
| 204 | + Expect(req.Conditions).To(BeEmpty()) |
| 205 | + }) |
| 206 | + |
| 207 | + It("should overwrite TLSSecurityProfile if directly set on AAQ CR", func(ctx context.Context) { |
| 208 | + hco.Spec.TLSSecurityProfile = intermediateTLSSecurityProfile |
| 209 | + existingResource, err := NewAAQ(hco) |
| 210 | + Expect(err).ToNot(HaveOccurred()) |
| 211 | + |
| 212 | + // mock a reconciliation triggered by a change in AAQ CR |
| 213 | + req.HCOTriggered = false |
| 214 | + |
| 215 | + // now, modify AAQ node placement |
| 216 | + existingResource.Spec.TLSSecurityProfile = openshift2AAQSecProfile(modernTLSSecurityProfile) |
| 217 | + |
| 218 | + hco.Spec.EnableApplicationAwareQuota = ptr.To(true) |
| 219 | + |
| 220 | + cl := commontestutils.InitClient([]client.Object{hco, existingResource}) |
| 221 | + handler := NewAAQHandler(cl, commontestutils.GetScheme()) |
| 222 | + res := handler.Ensure(req) |
| 223 | + Expect(res.UpgradeDone).To(BeFalse()) |
| 224 | + Expect(res.Updated).To(BeTrue()) |
| 225 | + Expect(res.Overwritten).To(BeTrue()) |
| 226 | + Expect(res.Err).ToNot(HaveOccurred()) |
| 227 | + |
| 228 | + foundResource := &aaqv1alpha1.AAQ{} |
| 229 | + Expect( |
| 230 | + cl.Get(ctx, |
| 231 | + types.NamespacedName{Name: existingResource.Name, Namespace: existingResource.Namespace}, |
| 232 | + foundResource), |
| 233 | + ).ToNot(HaveOccurred()) |
| 234 | + |
| 235 | + Expect(foundResource.Spec.TLSSecurityProfile).To(Equal(openshift2AAQSecProfile(hco.Spec.TLSSecurityProfile))) |
| 236 | + Expect(foundResource.Spec.TLSSecurityProfile).ToNot(Equal(existingResource.Spec.TLSSecurityProfile)) |
| 237 | + |
| 238 | + Expect(req.Conditions).To(BeEmpty()) |
| 239 | + }) |
| 240 | + }) |
166 | 241 | }) |
167 | 242 |
|
168 | 243 | Context("check FG", func() { |
|
0 commit comments