Repository: hvac/hvac (Python)

Issue:
Possible bug with `delete_role_secret_id_accessor`
The https://github.com/hvac/hvac/blob/master/hvac/v1/__init__.py#L2064 `delete_role_secret_id_accessor` method does not look like the documented https://www.vaultproject.io/api/auth/approle/#destroy-approle-secret-id-accessor method in the API.

1) the docstring has `DELETE` instead of `POST`
2) the docstring has `/secret-id/` instead of `/secret-id-accessor`
3) both the code, and docstring do not have the `/destroy` suffix as per the API

Most probably it should be similar to `delete_role_secret_id` https://github.com/hvac/hvac/blob/master/hvac/v1/__init__.py#L2046 where `POST` and `/destroy` are used for `/secret-id/` endpoints, it also has the `{ "secret_id": "" }` param, also like the API documentation shows for the accessor destruction.


Discussion:

Patch:
diff --git a/hvac/v1/__init__.py b/hvac/v1/__init__.py
index 6eace8958..671826515 100644
--- a/hvac/v1/__init__.py
+++ b/hvac/v1/__init__.py
@@ -1369,7 +1369,7 @@ def delete_role_secret_id(self, role_name, secret_id, mount_point='approle'):
         return self._adapter.post(url, json=params)
 
     def delete_role_secret_id_accessor(self, role_name, secret_id_accessor, mount_point='approle'):
-        """DELETE /auth/<mount_point>/role/<role name>/secret-id/<secret_id_accessor>
+        """POST /auth/<mount_point>/role/<role name>/secret-id-accessor/destroy
 
         :param role_name:
         :type role_name:
@@ -1380,8 +1380,11 @@ def delete_role_secret_id_accessor(self, role_name, secret_id_accessor, mount_po
         :return:
         :rtype:
         """
-        url = '/v1/auth/{0}/role/{1}/secret-id-accessor/{2}'.format(mount_point, role_name, secret_id_accessor)
-        return self._adapter.delete(url)
+        url = '/v1/auth/{0}/role/{1}/secret-id-accessor/destroy'.format(mount_point, role_name)
+        params = {
+            'secret_id_accessor': secret_id_accessor
+        }
+        return self._adapter.post(url, json=params)
 
     def create_role_custom_secret_id(self, role_name, secret_id, meta=None, mount_point='approle'):
         """POST /auth/<mount_point>/role/<role name>/custom-secret-id


Test patch:
diff --git a/tests/unit_tests/v1/test_approle_routes.py b/tests/unit_tests/v1/test_approle_routes.py
index b537fce7d..47242fc1f 100644
--- a/tests/unit_tests/v1/test_approle_routes.py
+++ b/tests/unit_tests/v1/test_approle_routes.py
@@ -465,13 +465,12 @@ def test_delete_role_secret_id(self, test_label, mount_point, role_name, secret_
     def test_delete_role_secret_id_accessor(self, test_label, mount_point, role_name, secret_id_accessor, requests_mocker):
         expected_status_code = 204
 
-        mock_url = 'http://localhost:8200/v1/auth/{0}/role/{1}/secret-id-accessor/{2}'.format(
+        mock_url = 'http://localhost:8200/v1/auth/{0}/role/{1}/secret-id-accessor/destroy'.format(
             'approle' if mount_point is None else mount_point,
             role_name,
-            secret_id_accessor,
         )
         requests_mocker.register_uri(
-            method='DELETE',
+            method='POST',
             url=mock_url,
             status_code=expected_status_code,
         )