|
@@ -39,6 +39,7 @@ import (
|
|
|
|
|
|
|
|
const (
|
|
const (
|
|
|
myServiceAcc = "my-service-account"
|
|
myServiceAcc = "my-service-account"
|
|
|
|
|
+ myRole = "my-sa-role"
|
|
|
otherNs = "other-ns"
|
|
otherNs = "other-ns"
|
|
|
)
|
|
)
|
|
|
|
|
|
|
@@ -351,14 +352,14 @@ func TestNewSession(t *testing.T) {
|
|
|
Name: myServiceAcc,
|
|
Name: myServiceAcc,
|
|
|
Namespace: otherNs,
|
|
Namespace: otherNs,
|
|
|
Annotations: map[string]string{
|
|
Annotations: map[string]string{
|
|
|
- roleARNAnnotation: "my-sa-role",
|
|
|
|
|
|
|
+ roleARNAnnotation: myRole,
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
jwtProvider: func(name, namespace, roleArn, region string) (credentials.Provider, error) {
|
|
jwtProvider: func(name, namespace, roleArn, region string) (credentials.Provider, error) {
|
|
|
assert.Equal(t, myServiceAcc, name)
|
|
assert.Equal(t, myServiceAcc, name)
|
|
|
assert.Equal(t, otherNs, namespace)
|
|
assert.Equal(t, otherNs, namespace)
|
|
|
- assert.Equal(t, "my-sa-role", roleArn)
|
|
|
|
|
|
|
+ assert.Equal(t, myRole, roleArn)
|
|
|
return fakesess.CredentialsProvider{
|
|
return fakesess.CredentialsProvider{
|
|
|
RetrieveFunc: func() (credentials.Value, error) {
|
|
RetrieveFunc: func() (credentials.Value, error) {
|
|
|
return credentials.Value{
|
|
return credentials.Value{
|
|
@@ -395,6 +396,46 @@ func TestNewSession(t *testing.T) {
|
|
|
expectedKeyID: "3333",
|
|
expectedKeyID: "3333",
|
|
|
expectedSecretKey: "4444",
|
|
expectedSecretKey: "4444",
|
|
|
},
|
|
},
|
|
|
|
|
+ {
|
|
|
|
|
+ name: "should not accept ServiceAccountRefs with nil Namespace",
|
|
|
|
|
+ sa: &v1.ServiceAccount{
|
|
|
|
|
+ ObjectMeta: metav1.ObjectMeta{
|
|
|
|
|
+ Name: myServiceAcc,
|
|
|
|
|
+ Namespace: otherNs,
|
|
|
|
|
+ Annotations: map[string]string{
|
|
|
|
|
+ roleARNAnnotation: myRole,
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ jwtProvider: func(name, namespace, roleArn, region string) (credentials.Provider, error) {
|
|
|
|
|
+ return fakesess.CredentialsProvider{
|
|
|
|
|
+ RetrieveFunc: func() (credentials.Value, error) {
|
|
|
|
|
+ return credentials.Value{}, nil
|
|
|
|
|
+ },
|
|
|
|
|
+ IsExpiredFunc: func() bool { return false },
|
|
|
|
|
+ }, nil
|
|
|
|
|
+ },
|
|
|
|
|
+ store: &esv1alpha1.ClusterSecretStore{
|
|
|
|
|
+ TypeMeta: metav1.TypeMeta{
|
|
|
|
|
+ APIVersion: esv1alpha1.ClusterSecretStoreKindAPIVersion,
|
|
|
|
|
+ Kind: esv1alpha1.ClusterSecretStoreKind,
|
|
|
|
|
+ },
|
|
|
|
|
+ Spec: esv1alpha1.SecretStoreSpec{
|
|
|
|
|
+ Provider: &esv1alpha1.SecretStoreProvider{
|
|
|
|
|
+ AWS: &esv1alpha1.AWSProvider{
|
|
|
|
|
+ Auth: esv1alpha1.AWSAuth{
|
|
|
|
|
+ JWTAuth: &esv1alpha1.AWSJWTAuth{
|
|
|
|
|
+ ServiceAccountRef: &esmeta.ServiceAccountSelector{
|
|
|
|
|
+ Name: myServiceAcc,
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ expectErr: "serviceAccountRef has no Namespace field (mandatory for ClusterSecretStore specs)",
|
|
|
|
|
+ },
|
|
|
}
|
|
}
|
|
|
for i := range rows {
|
|
for i := range rows {
|
|
|
row := rows[i]
|
|
row := rows[i]
|