-
Notifications
You must be signed in to change notification settings - Fork 209
Expand file tree
/
Copy pathencryption_rotation_test.go
More file actions
46 lines (42 loc) · 2.12 KB
/
Copy pathencryption_rotation_test.go
File metadata and controls
46 lines (42 loc) · 2.12 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
package e2e_encryption_rotation
import (
"context"
"flag"
"fmt"
"testing"
configv1 "github.com/openshift/api/config/v1"
"github.com/openshift/cluster-kube-apiserver-operator/pkg/operator/operatorclient"
operatorencryption "github.com/openshift/cluster-kube-apiserver-operator/test/library/encryption"
library "github.com/openshift/library-go/test/library/encryption"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
var provider = flag.String("provider", "aescbc", "encryption provider used by the tests")
// TestEncryptionRotation first encrypts data then it forces a key
// rotation by setting the "encyrption.Reason" in the operator's configuration
// file
func TestEncryptionRotation(t *testing.T) {
library.TestEncryptionRotation(context.TODO(), t, library.RotationScenario{
BasicScenario: library.BasicScenario{
Namespace: operatorclient.GlobalMachineSpecifiedConfigNamespace,
LabelSelector: "encryption.apiserver.operator.openshift.io/component" + "=" + operatorclient.TargetNamespace,
EncryptionConfigSecretName: fmt.Sprintf("encryption-config-%s", operatorclient.TargetNamespace),
EncryptionConfigSecretNamespace: operatorclient.GlobalMachineSpecifiedConfigNamespace,
OperatorNamespace: operatorclient.OperatorNamespace,
TargetGRs: operatorencryption.DefaultTargetGRs,
AssertFunc: operatorencryption.AssertSecretsAndConfigMaps,
},
CreateResourceFunc: operatorencryption.CreateAndStoreSecretOfLife,
GetRawResourceFunc: operatorencryption.GetRawSecretOfLife,
UnsupportedConfigFunc: func(raw []byte) error {
operatorClient := operatorencryption.GetOperator(t)
apiServerOperator, err := operatorClient.Get(context.TODO(), "cluster", metav1.GetOptions{})
if err != nil {
return err
}
apiServerOperator.Spec.UnsupportedConfigOverrides.Raw = raw
_, err = operatorClient.Update(context.TODO(), apiServerOperator, metav1.UpdateOptions{})
return err
},
EncryptionProvider: library.EncryptionProvider{APIServerEncryption: configv1.APIServerEncryption{Type: configv1.EncryptionType(*provider)}},
})
}