-
Notifications
You must be signed in to change notification settings - Fork 162
fix(instance): split security group marshalers #2939
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
Merged
Codelax
merged 5 commits into
scaleway:master
from
Codelax:fix/security-group-rules-marshal
Mar 24, 2023
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6b6a825
tests(instance): add test for security group get
Codelax 89d4c81
fix(instance): split security-group rules marshaler
Codelax 9821c6a
Update internal/namespaces/instance/v1/custom_security_group.go
Codelax 93bc311
Update internal/namespaces/instance/v1/custom_security_group_test.go
Codelax 53d9475
fix linter
Codelax File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
internal/namespaces/instance/v1/custom_security_group_test.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| package instance | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/scaleway/scaleway-cli/v2/internal/core" | ||
| ) | ||
|
|
||
| func Test_SecurityGroupGet(t *testing.T) { | ||
| t.Run("Get", core.Test(&core.TestConfig{ | ||
| Commands: GetCommands(), | ||
| BeforeFunc: core.BeforeFuncCombine( | ||
| createSecurityGroup("SecurityGroup"), | ||
| ), | ||
| Cmd: "scw instance security-group get {{ .SecurityGroup.ID }}", | ||
| Check: core.TestCheckGolden(), | ||
|
Codelax marked this conversation as resolved.
Outdated
|
||
| AfterFunc: deleteSecurityGroup("SecurityGroup"), | ||
| })) | ||
| } | ||
160 changes: 160 additions & 0 deletions
160
internal/namespaces/instance/v1/testdata/test-security-group-get-get.cassette.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,160 @@ | ||
| --- | ||
| version: 1 | ||
| interactions: | ||
| - request: | ||
| body: '{"name":"cli-sg-hungry-borg","project":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b","organization_default":false,"project_default":false,"stateful":true,"inbound_default_policy":"accept","outbound_default_policy":"accept"}' | ||
| form: {} | ||
| headers: | ||
| Content-Type: | ||
| - application/json | ||
| User-Agent: | ||
| - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.20.1; linux; amd64) cli-e2e-test | ||
| url: https://api.scaleway.com/instance/v1/zones/fr-par-1/security_groups | ||
| method: POST | ||
| response: | ||
| body: '{"security_group": {"id": "4e02d7f0-1f93-4478-ab2d-e64a6aacbd47", "creation_date": | ||
| "2023-03-24T13:57:13.987804+00:00", "modification_date": "2023-03-24T13:57:13.987804+00:00", | ||
| "name": "cli-sg-hungry-borg", "description": null, "organization": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", | ||
| "project": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "servers": [], "stateful": | ||
| true, "inbound_default_policy": "accept", "outbound_default_policy": "accept", | ||
| "organization_default": false, "project_default": false, "enable_default_security": | ||
| true, "state": "syncing", "tags": [], "zone": "fr-par-1"}}' | ||
| headers: | ||
| Content-Length: | ||
| - "582" | ||
| Content-Security-Policy: | ||
| - default-src 'none'; frame-ancestors 'none' | ||
| Content-Type: | ||
| - application/json | ||
| Date: | ||
| - Fri, 24 Mar 2023 13:57:14 GMT | ||
| Location: | ||
| - https://api.scaleway.com/instance/v1/zones/fr-par-1/security_groups/4e02d7f0-1f93-4478-ab2d-e64a6aacbd47 | ||
| Server: | ||
| - Scaleway API-Gateway | ||
| Strict-Transport-Security: | ||
| - max-age=63072000 | ||
| X-Content-Type-Options: | ||
| - nosniff | ||
| X-Frame-Options: | ||
| - DENY | ||
| X-Request-Id: | ||
| - 1bbf4677-dc3a-495d-a5de-d63c8e7fc3c5 | ||
| status: 201 Created | ||
| code: 201 | ||
| duration: "" | ||
| - request: | ||
| body: "" | ||
| form: {} | ||
| headers: | ||
| User-Agent: | ||
| - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.20.1; linux; amd64) cli-e2e-test | ||
| url: https://api.scaleway.com/instance/v1/zones/fr-par-1/security_groups/4e02d7f0-1f93-4478-ab2d-e64a6aacbd47 | ||
| method: GET | ||
| response: | ||
| body: '{"security_group": {"id": "4e02d7f0-1f93-4478-ab2d-e64a6aacbd47", "creation_date": | ||
| "2023-03-24T13:57:13.987804+00:00", "modification_date": "2023-03-24T13:57:13.987804+00:00", | ||
| "name": "cli-sg-hungry-borg", "description": null, "organization": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", | ||
| "project": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "servers": [], "stateful": | ||
| true, "inbound_default_policy": "accept", "outbound_default_policy": "accept", | ||
| "organization_default": false, "project_default": false, "enable_default_security": | ||
| true, "state": "syncing", "tags": [], "zone": "fr-par-1"}}' | ||
| headers: | ||
| Content-Length: | ||
| - "582" | ||
| Content-Security-Policy: | ||
| - default-src 'none'; frame-ancestors 'none' | ||
| Content-Type: | ||
| - application/json | ||
| Date: | ||
| - Fri, 24 Mar 2023 13:57:14 GMT | ||
| Server: | ||
| - Scaleway API-Gateway | ||
| Strict-Transport-Security: | ||
| - max-age=63072000 | ||
| X-Content-Type-Options: | ||
| - nosniff | ||
| X-Frame-Options: | ||
| - DENY | ||
| X-Request-Id: | ||
| - ecf25c55-618a-4b8c-82b8-db578182090f | ||
| status: 200 OK | ||
| code: 200 | ||
| duration: "" | ||
| - request: | ||
| body: "" | ||
| form: {} | ||
| headers: | ||
| User-Agent: | ||
| - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.20.1; linux; amd64) cli-e2e-test | ||
| url: https://api.scaleway.com/instance/v1/zones/fr-par-1/security_groups/4e02d7f0-1f93-4478-ab2d-e64a6aacbd47/rules?page=1 | ||
| method: GET | ||
| response: | ||
| body: '{"rules": [{"id": "58909be7-d17c-4ac8-9eb3-23d5fc58abc5", "protocol": "TCP", | ||
| "direction": "outbound", "ip_range": "0.0.0.0/0", "dest_port_from": 25, "dest_port_to": | ||
| null, "position": 1, "editable": false, "action": "drop", "zone": "fr-par-1"}, | ||
| {"id": "25680235-108b-4bbc-8e25-114303d950bd", "protocol": "TCP", "direction": | ||
| "outbound", "ip_range": "0.0.0.0/0", "dest_port_from": 465, "dest_port_to": | ||
| null, "position": 2, "editable": false, "action": "drop", "zone": "fr-par-1"}, | ||
| {"id": "4a31b633-118e-4900-bd52-facf1085fc8d", "protocol": "TCP", "direction": | ||
| "outbound", "ip_range": "0.0.0.0/0", "dest_port_from": 587, "dest_port_to": | ||
| null, "position": 3, "editable": false, "action": "drop", "zone": "fr-par-1"}, | ||
| {"id": "e7dd28e8-3747-4c7c-9a4f-35ae3f0ae2cd", "protocol": "TCP", "direction": | ||
| "outbound", "ip_range": "::/0", "dest_port_from": 25, "dest_port_to": null, | ||
| "position": 4, "editable": false, "action": "drop", "zone": "fr-par-1"}, {"id": | ||
| "f37d9e7c-8ed7-4e0f-baff-7f5e7ede0baf", "protocol": "TCP", "direction": "outbound", | ||
| "ip_range": "::/0", "dest_port_from": 465, "dest_port_to": null, "position": | ||
| 5, "editable": false, "action": "drop", "zone": "fr-par-1"}, {"id": "68054851-54e3-46c9-9cd7-83219751248b", | ||
| "protocol": "TCP", "direction": "outbound", "ip_range": "::/0", "dest_port_from": | ||
| 587, "dest_port_to": null, "position": 6, "editable": false, "action": "drop", | ||
| "zone": "fr-par-1"}]}' | ||
| headers: | ||
| Content-Length: | ||
| - "1398" | ||
| Content-Security-Policy: | ||
| - default-src 'none'; frame-ancestors 'none' | ||
| Content-Type: | ||
| - application/json | ||
| Date: | ||
| - Fri, 24 Mar 2023 13:57:14 GMT | ||
| Server: | ||
| - Scaleway API-Gateway | ||
| Strict-Transport-Security: | ||
| - max-age=63072000 | ||
| X-Content-Type-Options: | ||
| - nosniff | ||
| X-Frame-Options: | ||
| - DENY | ||
| X-Request-Id: | ||
| - 9491aa05-a952-441a-9896-b06a815b009a | ||
| status: 200 OK | ||
| code: 200 | ||
| duration: "" | ||
| - request: | ||
| body: "" | ||
| form: {} | ||
| headers: | ||
| User-Agent: | ||
| - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.20.1; linux; amd64) cli-e2e-test | ||
| url: https://api.scaleway.com/instance/v1/zones/fr-par-1/security_groups/4e02d7f0-1f93-4478-ab2d-e64a6aacbd47 | ||
| method: DELETE | ||
| response: | ||
| body: "" | ||
| headers: | ||
| Content-Security-Policy: | ||
| - default-src 'none'; frame-ancestors 'none' | ||
| Date: | ||
| - Fri, 24 Mar 2023 13:57:14 GMT | ||
| Server: | ||
| - Scaleway API-Gateway | ||
| Strict-Transport-Security: | ||
| - max-age=63072000 | ||
| X-Content-Type-Options: | ||
| - nosniff | ||
| X-Frame-Options: | ||
| - DENY | ||
| X-Request-Id: | ||
| - 5cf21a3b-8b21-4675-9f22-af5c25289605 | ||
| status: 204 No Content | ||
| code: 204 | ||
| duration: "" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.