Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Add Cloud Firewall for integration tests #515

Merged
merged 5 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/integration/account_events_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

func TestAccountEvents_List(t *testing.T) {
client, instance, teardown, err := setupInstance(t, "fixtures/TestAccountEvents_List")
client, instance, teardown, err := setupInstance(t, "fixtures/TestAccountEvents_List", true)
defer teardown()
if err != nil {
t.Error(err)
Expand Down
6 changes: 3 additions & 3 deletions test/integration/example_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func Example() {
fmt.Println("### Error:", err)

if spendMoney {
linode, err = linodeClient.CreateInstance(context.Background(), linodego.InstanceCreateOptions{Region: "us-southeast", Type: "g5-nanode-1"})
linode, err = linodeClient.CreateInstance(context.Background(), linodego.InstanceCreateOptions{Region: "us-southeast", Type: "g5-nanode-1", FirewallID: GetFirewallID()})
ykim-1 marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
log.Fatalln("* While creating instance: ", err)
}
Expand Down Expand Up @@ -311,11 +311,11 @@ func Example() {
// ## First Linode
// ### First Config: true
// ### First Disk: true
// ### No Auto Backups
// ### First Auto Backup
// ### Snapshots
// ### No Current Snapshot
// ### No Volumes
// ## Your Stackscripts: false
// ## Your Stackscripts: true
}

const (
Expand Down
15 changes: 9 additions & 6 deletions test/integration/example_nodebalancers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ func ExampleClient_CreateNodeBalancerConfig() {
nb, err := linodeClient.CreateNodeBalancer(context.Background(), linodego.NodeBalancerCreateOptions{
ClientConnThrottle: &clientConnThrottle,
Region: "us-southeast",
FirewallID: GetFirewallID(),
})
if err != nil {
log.Fatal(err)
Expand Down Expand Up @@ -137,6 +138,7 @@ func ExampleClient_CreateNodeBalancerNode() {
nb, err := linodeClient.CreateNodeBalancer(context.Background(), linodego.NodeBalancerCreateOptions{
ClientConnThrottle: &clientConnThrottle,
Region: "us-southeast",
FirewallID: GetFirewallID(),
})
if err != nil {
log.Fatal(err)
Expand All @@ -153,12 +155,13 @@ func ExampleClient_CreateNodeBalancerNode() {

booted := false
instanceOpts := linodego.InstanceCreateOptions{
Label: "nodebalancer-example-instance",
RootPass: randPassword(),
Region: "us-southeast",
Type: "g6-nanode-1",
Image: "linode/debian9",
Booted: &booted,
Label: "nodebalancer-example-instance",
RootPass: randPassword(),
Region: "us-southeast",
Type: "g6-nanode-1",
Image: "linode/debian9",
Booted: &booted,
FirewallID: GetFirewallID(),
}
instance, err := linodeClient.CreateInstance(context.Background(), instanceOpts)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions test/integration/firewalls_devices_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

func TestFirewallDevices_List(t *testing.T) {
client, instance, teardown, err := setupInstance(t, "fixtures/TestFirewallDevices_List")
client, instance, teardown, err := setupInstance(t, "fixtures/TestFirewallDevices_List", false)
if err != nil {
t.Error(err)
}
Expand All @@ -35,7 +35,7 @@ func TestFirewallDevices_List(t *testing.T) {
}

func TestFirewallDevice_Get(t *testing.T) {
client, instance, teardown, err := setupInstance(t, "fixtures/TestFirewallDevice_Get")
client, instance, teardown, err := setupInstance(t, "fixtures/TestFirewallDevice_Get", false)
if err != nil {
t.Error(err)
}
Expand Down Expand Up @@ -63,7 +63,7 @@ func TestFirewallDevice_Get(t *testing.T) {
}

func TestFirewallDevice_Delete(t *testing.T) {
client, instance, teardown, err := setupInstance(t, "fixtures/TestFirewallDevice_Delete")
client, instance, teardown, err := setupInstance(t, "fixtures/TestFirewallDevice_Delete", false)
if err != nil {
t.Error(err)
}
Expand Down
1,358 changes: 670 additions & 688 deletions test/integration/fixtures/Example.yaml

Large diffs are not rendered by default.

107 changes: 66 additions & 41 deletions test/integration/fixtures/ExampleCreateNodeBalancer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ interactions:
url: https://api.linode.com/v4beta/nodebalancers
method: POST
response:
body: '{"id": 357846, "label": "balancer357846", "region": "us-southeast", "hostname":
"139-144-255-40.ip.linodeusercontent.com", "ipv4": "139.144.255.40", "ipv6":
"1234::5678", "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05",
"client_conn_throttle": 20, "tags": [], "transfer": {"in": null, "out": null,
"total": null}}'
body: '{"id": 694136, "label": "balancer694136", "region": "us-southeast", "hostname":
"45-79-245-145.ip.linodeusercontent.com", "ipv4": "45.79.245.145", "ipv6": "2600:3c02:1::2d4f:f591",
"created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "client_conn_throttle":
20, "tags": [], "transfer": {"in": null, "out": null, "total": null}}'
headers:
Access-Control-Allow-Credentials:
- "true"
Expand All @@ -31,15 +30,19 @@ interactions:
Access-Control-Expose-Headers:
- X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status
Cache-Control:
- private, max-age=60, s-maxage=60
- max-age=0, no-cache, no-store
Connection:
- keep-alive
Content-Length:
- "344"
- "342"
Content-Security-Policy:
- default-src 'none'
Content-Type:
- application/json
Server:
- nginx
Expires:
- Fri, 31 May 2024 17:04:37 GMT
Pragma:
- no-cache
Strict-Transport-Security:
- max-age=31536000
Vary:
Expand All @@ -52,9 +55,12 @@ interactions:
- DENY
- DENY
X-Oauth-Scopes:
- '*'
- account:read_write databases:read_write domains:read_write events:read_write
firewall:read_write images:read_write ips:read_write linodes:read_write lke:read_write
longview:read_write nodebalancers:read_write object_storage:read_write stackscripts:read_write
volumes:read_write vpc:read_write
X-Ratelimit-Limit:
- "800"
- "400"
X-Xss-Protection:
- 1; mode=block
status: 200 OK
Expand All @@ -70,14 +76,13 @@ interactions:
- application/json
User-Agent:
- linodego/dev https://github.com/linode/linodego
url: https://api.linode.com/v4beta/nodebalancers/357846
url: https://api.linode.com/v4beta/nodebalancers/694136
method: GET
response:
body: '{"id": 357846, "label": "balancer357846", "region": "us-southeast", "hostname":
"139-144-255-40.ip.linodeusercontent.com", "ipv4": "139.144.255.40", "ipv6":
"1234::5678", "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05",
"client_conn_throttle": 20, "tags": [], "transfer": {"in": null, "out": null,
"total": null}}'
body: '{"id": 694136, "label": "balancer694136", "region": "us-southeast", "hostname":
"45-79-245-145.ip.linodeusercontent.com", "ipv4": "45.79.245.145", "ipv6": "2600:3c02:1::2d4f:f591",
"created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "client_conn_throttle":
20, "tags": [], "transfer": {"in": null, "out": null, "total": null}}'
headers:
Access-Control-Allow-Credentials:
- "true"
Expand All @@ -90,16 +95,19 @@ interactions:
Access-Control-Expose-Headers:
- X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status
Cache-Control:
- private, max-age=0, s-maxage=0, no-cache, no-store
- private, max-age=60, s-maxage=60
- max-age=0, no-cache, no-store
Connection:
- keep-alive
Content-Length:
- "344"
- "342"
Content-Security-Policy:
- default-src 'none'
Content-Type:
- application/json
Server:
- nginx
Expires:
- Fri, 31 May 2024 17:04:37 GMT
Pragma:
- no-cache
Strict-Transport-Security:
- max-age=31536000
Vary:
Expand All @@ -113,16 +121,19 @@ interactions:
- DENY
- DENY
X-Oauth-Scopes:
- '*'
- account:read_write databases:read_write domains:read_write events:read_write
firewall:read_write images:read_write ips:read_write linodes:read_write lke:read_write
longview:read_write nodebalancers:read_write object_storage:read_write stackscripts:read_write
volumes:read_write vpc:read_write
X-Ratelimit-Limit:
- "800"
- "400"
X-Xss-Protection:
- 1; mode=block
status: 200 OK
code: 200
duration: ""
- request:
body: '{"label":"balancer357846_renamed","client_conn_throttle":20,"tags":[]}'
body: '{"label":"balancer694136_renamed","client_conn_throttle":20,"tags":[]}'
form: {}
headers:
Accept:
Expand All @@ -131,12 +142,12 @@ interactions:
- application/json
User-Agent:
- linodego/dev https://github.com/linode/linodego
url: https://api.linode.com/v4beta/nodebalancers/357846
url: https://api.linode.com/v4beta/nodebalancers/694136
method: PUT
response:
body: '{"id": 357846, "label": "balancer357846_renamed", "region": "us-southeast",
"hostname": "139-144-255-40.ip.linodeusercontent.com", "ipv4": "139.144.255.40",
"ipv6": "1234::5678", "created": "2018-01-02T03:04:05", "updated":
body: '{"id": 694136, "label": "balancer694136_renamed", "region": "us-southeast",
"hostname": "45-79-245-145.ip.linodeusercontent.com", "ipv4": "45.79.245.145",
"ipv6": "2600:3c02:1::2d4f:f591", "created": "2018-01-02T03:04:05", "updated":
"2018-01-02T03:04:05", "client_conn_throttle": 20, "tags": [], "transfer": {"in":
null, "out": null, "total": null}}'
headers:
Expand All @@ -151,15 +162,19 @@ interactions:
Access-Control-Expose-Headers:
- X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status
Cache-Control:
- private, max-age=60, s-maxage=60
- max-age=0, no-cache, no-store
Connection:
- keep-alive
Content-Length:
- "352"
- "350"
Content-Security-Policy:
- default-src 'none'
Content-Type:
- application/json
Server:
- nginx
Expires:
- Fri, 31 May 2024 17:04:38 GMT
Pragma:
- no-cache
Strict-Transport-Security:
- max-age=31536000
Vary:
Expand All @@ -172,9 +187,12 @@ interactions:
- DENY
- DENY
X-Oauth-Scopes:
- '*'
- account:read_write databases:read_write domains:read_write events:read_write
firewall:read_write images:read_write ips:read_write linodes:read_write lke:read_write
longview:read_write nodebalancers:read_write object_storage:read_write stackscripts:read_write
volumes:read_write vpc:read_write
X-Ratelimit-Limit:
- "800"
- "400"
X-Xss-Protection:
- 1; mode=block
status: 200 OK
Expand All @@ -190,7 +208,7 @@ interactions:
- application/json
User-Agent:
- linodego/dev https://github.com/linode/linodego
url: https://api.linode.com/v4beta/nodebalancers/357846
url: https://api.linode.com/v4beta/nodebalancers/694136
method: DELETE
response:
body: '{}'
Expand All @@ -206,15 +224,19 @@ interactions:
Access-Control-Expose-Headers:
- X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status
Cache-Control:
- private, max-age=60, s-maxage=60
- max-age=0, no-cache, no-store
Connection:
- keep-alive
Content-Length:
- "2"
Content-Security-Policy:
- default-src 'none'
Content-Type:
- application/json
Server:
- nginx
Expires:
- Fri, 31 May 2024 17:04:38 GMT
Pragma:
- no-cache
Strict-Transport-Security:
- max-age=31536000
Vary:
Expand All @@ -227,9 +249,12 @@ interactions:
- DENY
- DENY
X-Oauth-Scopes:
- '*'
- account:read_write databases:read_write domains:read_write events:read_write
firewall:read_write images:read_write ips:read_write linodes:read_write lke:read_write
longview:read_write nodebalancers:read_write object_storage:read_write stackscripts:read_write
volumes:read_write vpc:read_write
X-Ratelimit-Limit:
- "800"
- "400"
X-Xss-Protection:
- 1; mode=block
status: 200 OK
Expand Down
Loading