Skip to content

Commit

Permalink
add reference to docs and include policy update test
Browse files Browse the repository at this point in the history
  • Loading branch information
drebes committed Jul 28, 2020
1 parent c1886b5 commit 5ff1022
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 4 deletions.
29 changes: 25 additions & 4 deletions products/compute/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7857,6 +7857,11 @@ objects:
update_verb: :PATCH
description: |
Organization security policies are used to control incoming/outgoing traffic.
references: !ruby/object:Api::Resource::ReferenceLinks
guides:
'Creating a firewall policy':
'https://cloud.google.com/vpc/docs/using-firewall-policies#create-policy'
api: 'https://cloud.google.com/compute/docs/reference/rest/beta/organizationSecurityPolicies'
parameters:
- !ruby/object:Api::Type::String
name: parent
Expand All @@ -7876,6 +7881,12 @@ objects:
name: description
description: |
A textual description for the organization security policy.
- !ruby/object:Api::Type::Fingerprint
name: 'fingerprint'
description: |
Fingerprint of this resource. This field is used internally during
updates of this resource.
output: true
- !ruby/object:Api::Type::String
name: id
description: |
Expand All @@ -7902,6 +7913,11 @@ objects:
description: |
An association for the OrganizationSecurityPolicy.
input: true
references: !ruby/object:Api::Resource::ReferenceLinks
guides:
'Associating a policy with the organization or folder':
'https://cloud.google.com/vpc/docs/using-firewall-policies#associate'
api: 'https://cloud.google.com/compute/docs/reference/rest/beta/organizationSecurityPolicies/addAssociation'
parameters:
- !ruby/object:Api::Type::String
name: 'policyId'
Expand Down Expand Up @@ -7937,6 +7953,11 @@ objects:
delete_url: 'locations/global/securityPolicies/{{policy_id}}/removeRule?priority={{priority}}'
description: |
A rule for the OrganizationSecurityPolicy.
references: !ruby/object:Api::Resource::ReferenceLinks
guides:
'Creating firewall rules':
'https://cloud.google.com/vpc/docs/using-firewall-policies#create-rules'
api: 'https://cloud.google.com/compute/docs/reference/rest/beta/organizationSecurityPolicies/addRule'
parameters:
- !ruby/object:Api::Type::String
name: policyId
Expand All @@ -7953,7 +7974,7 @@ objects:
- !ruby/object:Api::Type::Integer
name: 'priority'
description: |
An integer indicating the priority of a rule in the list. The priority must be a positive value
An integer indicating the priority of a rule in the list. The priority must be a value
between 0 and 2147483647. Rules are evaluated from highest to lowest priority where 0 is the
highest priority and 2147483647 is the lowest prority.
required: true
Expand All @@ -7972,7 +7993,7 @@ objects:
- !ruby/object:Api::Type::Enum
name: 'versionedExpr'
description: |
Preconfigured versioned expression. For organization security policies rules,
Preconfigured versioned expression. For organization security policy rules,
the only supported type is "FIREWALL".
values:
- :FIREWALL
Expand Down Expand Up @@ -8022,7 +8043,7 @@ objects:
- !ruby/object:Api::Type::String
name: 'action'
description: |
The Action to preform when the client connection triggers the rule. Can currently be either
The Action to perform when the client connection triggers the rule. Can currently be either
"allow", "deny" or "goto_next".
required: true
- !ruby/object:Api::Type::Boolean
Expand Down Expand Up @@ -12293,7 +12314,7 @@ objects:
- !ruby/object:Api::Type::Integer
name: 'priority'
description: |
An integer indicating the priority of a rule in the list. The priority must be a positive value
An integer indicating the priority of a rule in the list. The priority must be a value
between 0 and 2147483647. Rules are evaluated from highest to lowest priority where 0 is the
highest priority and 2147483647 is the lowest prority.
- !ruby/object:Api::Type::String
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<% autogen_exception -%>
package google
<% unless version == 'ga' -%>

import (
"fmt"
"strings"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
)

func TestAccComputeOrganizationSecurityPolicy_organizationSecurityPolicyUpdateExample(t *testing.T) {
t.Parallel()

context := map[string]interface{}{
"org_id": getTestOrgFromEnv(t),
"random_suffix": randString(t, 10),
}

vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckComputeOrganizationSecurityPolicyDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccComputeOrganizationSecurityPolicy_organizationSecurityPolicyUpdatePreExample(context),
},
{
ResourceName: "google_compute_organization_security_policy.policy",
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccComputeOrganizationSecurityPolicy_organizationSecurityPolicyUpdatePostExample(context),
},
{
ResourceName: "google_compute_organization_security_policy.policy",
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func testAccComputeOrganizationSecurityPolicy_organizationSecurityPolicyUpdatePreExample(context map[string]interface{}) string {
return Nprintf(`
resource "google_compute_organization_security_policy" "policy" {
display_name = "tf-test%{random_suffix}"
parent = "organizations/%{org_id}"
}
`, context)
}

func testAccComputeOrganizationSecurityPolicy_organizationSecurityPolicyUpdatePostExample(context map[string]interface{}) string {
return Nprintf(`
resource "google_compute_organization_security_policy" "policy" {
display_name = "tf-test%{random_suffix}"
parent = "organizations/%{org_id}"
description = "Updated description."
}
`, context)
}
<% end -%>

0 comments on commit 5ff1022

Please sign in to comment.