Update securityPolicy test cases
Add test case for regional backend service with no specified security policy
@@ -78,7 +78,7 @@ func TestEnsureSecurityPolicy(t *testing.T) {
expectSetCall: true,
},
{
- desc: "remove-policy",
+ desc: "unset-policy-empty-policy-string",
currentBackendService: &composite.BackendService{
Scope: meta.Global,
SecurityPolicy: "https://www.googleapis.com/compute/projects/test-project/global/securityPolicies/policy-1",
@@ -92,6 +92,15 @@ func TestEnsureSecurityPolicy(t *testing.T) {
},
expectSetCall: true,
},
+ {
+ desc: "unset-policy-no-specified-policy",
+ currentBackendService: &composite.BackendService{
+ Scope: meta.Global,
+ SecurityPolicy: "https://www.googleapis.com/compute/projects/test-project/global/securityPolicies/policy-1",
+ },
+ desiredConfig: &backendconfigv1.BackendConfig{},
+ expectSetCall: true,
+ },
{
desc: "same-policy",
currentBackendService: &composite.BackendService{
@@ -111,15 +120,6 @@ func TestEnsureSecurityPolicy(t *testing.T) {
currentBackendService: &composite.BackendService{Scope: meta.Global},
desiredConfig: &backendconfigv1.BackendConfig{},
},
- {
- desc: "no-specified-policy",
- currentBackendService: &composite.BackendService{
- Scope: meta.Global,
- SecurityPolicy: "https://www.googleapis.com/compute/projects/test-project/global/securityPolicies/policy-1",
- },
- desiredConfig: &backendconfigv1.BackendConfig{},
- expectSetCall: false,
- },
{
desc: "regional backend service",
currentBackendService: &composite.BackendService{
@@ -135,6 +135,13 @@ func TestEnsureSecurityPolicy(t *testing.T) {
expectSetCall: false,
expectError: true,
},
+ {
+ desc: "regional backend service with no specified security policy",
+ currentBackendService: &composite.BackendService{Scope: meta.Regional},
+ desiredConfig: &backendconfigv1.BackendConfig{},
+ expectSetCall: false,
+ expectError: false,
+ },
}
for i, tc := range testCases {
