Skip to content

Commit

Permalink
Add token enterprise-only test case
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeffrey Hogan committed Jul 7, 2019
1 parent f14caac commit 2e5839b
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
6 changes: 5 additions & 1 deletion hvac/api/system_backend/__init__.py
Expand Up @@ -10,6 +10,7 @@
from hvac.api.system_backend.leader import Leader
from hvac.api.system_backend.lease import Lease
from hvac.api.system_backend.mount import Mount
from hvac.api.system_backend.namespace import Namespace
from hvac.api.system_backend.policy import Policy
from hvac.api.system_backend.seal import Seal
from hvac.api.system_backend.wrapping import Wrapping
Expand All @@ -26,6 +27,7 @@
'Leader',
'Lease',
'Mount',
'Namespace',
'Policy',
'Seal',
'SystemBackend',
Expand All @@ -37,7 +39,8 @@
logger = logging.getLogger(__name__)


class SystemBackend(VaultApiCategory, Audit, Auth, Capabilities, Health, Init, Key, Leader, Lease, Mount, Policy, Seal, Wrapping):
class SystemBackend(VaultApiCategory, Audit, Auth, Capabilities, Health, Init, Key, Leader, Lease, Mount, Namespace,
Policy, Seal, Wrapping):
implemented_classes = [
Audit,
Auth,
Expand All @@ -48,6 +51,7 @@ class SystemBackend(VaultApiCategory, Audit, Auth, Capabilities, Health, Init, K
Leader,
Lease,
Mount,
Namespace,
Policy,
Seal,
Wrapping,
Expand Down
19 changes: 19 additions & 0 deletions hvac/api/system_backend/namespace.py
@@ -0,0 +1,19 @@
from hvac.api.system_backend.system_backend_mixin import SystemBackendMixin


class Namespace(SystemBackendMixin):

def list_namespaces(self):
"""Lists all the namespaces.
Supported methods:
LIST: /sys/namespaces. Produces: 200 application/json
:return: The JSON response of the request.
:rtype: dict
"""
api_path = '/v1/sys/namespaces/'
response = self._adapter.list(
url=api_path,
)
return response.json()
19 changes: 19 additions & 0 deletions tests/integration_tests/api/system_backend/test_namespace.py
@@ -0,0 +1,19 @@
import logging
from unittest import TestCase, skipIf

from tests import utils
from tests.utils.hvac_integration_test_case import HvacIntegrationTestCase


@skipIf(not utils.is_enterprise(), "Namespaces only supported with Enterprise Vault")
class TestNamespace(HvacIntegrationTestCase, TestCase):

def test_list_namespaces(self):

# List the lease of our test cert that was just issued.
list_namespaces_response = self.client.sys.list_namespaces()
logging.debug('list_namespaces_response: %s' % list_namespaces_response)
self.assertIsInstance(
obj=list_namespaces_response,
cls=list,
)

0 comments on commit 2e5839b

Please sign in to comment.