Skip to content

Commit

Permalink
operator: add console envtest for RedpandaCloud provider
Browse files Browse the repository at this point in the history
Test that RedpandaCloud fields are present in the ConfigMap

(cherry picked from commit 4950fcc)
  • Loading branch information
pvsune authored and joejulian committed Apr 12, 2023
1 parent 66548d1 commit ff86e39
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions src/go/k8s/controllers/redpanda/console_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,4 +342,49 @@ var _ = Describe("Console controller", func() {
}, timeout, interval).Should(BeTrue())
})
})

Context("When enabling multiple Login providers", func() {
ctx := context.Background()
It("Should prioritize RedpandaCloud", func() {
var (
rpCloudDomain = "test.auth.vectorized.io"
rpCloudAudience = "dev.vectorized.io"
)

By("Updating Console RedpandaCloud Login fields")
console := &redpandav1alpha1.Console{}
Expect(k8sClient.Get(ctx, types.NamespacedName{Namespace: ConsoleNamespace, Name: ConsoleName}, console)).Should(Succeed())
console.Spec.Login.RedpandaCloud = &redpandav1alpha1.EnterpriseLoginRedpandaCloud{
Enabled: true,
Domain: rpCloudDomain,
Audience: rpCloudAudience,
}
Expect(k8sClient.Update(ctx, console)).Should(Succeed())

By("Having only RedpandaCloud provider in ConfigMap")
createdConfigMaps := &corev1.ConfigMapList{}
Eventually(func() bool {
if err := k8sClient.List(ctx, createdConfigMaps, client.MatchingLabels(labels.ForConsole(console)), client.InNamespace(ConsoleNamespace)); err != nil {
return false
}
if len(createdConfigMaps.Items) != 1 {
return false
}
for _, cm := range createdConfigMaps.Items {
cc := &consolepkg.ConsoleConfig{}
if err := yaml.Unmarshal([]byte(cm.Data["config.yaml"]), cc); err != nil {
return false
}
if cc.Login.Google != nil {
return false
}
rpCloudConfig := cc.Login.RedpandaCloud
if !rpCloudConfig.Enabled || rpCloudConfig.Domain != rpCloudDomain || rpCloudConfig.Audience != rpCloudAudience {
return false
}
}
return true
}, timeout, interval).Should(BeTrue())
})
})
})

0 comments on commit ff86e39

Please sign in to comment.