VSChina / magic-modules

Magic Modules: Automagically generate Google Cloud Platform support for OSS
Apache License 2.0
1 stars 4 forks source link

Enable property checking customization in test file #40

Closed houkms closed 5 years ago

houkms commented 5 years ago

This PR provides supports for customization of property checking in test file. We provide the features of

The customization rules in the basic.yaml or complete.yaml are

Here is an example. And this results in checking only all the representations with prefix custom_rules.1 in test file.

--- !ruby/object:Provider::Azure::Example
resource: azurerm_web_application_firewall_policy
prerequisites:
  - !ruby/object:Provider::Azure::ExampleReference
    product: resourcegroup
    example: basic
properties:
  name: "<%= get_resource_name('ApplicationGatewayWebApplicationFirewallPolicies', 'wafpolicy') -%>"
  resource_group_name: ${azurerm_resource_group.<%= resource_id_hint -%>.name}
  location: ${azurerm_resource_group.<%= resource_id_hint -%>.location}
  custom_rules:
    - name: Rule1
      priority: 1
      rule_type: MatchRule
      match_conditions:
        - match_variables:
            - variable_name: RemoteAddr
          operator: IPMatch
          negation_conditon: false
          match_values: [192.168.1.0/24, 10.0.0.0/24]
      action: Block
    - name: Rule2
      priority: 2
      rule_type: MatchRule
      match_conditions:
        - match_variables:
            - variable_name: RemoteAddr
          operator: IPMatch
          negation_conditon: false
          match_values: [192.168.1.0/24]
        - match_variables:
            - variable_name: RequestHeaders
              selector: UserAgent
          operator: Contains
          negation_conditon: false
          match_values: [Windows]
      action: Block
property_check_excludes:
  - custom_rules.#
  - custom_rules.0.*
houkms commented 5 years ago

This PR solves the issue #25.