|
1 | 1 | package integration |
2 | 2 |
|
3 | 3 | import ( |
4 | | - "fmt" |
5 | | - "strings" |
6 | 4 | "testing" |
7 | 5 |
|
8 | 6 | "github.com/google/uuid" |
9 | 7 | "github.com/samber/lo" |
10 | 8 | "github.com/stretchr/testify/assert" |
11 | 9 | "github.com/stretchr/testify/require" |
12 | 10 | corev1 "k8s.io/api/core/v1" |
13 | | - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
14 | 11 | "k8s.io/apimachinery/pkg/types" |
15 | 12 | "sigs.k8s.io/controller-runtime/pkg/client" |
16 | 13 |
|
| 14 | + "github.com/kong/gateway-operator/pkg/consts" |
17 | 15 | testutils "github.com/kong/gateway-operator/pkg/utils/test" |
18 | 16 | "github.com/kong/gateway-operator/test" |
19 | 17 | "github.com/kong/gateway-operator/test/helpers" |
@@ -67,12 +65,14 @@ func TestKonnectExtension(t *testing.T) { |
67 | 65 | ) |
68 | 66 | // Create a KonnectExtension attaching to the CP by its ID. |
69 | 67 | t.Logf("Creating a KonnectExtension and waiting for Konnect control plane ref resolved") |
70 | | - ke := deploy.KonnectExtensionWithAPIAuthRefAndCPID( |
| 68 | + ke := deploy.KonnectExtension( |
71 | 69 | t, ctx, clientNamespaced, |
72 | | - konnectv1alpha1.KonnectAPIAuthConfigurationRef{ |
73 | | - Name: authCfg.Name, |
74 | | - }, |
75 | | - cp.GetKonnectID(), |
| 70 | + deploy.WithKonnectConfiguration[*konnectv1alpha1.KonnectExtension](konnectv1alpha1.KonnectConfiguration{ |
| 71 | + APIAuthConfigurationRef: konnectv1alpha1.KonnectAPIAuthConfigurationRef{ |
| 72 | + Name: authCfg.Name, |
| 73 | + }, |
| 74 | + }), |
| 75 | + deploy.WithKonnectIDControlPlaneRef(cp), |
76 | 76 | setKonnectExtensionDPCertSecretRef(t, s), |
77 | 77 | ) |
78 | 78 |
|
@@ -123,25 +123,10 @@ func checkKonnectExtensionConditions(t *assert.CollectT, ke *konnectv1alpha1.Kon |
123 | 123 | err := GetClients().MgrClient.Get(GetCtx(), types.NamespacedName{Name: ke.Name, Namespace: ke.Namespace}, ke) |
124 | 124 | require.NoError(t, err) |
125 | 125 |
|
126 | | - checkConditionTypes := []string{ |
| 126 | + checkConditionTypes := []consts.ConditionType{ |
127 | 127 | konnectv1alpha1.ControlPlaneRefValidConditionType, |
128 | 128 | konnectv1alpha1.DataPlaneCertificateProvisionedConditionType, |
129 | 129 | konnectv1alpha1.KonnectExtensionReadyConditionType, |
130 | 130 | } |
131 | | - failedConditionTypes := make([]string, 0, len(checkConditionTypes)) |
132 | | - conditionMap := lo.SliceToMap(ke.Status.Conditions, func(condition metav1.Condition) (string, metav1.ConditionStatus) { |
133 | | - return condition.Type, condition.Status |
134 | | - }) |
135 | | - |
136 | | - for _, conditionType := range checkConditionTypes { |
137 | | - status, ok := conditionMap[conditionType] |
138 | | - if !ok || status != metav1.ConditionTrue { |
139 | | - failedConditionTypes = append(failedConditionTypes, conditionType) |
140 | | - } |
141 | | - } |
142 | | - |
143 | | - if len(failedConditionTypes) > 0 { |
144 | | - return false, fmt.Sprintf("condition(s) %s not set to True", strings.Join(failedConditionTypes, ", ")) |
145 | | - } |
146 | | - return true, "" |
| 131 | + return helpers.CheckAllConditionsTrue(ke, checkConditionTypes) |
147 | 132 | } |
0 commit comments