Add tests to proxy example

This commit is contained in:
Julio Castillo
2021-02-15 19:08:00 +01:00
parent e34e3d77c9
commit 077e881406
7 changed files with 100 additions and 6 deletions

View File

@@ -22,11 +22,12 @@ You can optionally deploy the Squid server as [Managed Instance Group](https://c
|---|---|:---: |:---:|:---:|
| billing_account | Billing account id used as default for new projects. | <code title="">string</code> | ✓ | |
| prefix | Prefix used for resources that need unique names. | <code title="">string</code> | ✓ | |
| region | Default region for resources | <code title="">string</code> | ✓ | |
| root_node | Root node for the new hierarchy, either 'organizations/org_id' or 'folders/folder_id'. | <code title="">string</code> | ✓ | |
| *allowed_domains* | List of domains allowed by the squid proxy. | <code title="list&#40;string&#41;">list(string)</code> | | <code title="&#91;&#10;&#34;.google.com&#34;,&#10;&#34;.github.com&#34;&#10;&#93;">...</code> |
| *cidrs* | CIDR ranges for subnets | <code title="map&#40;string&#41;">map(string)</code> | | <code title="&#123;&#10;apps &#61; &#34;10.0.0.0&#47;24&#34;&#10;proxy &#61; &#34;10.0.1.0&#47;28&#34;&#10;&#125;">...</code> |
| *mig* | Enables the creation of an autoscaling managed instance group of squid instances. | <code title="">bool</code> | | <code title="">false</code> |
| *nat_logging* | Enables Cloud NAT logging if not null, value is one of 'ERRORS_ONLY', 'TRANSLATIONS_ONLY', 'ALL'. | <code title="">string</code> | | <code title="">ERRORS_ONLY</code> |
| *region* | Default region for resources | <code title="">string</code> | | <code title="">europe-west1</code> |
## Outputs

View File

@@ -124,10 +124,8 @@ module "service-account-squid" {
}
module "cos-squid" {
source = "../../modules/cloud-config-container/squid"
allow = [
".github.com",
]
source = "../../modules/cloud-config-container/squid"
allow = var.allowed_domains
clients = [var.cidrs.apps]
}
@@ -250,7 +248,7 @@ module "folder-apps" {
module "project-app" {
source = "../../modules/project"
billing_account = var.billing_account
name = "app"
name = "app1"
parent = module.folder-apps.id
prefix = var.prefix
services = ["compute.googleapis.com"]

View File

@@ -32,6 +32,7 @@ variable "root_node" {
variable "region" {
description = "Default region for resources"
type = string
default = "europe-west1"
}
variable "cidrs" {
@@ -54,3 +55,12 @@ variable "mig" {
type = bool
default = false
}
variable "allowed_domains" {
description = "List of domains allowed by the squid proxy."
type = list(string)
default = [
".google.com",
".github.com"
]
}

View File

@@ -0,0 +1,13 @@
# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

View File

@@ -0,0 +1,23 @@
/**
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
module "test" {
source = "../../../../networking/filtering-proxy"
billing_account = "123456-123456-123456"
mig = var.mig
prefix = "fabric"
root_node = "folders/123456789"
}

View File

@@ -0,0 +1,18 @@
# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
variable "mig" {
type = bool
default = false
}

View File

@@ -0,0 +1,31 @@
# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import pytest
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), "fixture")
def test_resources(e2e_plan_runner):
"Test that plan works and the numbers of resources is as expected."
modules, resources = e2e_plan_runner(FIXTURES_DIR)
assert len(modules) == 10
assert len(resources) == 26
modules, resources = e2e_plan_runner(FIXTURES_DIR, mig="true")
assert len(modules) == 12
assert len(resources) == 32