Skip to content

Commit

Permalink
Add handwritten examples from handwritten resources (#3129) (#352)
Browse files Browse the repository at this point in the history
Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored and Stuart Paterson committed Apr 6, 2020
1 parent d344555 commit 659f8f3
Show file tree
Hide file tree
Showing 46 changed files with 982 additions and 0 deletions.
24 changes: 24 additions & 0 deletions docs/resources/google_compute_firewalls.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,30 @@ describe google_compute_firewalls(project: 'chef-gcp-inspec') do
end
```

### Test that there are no more than a specified number of firewalls available for the project

describe google_compute_firewalls(project: 'chef-inspec-gcp') do
its('count') { should be <= 100}
end

### Test that an expected firewall is available for the project

describe google_compute_firewalls(project: 'chef-inspec-gcp') do
its('firewall_names') { should include "my-app-firewall-rule" }
end

### Test that a particular named rule does not exist

describe google_compute_firewalls(project: 'chef-inspec-gcp') do
its('firewall_names') { should_not include "default-allow-ssh" }
end

### Test there are no firewalls for the "INGRESS" direction

describe google_compute_firewalls(project: 'chef-inspec-gcp').where(firewall_direction: 'INGRESS') do
it { should_not exist }
end

## Properties
Properties that can be accessed from the `google_compute_firewalls` resource:

Expand Down
36 changes: 36 additions & 0 deletions docs/resources/google_compute_forwarding_rule.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,42 @@ describe google_compute_forwarding_rule(project: 'chef-gcp-inspec', region: 'eur
end
```

### Test that a GCP compute forwarding_rule exists

describe google_compute_forwarding_rule(project: 'chef-inspec-gcp', region: 'europe-west2', name: 'gcp-inspec-forwarding_rule') do
it { should exist }
end

### Test when a GCP compute forwarding_rule was created

describe google_compute_forwarding_rule(project: 'chef-inspec-gcp', region: 'europe-west2', name: 'gcp-inspec-forwarding_rule') do
its('creation_timestamp_date') { should be > Time.now - 365*60*60*24*10 }
end

### Test for an expected forwarding_rule identifier

describe google_compute_forwarding_rule(project: 'chef-inspec-gcp', region: 'europe-west2', name: 'gcp-inspec-forwarding_rule') do
its('id') { should eq 12345567789 }
end

### Test that a forwarding_rule load_balancing_scheme is as expected

describe google_compute_forwarding_rule(project: 'chef-inspec-gcp', region: 'europe-west2', name: 'gcp-inspec-forwarding_rule') do
its('load_balancing_scheme') { should eq "INTERNAL" }
end

### Test that a forwarding_rule IP address is as expected

describe google_compute_forwarding_rule(project: 'chef-inspec-gcp', region: 'europe-west2', name: 'gcp-inspec-forwarding_rule') do
its('ip_address') { should eq "10.0.0.1" }
end

### Test that a forwarding_rule is associated with the expected network

describe google_compute_forwarding_rule(project: 'chef-inspec-gcp', region: 'europe-west2', name: 'gcp-inspec-forwarding_rule') do
its('network') { should match "gcp_network_name" }
end

## Properties
Properties that can be accessed from the `google_compute_forwarding_rule` resource:

Expand Down
25 changes: 25 additions & 0 deletions docs/resources/google_compute_forwarding_rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,31 @@ describe google_compute_forwarding_rules(project: 'chef-gcp-inspec', region: 'eu
end
```

### Test that there are no more than a specified number of forwarding_rules available for the project and region

describe google_compute_forwarding_rules(project: 'chef-inspec-gcp', region: 'europe-west2') do
its('count') { should be <= 100}
end

### Test that an expected forwarding_rule identifier is present in the project and region

describe google_compute_forwarding_rules(project: 'chef-inspec-gcp', region: 'europe-west2') do
its('forwarding_rule_ids') { should include 12345678975432 }
end


### Test that an expected forwarding_rule name is available for the project and region

describe google_compute_forwarding_rules(project: 'chef-inspec-gcp', region: 'europe-west2') do
its('forwarding_rule_names') { should include "forwarding_rule-name" }
end

### Test that an expected forwarding_rule network name is not present for the project and region

describe google_compute_forwarding_rules(project: 'chef-inspec-gcp', region: 'europe-west2') do
its('forwarding_rule_networks') { should not include "network-name" }
end

## Properties
Properties that can be accessed from the `google_compute_forwarding_rules` resource:

Expand Down
12 changes: 12 additions & 0 deletions docs/resources/google_compute_image.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ describe google_compute_image(project: 'chef-gcp-inspec', name: 'notfound') do
end
```

### Test that a GCP compute image is in a particular status e.g. "READY" means available for use

describe google_compute_image(project: 'chef-inspec-gcp', location: 'europe-west2', name: 'compute-address') do
its('status') { should eq "READY" }
end

### Test that a GCP compute image has the expected family

describe google_compute_image(project: 'chef-inspec-gcp', name: 'ubuntu') do
its('family') { should match "ubuntu" }
end

## Properties
Properties that can be accessed from the `google_compute_image` resource:

Expand Down
14 changes: 14 additions & 0 deletions docs/resources/google_compute_instance_group.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,20 @@ describe google_compute_instance_group(project: 'chef-gcp-inspec', zone: 'zone',
end
```

### Test that a GCP compute instance group has the expected size

describe google_compute_instance_group(project: 'chef-inspec-gcp', zone: 'europe-west2-a', name: 'gcp-inspec-test') do
its('size') { should eq 2 }
end

### Test that a GCP compute instance group has a port with supplied name and value

describe google_compute_instance_group(project: 'chef-inspec-gcp', zone: 'europe-west2-a', name: 'gcp-inspec-test') do
its('port_name') { should eq "http" }
its('port_value') { should eq 80 }
end


## Properties
Properties that can be accessed from the `google_compute_instance_group` resource:

Expand Down
21 changes: 21 additions & 0 deletions docs/resources/google_compute_instance_groups.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,27 @@ describe google_compute_instance_groups(project: 'chef-gcp-inspec', zone: 'zone'
end
```

### Test that there are no more than a specified number of instance groups available for the project

describe google_compute_instance_groups(project: 'chef-inspec-gcp') do
its('count') { should be <= 100}
end

### Test that an expected instance_group is available for the project

describe google_compute_instance_groups(project: 'chef-inspec-gcp', zone: 'europe-west2-a') do
its('instance_group_names') { should include "my-instance-group-name" }
end

### Test that a subset of all instance_groups matching "mig*" have size greater than zero

google_compute_instance_groups(project: 'chef-inspec-gcp', zone: 'europe-west2-a').where(instance_group_name: /^mig/).instance_group_names.each do |instance_group_name|
describe google_compute_instance_group(project: 'chef-inspec-gcp', zone: 'europe-west2-a', name: instance_group_name) do
it { should exist }
its('size') { should be > 0 }
end
end

## Properties
Properties that can be accessed from the `google_compute_instance_groups` resource:

Expand Down
18 changes: 18 additions & 0 deletions docs/resources/google_compute_instances.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,24 @@ describe google_compute_instances(project: 'chef-gcp-inspec', zone: 'zone') do
end
```

### Test that there are no more than a specified number of instances in the project and zone

describe google_compute_instances(project: 'chef-inspec-gcp', zone: 'europe-west2-a') do
its('count') { should be <= 100}
end

### Test the exact number of instances in the project and zone

describe google_compute_instances(project: 'chef-inspec-gcp', zone: 'europe-west2-a') do
its('instance_ids.count') { should cmp 9 }
end

### Test that an instance with a particular name exists in the project and zone

describe google_compute_instances(project: 'chef-inspec-gcp', zone: 'europe-west2-a') do
its('instance_names') { should include "my-favourite-instance" }
end

## Properties
Properties that can be accessed from the `google_compute_instances` resource:

Expand Down
19 changes: 19 additions & 0 deletions docs/resources/google_compute_networks.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,25 @@ describe google_compute_networks(project: 'chef-gcp-inspec') do
end
```

### Test that there are no more than a specified number of networks available for the project

describe google_compute_networks(project: 'chef-inspec-gcp') do
its('count') { should be <= 100}
end

### Test that an expected network identifier is present in the project

describe google_compute_networks(project: 'chef-inspec-gcp') do
its('network_ids') { should include 12345678975432 }
end

### Test that an expected network name is available for the project

describe google_compute_networks(project: 'chef-inspec-gcp') do
its('network_names') { should include "network-name" }
end


## Properties
Properties that can be accessed from the `google_compute_networks` resource:

Expand Down
12 changes: 12 additions & 0 deletions docs/resources/google_compute_project_info.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@ describe google_compute_project_info(project: 'chef-gcp-inspec') do
end
```

### Test that GCP compute project information exists

describe google_compute_project_info(project: 'chef-inspec-gcp') do
it { should exist }
end

### Test that GCP compute project default service account is as expected

describe google_compute_project_info(project: 'chef-inspec-gcp') do
its('default_service_account') { should eq '[email protected]' }
end

## Properties
Properties that can be accessed from the `google_compute_project_info` resource:

Expand Down
21 changes: 21 additions & 0 deletions docs/resources/google_compute_region_instance_group_managers.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,27 @@ describe google_compute_region_instance_group_managers(project: 'chef-gcp-inspec
end
```

### Test that there are no more than a specified number of instance groups available for the project

describe google_compute_region_instance_group_managers(project: 'chef-inspec-gcp', region: 'europe-west2') do
its('count') { should be <= 100}
end

### Test that an expected instance_group is available for the project

describe google_compute_region_instance_group_managers(project: 'chef-inspec-gcp', region: 'europe-west2') do
its('instance_group_names') { should include "my-instance-group-name" }
end

### Test that a subset of all instance_groups matching "mig*" have size greater than zero

google_compute_region_instance_group_managers(project: 'chef-inspec-gcp', region: 'europe-west2').where(instance_group_name: /^mig/).instance_group_names.each do |instance_group_name|
describe google_compute_instance_group(project: 'chef-inspec-gcp', region: 'europe-west2', name: instance_group_name) do
it { should exist }
its('target_size') { should be > 0 }
end
end

## Properties
Properties that can be accessed from the `google_compute_region_instance_group_managers` resource:

Expand Down
25 changes: 25 additions & 0 deletions docs/resources/google_compute_subnetworks.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,31 @@ describe google_compute_subnetworks(project: 'chef-gcp-inspec', region: 'europe-
end
```

### Test that there are no more than a specified number of subnetworks available for the project and region

describe google_compute_subnetworks(project: 'chef-inspec-gcp', region: 'europe-west2') do
its('count') { should be <= 100}
end

### Test that an expected subnetwork identifier is present in the project and region

describe google_compute_subnetworks(project: 'chef-inspec-gcp', region: 'europe-west2') do
its('subnetwork_ids') { should include 12345678975432 }
end


### Test that an expected subnetwork name is available for the project and region

describe google_compute_subnetworks(project: 'chef-inspec-gcp', region: 'europe-west2') do
its('subnetwork_names') { should include "subnetwork-name" }
end

### Test that an expected subnetwork network name is not present for the project and region

describe google_compute_subnetworks(project: 'chef-inspec-gcp', region: 'europe-west2') do
its('subnetwork_networks') { should not include "network-name" }
end

## Properties
Properties that can be accessed from the `google_compute_subnetworks` resource:

Expand Down
30 changes: 30 additions & 0 deletions docs/resources/google_compute_vpn_tunnel.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,36 @@ describe google_compute_vpn_tunnel(project: 'chef-gcp-inspec', region: 'europe-w
end
```

### Test that a GCP compute vpn_tunnel exists

describe google_compute_vpn_tunnel(project: 'chef-inspec-gcp', region: 'europe-west2', name: 'gcp-inspec-vpn-tunnel') do
it { should exist }
end

### Test when a GCP compute vpn_tunnel was created

describe google_compute_vpn_tunnel(project: 'chef-inspec-gcp', region: 'europe-west2', name: 'gcp-inspec-vpn-tunnel') do
its('creation_timestamp_date') { should be > Time.now - 365*60*60*24*10 }
end

### Test for an expected vpn_tunnel identifier

describe google_compute_vpn_tunnel(project: 'chef-inspec-gcp', region: 'europe-west2', name: 'gcp-inspec-vpn-tunnel') do
its('id') { should eq 12345567789 }
end

### Test that a vpn_tunnel peer address is as expected

describe google_compute_vpn_tunnel(project: 'chef-inspec-gcp', region: 'europe-west2', name: 'gcp-inspec-vpn-tunnel') do
its('peer_ip') { should eq "123.123.123.123" }
end

### Test that a vpn_tunnel status is as expected

describe google_compute_vpn_tunnel(project: 'chef-inspec-gcp', region: 'europe-west2', name: 'gcp-inspec-vpn_tunnel') do
its('status') { should eq "ESTABLISHED" }
end

## Properties
Properties that can be accessed from the `google_compute_vpn_tunnel` resource:

Expand Down
18 changes: 18 additions & 0 deletions docs/resources/google_compute_vpn_tunnels.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,24 @@ describe google_compute_vpn_tunnels(project: 'chef-gcp-inspec', region: 'europe-
end
```

### Test that there are no more than a specified number of vpn_tunnels available for the project and region

describe google_compute_vpn_tunnels(project: 'chef-inspec-gcp', region: 'europe-west2') do
its('count') { should be <= 100}
end

### Test that an expected vpn_tunnel name is available for the project and region

describe google_compute_vpn_tunnels(project: 'chef-inspec-gcp', region: 'europe-west2') do
its('vpn_tunnel_names') { should include "vpn_tunnel-name" }
end

### Test that an expected vpn_tunnel target_vpn_gateways name is not present for the project and region

describe google_compute_vpn_tunnels(project: 'chef-inspec-gcp', region: 'europe-west2') do
its('vpn_tunnel_target_vpn_gateways') { should not include "gateway-name" }
end

## Properties
Properties that can be accessed from the `google_compute_vpn_tunnels` resource:

Expand Down
Loading

0 comments on commit 659f8f3

Please sign in to comment.