Skip to content

Commit 13efdb0

Browse files
authored
Change rotate-root path method (#81)
Change `rotate-root` path method Description Now rotate-root path works with POST and PUT instead of GET Fixes: #80 Acceptance tests Running acceptance tests... === RUN TestPlugin === RUN TestPlugin/TestCloudLifecycle === RUN TestPlugin/TestCloudLifecycle/WriteCloud === RUN TestPlugin/TestCloudLifecycle/ReadCloud === RUN TestPlugin/TestCloudLifecycle/ListClouds === RUN TestPlugin/TestCloudLifecycle/ListClouds/method-LIST === PAUSE TestPlugin/TestCloudLifecycle/ListClouds/method-LIST === RUN TestPlugin/TestCloudLifecycle/ListClouds/method-GET === PAUSE TestPlugin/TestCloudLifecycle/ListClouds/method-GET === CONT TestPlugin/TestCloudLifecycle/ListClouds/method-LIST === CONT TestPlugin/TestCloudLifecycle/ListClouds/method-GET === RUN TestPlugin/TestCloudLifecycle/DeleteCloud === RUN TestPlugin/TestCredsLifecycle === RUN TestPlugin/TestCredsLifecycle/root_token === RUN TestPlugin/TestCredsLifecycle/user_token === RUN TestPlugin/TestCredsLifecycle/user_password === RUN TestPlugin/TestInfo === RUN TestPlugin/TestRoleLifecycle roles_test.go:53: Cloud with name `dvjjx06ku3` was created === RUN TestPlugin/TestRoleLifecycle/WriteRole === RUN TestPlugin/TestRoleLifecycle/ReadRole === RUN TestPlugin/TestRoleLifecycle/ListRoles === RUN TestPlugin/TestRoleLifecycle/ListRoles/method-LIST === PAUSE TestPlugin/TestRoleLifecycle/ListRoles/method-LIST === RUN TestPlugin/TestRoleLifecycle/ListRoles/method-GET === PAUSE TestPlugin/TestRoleLifecycle/ListRoles/method-GET === CONT TestPlugin/TestRoleLifecycle/ListRoles/method-LIST === CONT TestPlugin/TestRoleLifecycle/ListRoles/method-GET === RUN TestPlugin/TestRoleLifecycle/DeleteRole === CONT TestPlugin/TestRoleLifecycle plugin_test.go:337: Cloud with name `dvjjx06ku3` has been removed === RUN TestPlugin/TestRootRotate rotate_test.go:65: Cloud with name `default1` was created rotate_test.go:68: Cloud with name `qrh3` was created plugin_test.go:337: Cloud with name `qrh3` has been removed plugin_test.go:337: Cloud with name `default1` has been removed --- PASS: TestPlugin (11.94s) --- PASS: TestPlugin/TestCloudLifecycle (0.38s) --- PASS: TestPlugin/TestCloudLifecycle/WriteCloud (0.38s) --- PASS: TestPlugin/TestCloudLifecycle/ReadCloud (0.00s) --- PASS: TestPlugin/TestCloudLifecycle/ListClouds (0.00s) --- PASS: TestPlugin/TestCloudLifecycle/ListClouds/method-GET (0.00s) --- PASS: TestPlugin/TestCloudLifecycle/ListClouds/method-LIST (0.00s) --- PASS: TestPlugin/TestCloudLifecycle/DeleteCloud (0.00s) --- PASS: TestPlugin/TestCredsLifecycle (4.87s) --- PASS: TestPlugin/TestCredsLifecycle/root_token (1.21s) --- PASS: TestPlugin/TestCredsLifecycle/user_token (2.01s) --- PASS: TestPlugin/TestCredsLifecycle/user_password (0.78s) --- PASS: TestPlugin/TestInfo (0.00s) --- PASS: TestPlugin/TestRoleLifecycle (0.02s) --- PASS: TestPlugin/TestRoleLifecycle/WriteRole (0.00s) --- PASS: TestPlugin/TestRoleLifecycle/ReadRole (0.00s) --- PASS: TestPlugin/TestRoleLifecycle/ListRoles (0.00s) --- PASS: TestPlugin/TestRoleLifecycle/ListRoles/method-LIST (0.00s) --- PASS: TestPlugin/TestRoleLifecycle/ListRoles/method-GET (0.00s) --- PASS: TestPlugin/TestRoleLifecycle/DeleteRole (0.00s) --- PASS: TestPlugin/TestRootRotate (4.55s) PASS ok github.com/opentelekomcloud/vault-plugin-secrets-openstack/acceptance 11.948s Reviewed-by: Vladimir Vshivkov <None> Reviewed-by: Artem Goncharov <[email protected]> Reviewed-by: Rodion Gyrbu <[email protected]>
1 parent b4a05eb commit 13efdb0

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

acceptance/rotate_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func (p *PluginTest) TestRootRotate() {
6868
newCloud := p.makeChildCloud(cloud)
6969

7070
r, err := p.vaultDo(
71-
http.MethodGet,
71+
http.MethodPost,
7272
fmt.Sprintf("/v1/%s/rotate-root/%s", pluginAlias, newCloud.Name),
7373
nil,
7474
)

doc/source/api.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ Once this method is called, Vault will now be the only entity that knows the pas
116116

117117
| Method | Path |
118118
|:-------|:--------------------------------|
119-
| `GET` | `/openstack/rotate-root/:cloud` |
119+
| `POST` | `/openstack/rotate-root/:cloud` |
120+
| `PUT` | `/openstack/rotate-root/:cloud` |
120121

121122
### Sample Request
122123

openstack/path_rotate_root.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ func (b *backend) pathRotateRoot() *framework.Path {
3434
},
3535
},
3636
Operations: map[logical.Operation]framework.OperationHandler{
37-
logical.ReadOperation: &framework.PathOperation{
37+
logical.CreateOperation: &framework.PathOperation{
38+
Callback: b.rotateRootCredentials,
39+
},
40+
logical.UpdateOperation: &framework.PathOperation{
3841
Callback: b.rotateRootCredentials,
3942
},
4043
},

openstack/path_rotate_root_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func TestRotateRootCredentials_ok(t *testing.T) {
3636

3737
_, err = b.HandleRequest(context.Background(), &logical.Request{
3838
Path: "rotate-root/" + cloud.name,
39-
Operation: logical.ReadOperation,
39+
Operation: logical.CreateOperation,
4040
Storage: s,
4141
})
4242
require.NoError(t, err)
@@ -56,7 +56,7 @@ func TestRotateRootCredentials_error(t *testing.T) {
5656

5757
_, err := b.HandleRequest(context.Background(), &logical.Request{
5858
Path: "rotate-root/" + cloud.name,
59-
Operation: logical.ReadOperation,
59+
Operation: logical.CreateOperation,
6060
Storage: s,
6161
})
6262
require.Error(t, err)
@@ -100,7 +100,7 @@ func TestRotateRootCredentials_error(t *testing.T) {
100100

101101
_, err = b.HandleRequest(context.Background(), &logical.Request{
102102
Path: "rotate-root/" + cloud.name,
103-
Operation: logical.ReadOperation,
103+
Operation: logical.CreateOperation,
104104
Storage: s,
105105
})
106106
require.Error(t, err)

0 commit comments

Comments
 (0)