mirror of
https://github.com/zalando/postgres-operator.git
synced 2026-10-19 10:05:25 +02:00
day after tomorrow
This commit is contained in:
@@ -319,7 +319,7 @@ func TestUpdateSecret(t *testing.T) {
|
|||||||
// initialize rotation with current time
|
// initialize rotation with current time
|
||||||
cluster.syncSecrets()
|
cluster.syncSecrets()
|
||||||
|
|
||||||
tomorrow := time.Now().AddDate(0, 0, 2)
|
dayAfterTomorrow := time.Now().AddDate(0, 0, 2)
|
||||||
|
|
||||||
for username := range cluster.Spec.Users {
|
for username := range cluster.Spec.Users {
|
||||||
pgUser := cluster.pgUsers[username]
|
pgUser := cluster.pgUsers[username]
|
||||||
@@ -330,7 +330,7 @@ func TestUpdateSecret(t *testing.T) {
|
|||||||
secretPassword := string(secret.Data["password"])
|
secretPassword := string(secret.Data["password"])
|
||||||
|
|
||||||
// now update the secret setting a next rotation date (tomorrow + interval)
|
// now update the secret setting a next rotation date (tomorrow + interval)
|
||||||
cluster.updateSecret(username, secret, &rotationUsers, &retentionUsers, tomorrow)
|
cluster.updateSecret(username, secret, &rotationUsers, &retentionUsers, dayAfterTomorrow)
|
||||||
updatedSecret, err := cluster.KubeClient.Secrets(namespace).Get(context.TODO(), secretTemplate.Format("username", username, "cluster", clusterName), metav1.GetOptions{})
|
updatedSecret, err := cluster.KubeClient.Secrets(namespace).Get(context.TODO(), secretTemplate.Format("username", username, "cluster", clusterName), metav1.GetOptions{})
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
@@ -342,7 +342,7 @@ func TestUpdateSecret(t *testing.T) {
|
|||||||
|
|
||||||
// check that next rotation date is tomorrow + interval, not date in secret + interval
|
// check that next rotation date is tomorrow + interval, not date in secret + interval
|
||||||
nextRotation := string(updatedSecret.Data["nextRotation"])
|
nextRotation := string(updatedSecret.Data["nextRotation"])
|
||||||
_, nextRotationDate := cluster.getNextRotationDate(tomorrow)
|
_, nextRotationDate := cluster.getNextRotationDate(dayAfterTomorrow)
|
||||||
if nextRotation != nextRotationDate {
|
if nextRotation != nextRotationDate {
|
||||||
t.Errorf("%s: updated secret of %s does not contain correct rotation date: expected %s, got %s", testName, username, nextRotationDate, nextRotation)
|
t.Errorf("%s: updated secret of %s does not contain correct rotation date: expected %s, got %s", testName, username, nextRotationDate, nextRotation)
|
||||||
}
|
}
|
||||||
@@ -354,7 +354,7 @@ func TestUpdateSecret(t *testing.T) {
|
|||||||
t.Errorf("%s: username differs in updated secret: expected %s, got %s", testName, username, secretUsername)
|
t.Errorf("%s: username differs in updated secret: expected %s, got %s", testName, username, secretUsername)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
rotatedUsername := username + tomorrow.Format("060102")
|
rotatedUsername := username + dayAfterTomorrow.Format("060102")
|
||||||
if secretUsername != rotatedUsername {
|
if secretUsername != rotatedUsername {
|
||||||
t.Errorf("%s: updated secret does not contain correct username: expected %s, got %s", testName, rotatedUsername, secretUsername)
|
t.Errorf("%s: updated secret does not contain correct username: expected %s, got %s", testName, rotatedUsername, secretUsername)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user