From af089e41adc8ef88042b30128432707ffc565368 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20L=C3=A9one?= Date: Wed, 29 Jul 2020 15:33:45 +0200 Subject: [PATCH 1/2] feat(rdb): add nice human marshalling for add/delete rules --- internal/namespaces/rdb/v1/custom.go | 3 + internal/namespaces/rdb/v1/custom_acl.go | 35 ++ internal/namespaces/rdb/v1/custom_acl_test.go | 30 + .../test-add-acl-simple.cassette.yaml | 585 ++++++++++++++++++ .../v1/testdata/test-add-acl-simple.golden | 37 ++ .../test-delete-acl-simple.cassette.yaml | 553 +++++++++++++++++ .../v1/testdata/test-delete-acl-simple.golden | 24 + 7 files changed, 1267 insertions(+) create mode 100644 internal/namespaces/rdb/v1/custom_acl_test.go create mode 100644 internal/namespaces/rdb/v1/testdata/test-add-acl-simple.cassette.yaml create mode 100644 internal/namespaces/rdb/v1/testdata/test-add-acl-simple.golden create mode 100644 internal/namespaces/rdb/v1/testdata/test-delete-acl-simple.cassette.yaml create mode 100644 internal/namespaces/rdb/v1/testdata/test-delete-acl-simple.golden diff --git a/internal/namespaces/rdb/v1/custom.go b/internal/namespaces/rdb/v1/custom.go index 4e795dfd8c..138104b55c 100644 --- a/internal/namespaces/rdb/v1/custom.go +++ b/internal/namespaces/rdb/v1/custom.go @@ -35,6 +35,9 @@ func GetCommands() *core.Commands { instanceConnectCommand(), backupWaitCommand(), )) + cmds.MustFind("rdb", "acl", "add").Override(aclAddBuilder) + cmds.MustFind("rdb", "acl", "delete").Override(aclDeleteBuilder) + cmds.MustFind("rdb", "backup", "create").Override(backupCreateBuilder) cmds.MustFind("rdb", "backup", "export").Override(backupExportBuilder) cmds.MustFind("rdb", "backup", "restore").Override(backupRestoreBuilder) diff --git a/internal/namespaces/rdb/v1/custom_acl.go b/internal/namespaces/rdb/v1/custom_acl.go index 62585d6ce2..61aab92374 100644 --- a/internal/namespaces/rdb/v1/custom_acl.go +++ b/internal/namespaces/rdb/v1/custom_acl.go @@ -1,7 +1,10 @@ package rdb import ( + "context" + "github.com/fatih/color" + "github.com/scaleway/scaleway-cli/internal/core" "github.com/scaleway/scaleway-cli/internal/human" "github.com/scaleway/scaleway-sdk-go/api/rdb/v1" ) @@ -12,3 +15,35 @@ var ( rdb.ACLRuleActionDeny: &human.EnumMarshalSpec{Attribute: color.FgRed, Value: "deny"}, } ) + +func aclAddBuilder(c *core.Command) *core.Command { + c.Interceptor = func(ctx context.Context, argsI interface{}, runner core.CommandRunner) (interface{}, error) { + aclAddResponseI, err := runner(ctx, argsI) + if err != nil { + return nil, err + } + aclAddResponse := aclAddResponseI.(*rdb.AddInstanceACLRulesResponse) + return rdb.ListInstanceACLRulesResponse{ + Rules: aclAddResponse.Rules, + TotalCount: uint32(len(aclAddResponse.Rules)), + }, nil + } + + return c +} + +func aclDeleteBuilder(c *core.Command) *core.Command { + c.Interceptor = func(ctx context.Context, argsI interface{}, runner core.CommandRunner) (interface{}, error) { + aclDeleteResponseI, err := runner(ctx, argsI) + if err != nil { + return nil, err + } + aclDeleteResponse := aclDeleteResponseI.(*rdb.DeleteInstanceACLRulesResponse) + return rdb.ListInstanceACLRulesResponse{ + Rules: aclDeleteResponse.Rules, + TotalCount: uint32(len(aclDeleteResponse.Rules)), + }, nil + } + + return c +} diff --git a/internal/namespaces/rdb/v1/custom_acl_test.go b/internal/namespaces/rdb/v1/custom_acl_test.go new file mode 100644 index 0000000000..2f38ab8641 --- /dev/null +++ b/internal/namespaces/rdb/v1/custom_acl_test.go @@ -0,0 +1,30 @@ +package rdb + +import ( + "testing" + + "github.com/scaleway/scaleway-cli/internal/core" +) + +func Test_AddACL(t *testing.T) { + t.Run("Simple", core.Test(&core.TestConfig{ + Commands: GetCommands(), + BeforeFunc: createInstance("PostgreSQL-12"), + Cmd: "scw rdb acl add instance-id={{ .Instance.ID }} rules.0.ip=4.2.3.4", + Check: core.TestCheckGolden(), + AfterFunc: deleteInstance(), + })) +} + +func Test_DeleteACL(t *testing.T) { + t.Run("Simple", core.Test(&core.TestConfig{ + Commands: GetCommands(), + BeforeFunc: core.BeforeFuncCombine( + createInstance("PostgreSQL-12"), + core.ExecBeforeCmd("scw rdb acl add instance-id={{ .Instance.ID }} rules.0.ip=1.2.3.4"), + ), + Cmd: "scw rdb acl remove instance-id={{ .Instance.ID }} acl-rule-ips.0=1.2.3.4", + Check: core.TestCheckGolden(), + AfterFunc: deleteInstance(), + })) +} diff --git a/internal/namespaces/rdb/v1/testdata/test-add-acl-simple.cassette.yaml b/internal/namespaces/rdb/v1/testdata/test-add-acl-simple.cassette.yaml new file mode 100644 index 0000000000..fad898e3d9 --- /dev/null +++ b/internal/namespaces/rdb/v1/testdata/test-add-acl-simple.cassette.yaml @@ -0,0 +1,585 @@ +--- +version: 1 +interactions: +- request: + body: '{"organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","name":"cli-test","engine":"PostgreSQL-12","user_name":"foobar","password":"{4xdl*#QOoP+\u00263XRkGA)]","node_type":"db-dev-s","is_ha_cluster":false,"disable_backup":false,"tags":null}' + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.5; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances + method: POST + response: + body: '{"id":"2da36b6f-5d7e-41c1-9e7d-241bdbe5c63e","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"provisioning","engine":"PostgreSQL-12","endpoint":null,"tags":[],"settings":[],"backup_schedule":{"frequency":24,"retention":7,"disabled":false},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-08-12T08:39:43.691256Z","region":"fr-par"}' + headers: + Content-Length: + - "443" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Wed, 12 Aug 2020 08:39:44 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - bf5fdbf0-e3e4-4150-bc92-795317ef8d88 + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.5; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/2da36b6f-5d7e-41c1-9e7d-241bdbe5c63e + method: GET + response: + body: '{"id":"2da36b6f-5d7e-41c1-9e7d-241bdbe5c63e","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"provisioning","engine":"PostgreSQL-12","endpoint":null,"tags":[],"settings":[],"backup_schedule":{"frequency":24,"retention":7,"disabled":false},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-08-12T08:39:43.691256Z","region":"fr-par"}' + headers: + Content-Length: + - "443" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Wed, 12 Aug 2020 08:39:44 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - fd120fa7-acde-4303-a2aa-2c0287a8245b + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.5; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/2da36b6f-5d7e-41c1-9e7d-241bdbe5c63e + method: GET + response: + body: '{"id":"2da36b6f-5d7e-41c1-9e7d-241bdbe5c63e","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"provisioning","engine":"PostgreSQL-12","endpoint":null,"tags":[],"settings":[],"backup_schedule":{"frequency":24,"retention":7,"disabled":false},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-08-12T08:39:43.691256Z","region":"fr-par"}' + headers: + Content-Length: + - "443" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Wed, 12 Aug 2020 08:39:59 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - fe59a15b-4578-465d-a3bf-02103bcccd12 + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.5; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/2da36b6f-5d7e-41c1-9e7d-241bdbe5c63e + method: GET + response: + body: '{"id":"2da36b6f-5d7e-41c1-9e7d-241bdbe5c63e","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"provisioning","engine":"PostgreSQL-12","endpoint":null,"tags":[],"settings":[],"backup_schedule":{"frequency":24,"retention":7,"disabled":false},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-08-12T08:39:43.691256Z","region":"fr-par"}' + headers: + Content-Length: + - "443" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Wed, 12 Aug 2020 08:40:14 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - a8ec5755-3707-45d9-8ba0-bf21e6d982f0 + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.5; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/2da36b6f-5d7e-41c1-9e7d-241bdbe5c63e + method: GET + response: + body: '{"id":"2da36b6f-5d7e-41c1-9e7d-241bdbe5c63e","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"provisioning","engine":"PostgreSQL-12","endpoint":null,"tags":[],"settings":[],"backup_schedule":{"frequency":24,"retention":7,"disabled":false},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-08-12T08:39:43.691256Z","region":"fr-par"}' + headers: + Content-Length: + - "443" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Wed, 12 Aug 2020 08:40:29 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 360d68c6-d4cb-40eb-9465-c33ce9c2385e + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.5; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/2da36b6f-5d7e-41c1-9e7d-241bdbe5c63e + method: GET + response: + body: '{"id":"2da36b6f-5d7e-41c1-9e7d-241bdbe5c63e","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"initializing","engine":"PostgreSQL-12","endpoint":null,"tags":[],"settings":[],"backup_schedule":{"frequency":24,"retention":7,"disabled":false},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-08-12T08:39:43.691256Z","region":"fr-par"}' + headers: + Content-Length: + - "443" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Wed, 12 Aug 2020 08:40:45 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 9e298685-eceb-472a-911c-bd16ab56ea46 + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.5; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/2da36b6f-5d7e-41c1-9e7d-241bdbe5c63e + method: GET + response: + body: '{"id":"2da36b6f-5d7e-41c1-9e7d-241bdbe5c63e","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"initializing","engine":"PostgreSQL-12","endpoint":null,"tags":[],"settings":[],"backup_schedule":{"frequency":24,"retention":7,"disabled":false},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-08-12T08:39:43.691256Z","region":"fr-par"}' + headers: + Content-Length: + - "443" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Wed, 12 Aug 2020 08:40:59 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 77455b1f-6135-493c-9f3f-009737c77e99 + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.5; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/2da36b6f-5d7e-41c1-9e7d-241bdbe5c63e + method: GET + response: + body: '{"id":"2da36b6f-5d7e-41c1-9e7d-241bdbe5c63e","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"initializing","engine":"PostgreSQL-12","endpoint":null,"tags":[],"settings":[],"backup_schedule":{"frequency":24,"retention":7,"disabled":false},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-08-12T08:39:43.691256Z","region":"fr-par"}' + headers: + Content-Length: + - "443" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Wed, 12 Aug 2020 08:41:14 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 7d427e97-5500-4346-ab31-7e3aa2d25070 + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.5; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/2da36b6f-5d7e-41c1-9e7d-241bdbe5c63e + method: GET + response: + body: '{"id":"2da36b6f-5d7e-41c1-9e7d-241bdbe5c63e","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"initializing","engine":"PostgreSQL-12","endpoint":null,"tags":[],"settings":[],"backup_schedule":{"frequency":24,"retention":7,"disabled":false},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-08-12T08:39:43.691256Z","region":"fr-par"}' + headers: + Content-Length: + - "443" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Wed, 12 Aug 2020 08:41:29 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - c3fc4c21-f4e5-487f-a2f6-c7b64a70f805 + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.5; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/2da36b6f-5d7e-41c1-9e7d-241bdbe5c63e + method: GET + response: + body: '{"id":"2da36b6f-5d7e-41c1-9e7d-241bdbe5c63e","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"initializing","engine":"PostgreSQL-12","endpoint":null,"tags":[],"settings":[],"backup_schedule":{"frequency":24,"retention":7,"disabled":false},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-08-12T08:39:43.691256Z","region":"fr-par"}' + headers: + Content-Length: + - "443" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Wed, 12 Aug 2020 08:41:45 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 50c09cdd-c580-45ce-a139-ed8c2e3e9a09 + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.5; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/2da36b6f-5d7e-41c1-9e7d-241bdbe5c63e + method: GET + response: + body: '{"id":"2da36b6f-5d7e-41c1-9e7d-241bdbe5c63e","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"initializing","engine":"PostgreSQL-12","endpoint":null,"tags":[],"settings":[],"backup_schedule":{"frequency":24,"retention":7,"disabled":false},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-08-12T08:39:43.691256Z","region":"fr-par"}' + headers: + Content-Length: + - "443" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Wed, 12 Aug 2020 08:42:00 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 2d54c07f-b1e6-4834-a9f8-d239b2bd0223 + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.5; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/2da36b6f-5d7e-41c1-9e7d-241bdbe5c63e + method: GET + response: + body: '{"id":"2da36b6f-5d7e-41c1-9e7d-241bdbe5c63e","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"initializing","engine":"PostgreSQL-12","endpoint":null,"tags":[],"settings":[],"backup_schedule":{"frequency":24,"retention":7,"disabled":false},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-08-12T08:39:43.691256Z","region":"fr-par"}' + headers: + Content-Length: + - "443" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Wed, 12 Aug 2020 08:42:15 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 14a2f8b7-381b-47b1-b65e-a2541b3f667d + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.5; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/2da36b6f-5d7e-41c1-9e7d-241bdbe5c63e + method: GET + response: + body: '{"id":"2da36b6f-5d7e-41c1-9e7d-241bdbe5c63e","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"initializing","engine":"PostgreSQL-12","endpoint":null,"tags":[],"settings":[],"backup_schedule":{"frequency":24,"retention":7,"disabled":false},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-08-12T08:39:43.691256Z","region":"fr-par"}' + headers: + Content-Length: + - "443" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Wed, 12 Aug 2020 08:42:30 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 1531fbb5-b478-4cce-8c6d-1bf858a4f5e0 + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.5; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/2da36b6f-5d7e-41c1-9e7d-241bdbe5c63e + method: GET + response: + body: '{"id":"2da36b6f-5d7e-41c1-9e7d-241bdbe5c63e","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"initializing","engine":"PostgreSQL-12","endpoint":null,"tags":[],"settings":[],"backup_schedule":{"frequency":24,"retention":7,"disabled":false},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-08-12T08:39:43.691256Z","region":"fr-par"}' + headers: + Content-Length: + - "443" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Wed, 12 Aug 2020 08:42:45 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - ad3833d0-850f-43b2-bc8c-08f8b9df9e3c + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.5; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/2da36b6f-5d7e-41c1-9e7d-241bdbe5c63e + method: GET + response: + body: '{"id":"2da36b6f-5d7e-41c1-9e7d-241bdbe5c63e","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"initializing","engine":"PostgreSQL-12","endpoint":null,"tags":[],"settings":[],"backup_schedule":{"frequency":24,"retention":7,"disabled":false},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-08-12T08:39:43.691256Z","region":"fr-par"}' + headers: + Content-Length: + - "443" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Wed, 12 Aug 2020 08:43:00 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - efb498b4-a1cc-49ad-82c7-ed815454af2a + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.5; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/2da36b6f-5d7e-41c1-9e7d-241bdbe5c63e + method: GET + response: + body: '{"id":"2da36b6f-5d7e-41c1-9e7d-241bdbe5c63e","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"ready","engine":"PostgreSQL-12","endpoint":{"ip":"51.159.26.67","port":13989,"name":null},"tags":[],"settings":[{"name":"work_mem","value":"4"},{"name":"max_connections","value":"100"},{"name":"effective_cache_size","value":"1300"},{"name":"maintenance_work_mem","value":"150"},{"name":"max_parallel_workers","value":"0"},{"name":"max_parallel_workers_per_gather","value":"0"}],"backup_schedule":{"frequency":24,"retention":7,"disabled":false},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-08-12T08:39:43.691256Z","region":"fr-par"}' + headers: + Content-Length: + - "742" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Wed, 12 Aug 2020 08:43:15 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 197b7d05-3da5-4778-bb6b-82a049c53d8c + status: 200 OK + code: 200 + duration: "" +- request: + body: '{"rules":[{"ip":"4.2.3.4/32","description":""}]}' + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.5; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/2da36b6f-5d7e-41c1-9e7d-241bdbe5c63e/acls + method: POST + response: + body: '{"rules":[{"ip":"0.0.0.0/0","port":13989,"protocol":"tcp","direction":"inbound","action":"allow","description":"Allow + All"},{"ip":"4.2.3.4","port":13989,"protocol":"tcp","direction":"inbound","action":"allow","description":"IP + allowed"}]}' + headers: + Content-Length: + - "238" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Wed, 12 Aug 2020 08:43:18 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - a54bf29d-7f3b-4357-be0b-fcbdb7d39112 + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.5; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/2da36b6f-5d7e-41c1-9e7d-241bdbe5c63e + method: DELETE + response: + body: '{"id":"2da36b6f-5d7e-41c1-9e7d-241bdbe5c63e","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"deleting","engine":"PostgreSQL-12","endpoint":{"ip":"51.159.26.67","port":13989,"name":null},"tags":[],"settings":[{"name":"work_mem","value":"4"},{"name":"max_connections","value":"100"},{"name":"effective_cache_size","value":"1300"},{"name":"maintenance_work_mem","value":"150"},{"name":"max_parallel_workers","value":"0"},{"name":"max_parallel_workers_per_gather","value":"0"}],"backup_schedule":{"frequency":24,"retention":7,"disabled":true},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-08-12T08:39:43.691256Z","region":"fr-par"}' + headers: + Content-Length: + - "744" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Wed, 12 Aug 2020 08:43:19 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - da453382-8f2b-4ad6-b5f4-a5b99c35d510 + status: 200 OK + code: 200 + duration: "" diff --git a/internal/namespaces/rdb/v1/testdata/test-add-acl-simple.golden b/internal/namespaces/rdb/v1/testdata/test-add-acl-simple.golden new file mode 100644 index 0000000000..3ab3bc0048 --- /dev/null +++ b/internal/namespaces/rdb/v1/testdata/test-add-acl-simple.golden @@ -0,0 +1,37 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +🟩🟩🟩 STDOUT️ 🟩🟩🟩️ +Rules.0.IP 0.0.0.0/0 +Rules.0.Port 13989 +Rules.0.Protocol tcp +Rules.0.Direction inbound +Rules.0.Action allow +Rules.0.Description Allow All +Rules.1.IP 4.2.3.4/32 +Rules.1.Port 13989 +Rules.1.Protocol tcp +Rules.1.Direction inbound +Rules.1.Action allow +Rules.1.Description IP allowed +TotalCount 2 +🟩🟩🟩 JSON STDOUT 🟩🟩🟩 +{ + "rules": [ + { + "ip": "0.0.0.0/0", + "port": 13989, + "protocol": "tcp", + "direction": "inbound", + "action": "allow", + "description": "Allow All" + }, + { + "ip": "4.2.3.4/32", + "port": 13989, + "protocol": "tcp", + "direction": "inbound", + "action": "allow", + "description": "IP allowed" + } + ], + "total_count": 2 +} diff --git a/internal/namespaces/rdb/v1/testdata/test-delete-acl-simple.cassette.yaml b/internal/namespaces/rdb/v1/testdata/test-delete-acl-simple.cassette.yaml new file mode 100644 index 0000000000..5531efb43e --- /dev/null +++ b/internal/namespaces/rdb/v1/testdata/test-delete-acl-simple.cassette.yaml @@ -0,0 +1,553 @@ +--- +version: 1 +interactions: +- request: + body: '{"organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","name":"cli-test","engine":"PostgreSQL-12","user_name":"foobar","password":"{4xdl*#QOoP+\u00263XRkGA)]","node_type":"db-dev-s","is_ha_cluster":false,"disable_backup":false,"tags":null}' + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.5; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances + method: POST + response: + body: '{"id":"4586e032-ee31-4374-8d06-3f2b0b873590","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"provisioning","engine":"PostgreSQL-12","endpoint":null,"tags":[],"settings":[],"backup_schedule":{"frequency":24,"retention":7,"disabled":false},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-08-12T08:52:36.292749Z","region":"fr-par"}' + headers: + Content-Length: + - "443" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Wed, 12 Aug 2020 08:52:36 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - fb3d775d-2036-45e5-aaa2-c7f2d7d3dae7 + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.5; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/4586e032-ee31-4374-8d06-3f2b0b873590 + method: GET + response: + body: '{"id":"4586e032-ee31-4374-8d06-3f2b0b873590","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"provisioning","engine":"PostgreSQL-12","endpoint":null,"tags":[],"settings":[],"backup_schedule":{"frequency":24,"retention":7,"disabled":false},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-08-12T08:52:36.292749Z","region":"fr-par"}' + headers: + Content-Length: + - "443" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Wed, 12 Aug 2020 08:52:36 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 58de660e-11df-4305-8382-561260ebfba5 + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.5; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/4586e032-ee31-4374-8d06-3f2b0b873590 + method: GET + response: + body: '{"id":"4586e032-ee31-4374-8d06-3f2b0b873590","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"provisioning","engine":"PostgreSQL-12","endpoint":null,"tags":[],"settings":[],"backup_schedule":{"frequency":24,"retention":7,"disabled":false},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-08-12T08:52:36.292749Z","region":"fr-par"}' + headers: + Content-Length: + - "443" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Wed, 12 Aug 2020 08:52:52 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - af1a135a-84ee-46c2-ad67-4a15a6987cf1 + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.5; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/4586e032-ee31-4374-8d06-3f2b0b873590 + method: GET + response: + body: '{"id":"4586e032-ee31-4374-8d06-3f2b0b873590","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"provisioning","engine":"PostgreSQL-12","endpoint":null,"tags":[],"settings":[],"backup_schedule":{"frequency":24,"retention":7,"disabled":false},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-08-12T08:52:36.292749Z","region":"fr-par"}' + headers: + Content-Length: + - "443" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Wed, 12 Aug 2020 08:53:07 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 0675214b-f4cd-4082-bfb5-ca33ee2c0df6 + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.5; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/4586e032-ee31-4374-8d06-3f2b0b873590 + method: GET + response: + body: '{"id":"4586e032-ee31-4374-8d06-3f2b0b873590","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"initializing","engine":"PostgreSQL-12","endpoint":null,"tags":[],"settings":[],"backup_schedule":{"frequency":24,"retention":7,"disabled":false},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-08-12T08:52:36.292749Z","region":"fr-par"}' + headers: + Content-Length: + - "443" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Wed, 12 Aug 2020 08:53:21 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - c19d8bbc-2f41-428c-b216-2300e1eac428 + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.5; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/4586e032-ee31-4374-8d06-3f2b0b873590 + method: GET + response: + body: '{"id":"4586e032-ee31-4374-8d06-3f2b0b873590","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"initializing","engine":"PostgreSQL-12","endpoint":null,"tags":[],"settings":[],"backup_schedule":{"frequency":24,"retention":7,"disabled":false},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-08-12T08:52:36.292749Z","region":"fr-par"}' + headers: + Content-Length: + - "443" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Wed, 12 Aug 2020 08:53:37 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 409adeeb-1c1b-4df8-acb0-a5aecbc02b81 + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.5; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/4586e032-ee31-4374-8d06-3f2b0b873590 + method: GET + response: + body: '{"id":"4586e032-ee31-4374-8d06-3f2b0b873590","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"initializing","engine":"PostgreSQL-12","endpoint":null,"tags":[],"settings":[],"backup_schedule":{"frequency":24,"retention":7,"disabled":false},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-08-12T08:52:36.292749Z","region":"fr-par"}' + headers: + Content-Length: + - "443" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Wed, 12 Aug 2020 08:53:52 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 09043bca-15b3-436e-bce7-f331f173fd67 + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.5; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/4586e032-ee31-4374-8d06-3f2b0b873590 + method: GET + response: + body: '{"id":"4586e032-ee31-4374-8d06-3f2b0b873590","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"initializing","engine":"PostgreSQL-12","endpoint":null,"tags":[],"settings":[],"backup_schedule":{"frequency":24,"retention":7,"disabled":false},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-08-12T08:52:36.292749Z","region":"fr-par"}' + headers: + Content-Length: + - "443" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Wed, 12 Aug 2020 08:54:07 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - f4c55172-5eae-4238-a8f2-11802c24d567 + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.5; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/4586e032-ee31-4374-8d06-3f2b0b873590 + method: GET + response: + body: '{"id":"4586e032-ee31-4374-8d06-3f2b0b873590","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"initializing","engine":"PostgreSQL-12","endpoint":null,"tags":[],"settings":[],"backup_schedule":{"frequency":24,"retention":7,"disabled":false},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-08-12T08:52:36.292749Z","region":"fr-par"}' + headers: + Content-Length: + - "443" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Wed, 12 Aug 2020 08:54:22 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - ade91754-d062-470f-8353-747a1f75b02b + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.5; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/4586e032-ee31-4374-8d06-3f2b0b873590 + method: GET + response: + body: '{"id":"4586e032-ee31-4374-8d06-3f2b0b873590","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"initializing","engine":"PostgreSQL-12","endpoint":null,"tags":[],"settings":[],"backup_schedule":{"frequency":24,"retention":7,"disabled":false},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-08-12T08:52:36.292749Z","region":"fr-par"}' + headers: + Content-Length: + - "443" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Wed, 12 Aug 2020 08:54:37 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 922025d8-ca41-479f-9197-5a466ba2aad9 + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.5; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/4586e032-ee31-4374-8d06-3f2b0b873590 + method: GET + response: + body: '{"id":"4586e032-ee31-4374-8d06-3f2b0b873590","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"initializing","engine":"PostgreSQL-12","endpoint":null,"tags":[],"settings":[],"backup_schedule":{"frequency":24,"retention":7,"disabled":false},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-08-12T08:52:36.292749Z","region":"fr-par"}' + headers: + Content-Length: + - "443" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Wed, 12 Aug 2020 08:54:52 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - de90aed7-9f82-4842-a385-dea1de78f412 + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.5; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/4586e032-ee31-4374-8d06-3f2b0b873590 + method: GET + response: + body: '{"id":"4586e032-ee31-4374-8d06-3f2b0b873590","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"initializing","engine":"PostgreSQL-12","endpoint":null,"tags":[],"settings":[],"backup_schedule":{"frequency":24,"retention":7,"disabled":false},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-08-12T08:52:36.292749Z","region":"fr-par"}' + headers: + Content-Length: + - "443" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Wed, 12 Aug 2020 08:55:07 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 42a5aaf3-9af2-40da-840a-1fb6419336ab + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.5; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/4586e032-ee31-4374-8d06-3f2b0b873590 + method: GET + response: + body: '{"id":"4586e032-ee31-4374-8d06-3f2b0b873590","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"initializing","engine":"PostgreSQL-12","endpoint":null,"tags":[],"settings":[],"backup_schedule":{"frequency":24,"retention":7,"disabled":false},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-08-12T08:52:36.292749Z","region":"fr-par"}' + headers: + Content-Length: + - "443" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Wed, 12 Aug 2020 08:55:22 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - ea84fdcc-410e-46a9-9c1c-7cc88ee72257 + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.5; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/4586e032-ee31-4374-8d06-3f2b0b873590 + method: GET + response: + body: '{"id":"4586e032-ee31-4374-8d06-3f2b0b873590","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"initializing","engine":"PostgreSQL-12","endpoint":null,"tags":[],"settings":[],"backup_schedule":{"frequency":24,"retention":7,"disabled":false},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-08-12T08:52:36.292749Z","region":"fr-par"}' + headers: + Content-Length: + - "443" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Wed, 12 Aug 2020 08:55:37 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 2574a5d1-e91e-484d-bf61-8a8ee4e92231 + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.5; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/4586e032-ee31-4374-8d06-3f2b0b873590 + method: GET + response: + body: '{"id":"4586e032-ee31-4374-8d06-3f2b0b873590","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"ready","engine":"PostgreSQL-12","endpoint":{"ip":"195.154.68.222","port":27678,"name":null},"tags":[],"settings":[{"name":"work_mem","value":"4"},{"name":"max_connections","value":"100"},{"name":"effective_cache_size","value":"1300"},{"name":"maintenance_work_mem","value":"150"},{"name":"max_parallel_workers","value":"0"},{"name":"max_parallel_workers_per_gather","value":"0"}],"backup_schedule":{"frequency":24,"retention":7,"disabled":false},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-08-12T08:52:36.292749Z","region":"fr-par"}' + headers: + Content-Length: + - "744" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Wed, 12 Aug 2020 08:55:53 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - c33af946-5061-4433-9178-4d7b3ab45f9b + status: 200 OK + code: 200 + duration: "" +- request: + body: '{"rules":[{"ip":"1.2.3.4/32","description":""}]}' + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.5; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/4586e032-ee31-4374-8d06-3f2b0b873590/acls + method: POST + response: + body: '{"rules":[{"ip":"0.0.0.0/0","port":27678,"protocol":"tcp","direction":"inbound","action":"allow","description":"Allow + All"},{"ip":"1.2.3.4","port":27678,"protocol":"tcp","direction":"inbound","action":"allow","description":"IP + allowed"}]}' + headers: + Content-Length: + - "238" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Wed, 12 Aug 2020 08:55:55 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - a378ebfd-45e1-477a-ba94-577d7cd95179 + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.5; darwin; amd64) cli-e2e-test + url: https://api.scaleway.com/rdb/v1/regions/fr-par/instances/4586e032-ee31-4374-8d06-3f2b0b873590 + method: DELETE + response: + body: '{"id":"4586e032-ee31-4374-8d06-3f2b0b873590","name":"cli-test","organization_id":"951df375-e094-4d26-97c1-ba548eeb9c42","status":"deleting","engine":"PostgreSQL-12","endpoint":{"ip":"195.154.68.222","port":27678,"name":null},"tags":[],"settings":[{"name":"work_mem","value":"4"},{"name":"max_connections","value":"100"},{"name":"effective_cache_size","value":"1300"},{"name":"maintenance_work_mem","value":"150"},{"name":"max_parallel_workers","value":"0"},{"name":"max_parallel_workers_per_gather","value":"0"}],"backup_schedule":{"frequency":24,"retention":7,"disabled":true},"is_ha_cluster":false,"read_replicas":[],"node_type":"db-dev-s","volume":{"type":"lssd","size":5000000000},"created_at":"2020-08-12T08:52:36.292749Z","region":"fr-par"}' + headers: + Content-Length: + - "746" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Wed, 12 Aug 2020 08:55:55 GMT + Server: + - agw_listener_public_vip + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - b5fb73d1-5969-4486-95d8-30dcc82bb266 + status: 200 OK + code: 200 + duration: "" diff --git a/internal/namespaces/rdb/v1/testdata/test-delete-acl-simple.golden b/internal/namespaces/rdb/v1/testdata/test-delete-acl-simple.golden new file mode 100644 index 0000000000..d88d197a1a --- /dev/null +++ b/internal/namespaces/rdb/v1/testdata/test-delete-acl-simple.golden @@ -0,0 +1,24 @@ +🎲🎲🎲 EXIT CODE: 1 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Network Access Control List allows to control network in and out traffic by setting up ACL rules. + +USAGE: + scw rdb acl + +AVAILABLE COMMANDS: + add Add an ACL instance to a given instance + delete Delete ACL rules of a given instance + list List ACL rules of a given instance + +FLAGS: + -h, --help help for acl + +GLOBAL FLAGS: + -c, --config string The path to the config file + -D, --debug Enable debug mode + -o, --output string Output format: json or human, see 'scw help output' for more info (default "human") + -p, --profile string The config profile to use + +Use "scw rdb acl [command] --help" for more information about a command. +πŸŸ₯πŸŸ₯πŸŸ₯ JSON STDERR πŸŸ₯πŸŸ₯πŸŸ₯ +{} From 2a76d7c54f013b66e31a71240bc2d4168c9deef5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20L=C3=A9one?= Date: Mon, 24 Aug 2020 11:51:01 +0200 Subject: [PATCH 2/2] FIx --- internal/namespaces/rdb/v1/custom_acl.go | 5 +- .../v1/testdata/test-add-acl-simple.golden | 55 +++++++------------ 2 files changed, 22 insertions(+), 38 deletions(-) diff --git a/internal/namespaces/rdb/v1/custom_acl.go b/internal/namespaces/rdb/v1/custom_acl.go index 61aab92374..7798c1db22 100644 --- a/internal/namespaces/rdb/v1/custom_acl.go +++ b/internal/namespaces/rdb/v1/custom_acl.go @@ -23,10 +23,7 @@ func aclAddBuilder(c *core.Command) *core.Command { return nil, err } aclAddResponse := aclAddResponseI.(*rdb.AddInstanceACLRulesResponse) - return rdb.ListInstanceACLRulesResponse{ - Rules: aclAddResponse.Rules, - TotalCount: uint32(len(aclAddResponse.Rules)), - }, nil + return aclAddResponse.Rules, nil } return c diff --git a/internal/namespaces/rdb/v1/testdata/test-add-acl-simple.golden b/internal/namespaces/rdb/v1/testdata/test-add-acl-simple.golden index 3ab3bc0048..cac765844e 100644 --- a/internal/namespaces/rdb/v1/testdata/test-add-acl-simple.golden +++ b/internal/namespaces/rdb/v1/testdata/test-add-acl-simple.golden @@ -1,37 +1,24 @@ 🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 🟩🟩🟩 STDOUT️ 🟩🟩🟩️ -Rules.0.IP 0.0.0.0/0 -Rules.0.Port 13989 -Rules.0.Protocol tcp -Rules.0.Direction inbound -Rules.0.Action allow -Rules.0.Description Allow All -Rules.1.IP 4.2.3.4/32 -Rules.1.Port 13989 -Rules.1.Protocol tcp -Rules.1.Direction inbound -Rules.1.Action allow -Rules.1.Description IP allowed -TotalCount 2 +IP PORT PROTOCOL DIRECTION ACTION DESCRIPTION +0.0.0.0/0 13989 tcp inbound allow Allow All +4.2.3.4/32 13989 tcp inbound allow IP allowed 🟩🟩🟩 JSON STDOUT 🟩🟩🟩 -{ - "rules": [ - { - "ip": "0.0.0.0/0", - "port": 13989, - "protocol": "tcp", - "direction": "inbound", - "action": "allow", - "description": "Allow All" - }, - { - "ip": "4.2.3.4/32", - "port": 13989, - "protocol": "tcp", - "direction": "inbound", - "action": "allow", - "description": "IP allowed" - } - ], - "total_count": 2 -} +[ + { + "ip": "0.0.0.0/0", + "port": 13989, + "protocol": "tcp", + "direction": "inbound", + "action": "allow", + "description": "Allow All" + }, + { + "ip": "4.2.3.4/32", + "port": 13989, + "protocol": "tcp", + "direction": "inbound", + "action": "allow", + "description": "IP allowed" + } +]