Merge pull request #154 from fnordahl/add-barbican-vault-tests

Add barbican vault tests
This commit is contained in:
David Ames
2018-11-20 07:41:40 -08:00
committed by GitHub
3 changed files with 85 additions and 2 deletions

View File

@@ -0,0 +1,15 @@
# Copyright 2018 Canonical Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Collection of code for setting up and testing barbican-vault."""

View File

@@ -0,0 +1,33 @@
# Copyright 2018 Canonical Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Encapsulate barbican-vault testing."""
import zaza
import zaza.charm_tests.vault.tests as vault_tests
class BarbicanVaultUnsealVault(vault_tests.UnsealVault):
"""Helper class to unseal Vault and update deploy status expectations."""
@classmethod
def setUpClass(cls):
"""Run setup for UnsealVault class."""
super(BarbicanVaultUnsealVault, cls).setUpClass()
def test_unseal(self):
"""Unseal vault, update barbican-vault deploy status expectations."""
test_config = zaza.charm_lifecycle.utils.get_charm_config()
del test_config['target_deploy_status']['barbican-vault']
super().test_unseal(test_config)

View File

@@ -30,8 +30,8 @@ import zaza.utilities.cert
import zaza.model
class VaultTest(unittest.TestCase):
"""Encapsulate vault tests."""
class BaseVaultTest(unittest.TestCase):
"""Base class for vault tests."""
@classmethod
def setUpClass(cls):
@@ -44,6 +44,41 @@ class VaultTest(unittest.TestCase):
vault_utils.unseal_all(cls.clients, cls.vault_creds['keys'][0])
vault_utils.auth_all(cls.clients, cls.vault_creds['root_token'])
class UnsealVault(BaseVaultTest):
"""Unseal Vault only.
Useful for bootstrapping Vault when it is present in test bundles for other
charms.
"""
@classmethod
def setUpClass(cls):
"""Run setup for UnsealVault class."""
super(UnsealVault, cls).setUpClass()
def test_unseal(self, test_config=None):
"""Unseal Vault.
:param test_config: (Optional) Zaza test config
:type test_config: charm_lifecycle.utils.get_charm_config()
"""
vault_utils.run_charm_authorize(self.vault_creds['root_token'])
if not test_config:
test_config = lifecycle_utils.get_charm_config()
del test_config['target_deploy_status']['vault']
zaza.model.wait_for_application_states(
states=test_config.get('target_deploy_status', {}))
class VaultTest(BaseVaultTest):
"""Encapsulate vault tests."""
@classmethod
def setUpClass(cls):
"""Run setup for Vault tests."""
super(VaultTest, cls).setUpClass()
def test_csr(self):
"""Test generating a csr and uploading a signed certificate."""
vault_actions = zaza.model.get_actions(