Skip to content

Commit

Permalink
Add test for invalid AuthEncryptionKey length
Browse files Browse the repository at this point in the history
  • Loading branch information
bshephar committed Oct 3, 2024
1 parent df97dc5 commit e48838a
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions tests/functional/heat_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -644,4 +644,59 @@ var _ = Describe("Heat controller", func() {
return GetEnvVarValue(deployment.Spec.Template.Spec.Containers[0].Env, "CONFIG_HASH", "")
})*/

When("HeatAuthEncryptionKey is too short", func() {

BeforeEach(func() {
DeferCleanup(th.DeleteInstance, CreateHeat(heatName, GetDefaultHeatSpec()))
DeferCleanup(
k8sClient.Delete, ctx, CreateHeatSecret(namespace, SecretName))
DeferCleanup(infra.DeleteMemcached, infra.CreateMemcached(namespace, "memcached", memcachedSpec))
infra.SimulateMemcachedReady(types.NamespacedName{
Name: "memcached",
Namespace: namespace,
})
DeferCleanup(
k8sClient.Delete, ctx, CreateHeatMessageBusSecret(namespace, HeatMessageBusSecretName))
infra.SimulateTransportURLReady(heatTransportURLName)
keystoneAPI := keystone.CreateKeystoneAPI(namespace)
DeferCleanup(keystone.DeleteKeystoneAPI, keystoneAPI)
DeferCleanup(
mariadb.DeleteDBService,
mariadb.CreateDBService(
namespace,
GetHeat(heatName).Spec.DatabaseInstance,
corev1.ServiceSpec{
Ports: []corev1.ServicePort{{Port: 3306}},
},
),
)
mariadb.SimulateMariaDBAccountCompleted(types.NamespacedName{Namespace: namespace, Name: GetHeat(heatName).Spec.DatabaseAccount})
mariadb.SimulateMariaDBDatabaseCompleted(types.NamespacedName{Namespace: namespace, Name: heat.DatabaseCRName})
dbSyncJobName := types.NamespacedName{
Name: "heat-db-sync",
Namespace: namespace,
}
th.SimulateJobSuccess(dbSyncJobName)

})

It("Should complain about the Key length", func() {
Eventually(func(g Gomega) {
heat := GetHeat(heatName)
heat.Spec.PasswordSelectors.AuthEncryptionKey = "TooShortAuthEncKey"
g.Expect(th.K8sClient.Update(ctx, heat)).Should(Succeed())
}, timeout, interval).Should(Succeed())

th.ExpectCondition(
heatName,
ConditionGetterFunc(HeatConditionGetter),
condition.ServiceConfigReadyCondition,
corev1.ConditionFalse,
)

conditions := HeatConditionGetter(heatName)
message := &conditions.Get(condition.ServiceConfigReadyCondition).Message
Expect(*message).Should(ContainSubstring("AuthEncryptionKey must be at least 32 characters"))
})
})
})

0 comments on commit e48838a

Please sign in to comment.