Add tests to proxy example
This commit is contained in:
@@ -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(string)">list(string)</code> | | <code title="[ ".google.com", ".github.com" ]">...</code> |
|
||||
| *cidrs* | CIDR ranges for subnets | <code title="map(string)">map(string)</code> | | <code title="{ apps = "10.0.0.0/24" proxy = "10.0.1.0/28" }">...</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
|
||||
|
||||
|
||||
@@ -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"]
|
||||
|
||||
@@ -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"
|
||||
]
|
||||
}
|
||||
|
||||
13
tests/networking/filtering_proxy/__init__.py
Normal file
13
tests/networking/filtering_proxy/__init__.py
Normal 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.
|
||||
23
tests/networking/filtering_proxy/fixture/main.tf
Normal file
23
tests/networking/filtering_proxy/fixture/main.tf
Normal 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"
|
||||
}
|
||||
18
tests/networking/filtering_proxy/fixture/variables.tf
Normal file
18
tests/networking/filtering_proxy/fixture/variables.tf
Normal 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
|
||||
}
|
||||
31
tests/networking/filtering_proxy/test_plan.py
Normal file
31
tests/networking/filtering_proxy/test_plan.py
Normal 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
|
||||
Reference in New Issue
Block a user