forked from gardener/gardener
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd_test.go
More file actions
100 lines (86 loc) · 3.14 KB
/
add_test.go
File metadata and controls
100 lines (86 loc) · 3.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
// SPDX-FileCopyrightText: SAP SE or an SAP affiliate company and Gardener contributors
//
// SPDX-License-Identifier: Apache-2.0
package reference_test
import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
autoscalingv1 "k8s.io/api/autoscaling/v1"
corev1 "k8s.io/api/core/v1"
gardencorev1beta1 "github.com/gardener/gardener/pkg/apis/core/v1beta1"
. "github.com/gardener/gardener/pkg/controllermanager/controller/shoot/reference"
)
var _ = Describe("Add", func() {
Describe("#Predicate", func() {
var shoot *gardencorev1beta1.Shoot
BeforeEach(func() {
shoot = &gardencorev1beta1.Shoot{
Spec: gardencorev1beta1.ShootSpec{
Kubernetes: gardencorev1beta1.Kubernetes{
KubeAPIServer: &gardencorev1beta1.KubeAPIServerConfig{},
},
},
}
})
It("should return false because new object is no shoot", func() {
Expect(Predicate(nil, nil)).To(BeFalse())
})
It("should return false because old object is no shoot", func() {
Expect(Predicate(nil, shoot)).To(BeFalse())
})
It("should return false because there is no ref change", func() {
Expect(Predicate(shoot, shoot)).To(BeFalse())
})
It("should return true because the DNS fields changed", func() {
oldShoot := shoot.DeepCopy()
shoot.Spec.DNS = &gardencorev1beta1.DNS{
Providers: []gardencorev1beta1.DNSProvider{{
CredentialsRef: &autoscalingv1.CrossVersionObjectReference{
APIVersion: "v1",
Kind: "Secret",
Name: "secret",
},
}},
}
Expect(Predicate(oldShoot, shoot)).To(BeTrue())
})
It("should return true because the admission plugins field changed", func() {
oldShoot := shoot.DeepCopy()
shoot.Spec.Kubernetes.KubeAPIServer.AdmissionPlugins = []gardencorev1beta1.AdmissionPlugin{{}}
Expect(Predicate(oldShoot, shoot)).To(BeTrue())
})
It("should return true because the audit policy field changed", func() {
oldShoot := shoot.DeepCopy()
shoot.Spec.Kubernetes.KubeAPIServer.AuditConfig = &gardencorev1beta1.AuditConfig{
AuditPolicy: &gardencorev1beta1.AuditPolicy{
ConfigMapRef: &corev1.ObjectReference{
Name: "audit-policy",
},
},
}
Expect(Predicate(oldShoot, shoot)).To(BeTrue())
})
It("should return true because the structured authentication field changed", func() {
oldShoot := shoot.DeepCopy()
shoot.Spec.Kubernetes.KubeAPIServer.StructuredAuthentication = &gardencorev1beta1.StructuredAuthentication{}
Expect(Predicate(oldShoot, shoot)).To(BeTrue())
})
It("should return true because the structured authorization field changed", func() {
oldShoot := shoot.DeepCopy()
shoot.Spec.Kubernetes.KubeAPIServer.StructuredAuthorization = &gardencorev1beta1.StructuredAuthorization{}
Expect(Predicate(oldShoot, shoot)).To(BeTrue())
})
It("should return true because the resources field changed", func() {
oldShoot := shoot.DeepCopy()
shoot.Spec.Resources = []gardencorev1beta1.NamedResourceReference{{
Name: "resource-1",
ResourceRef: autoscalingv1.CrossVersionObjectReference{
APIVersion: "v1",
Kind: "Secret",
Name: "test",
},
}}
Expect(Predicate(oldShoot, shoot)).To(BeTrue())
})
})
})