Commit Graph

17 Commits

Author SHA1 Message Date
Hervé Beraud b74404f536 Use unittest.mock instead of mock
The mock third party library was needed for mock support in py2
runtimes. Since we now only support py36 and later, we can use the
standard lib unittest.mock module instead.

Note that https://github.com/openstack/charms.openstack is used during tests
and he need `mock`, unfortunatelly it doesn't declare `mock` in its
requirements so it retrieve mock from other charm project (cross dependency).
So we depend on charms.openstack first and when
Ib1ed5b598a52375e29e247db9ab4786df5b6d142 will be merged then CI
will pass without errors.

Depends-On: Ib1ed5b598a52375e29e247db9ab4786df5b6d142
Change-Id: I2570caf6f292b2dd152f7c229be6651978f80bff
2021-12-15 11:10:19 +00:00
Liam Young 26ba0535ef Retrieve approle_secret_id from correct relation
The existing comment in the code expresses the correct intent:
"fetch current secret-id, if any, from relation with barbican principle"
but then attempts to retrieve the secret-id from the vault
relation.

Change-Id: Ie2694ba38e08fd9e864bf9d8fa0b63f0e185b8bd
Closes-Bug: #1871981
2020-12-17 19:57:56 +00:00
Hervé Beraud 31952dbc6f Stop to use the __future__ module.
The __future__ module [1] was used in this context to ensure compatibility
between python 2 and python 3.

We previously dropped the support of python 2.7 [2] and now we only support
python 3 so we don't need to continue to use this module and the imports
listed below.

Imports commonly used and their related PEPs:
- `division` is related to PEP 238 [3]
- `print_function` is related to PEP 3105 [4]
- `unicode_literals` is related to PEP 3112 [5]
- `with_statement` is related to PEP 343 [6]
- `absolute_import` is related to PEP 328 [7]

[1] https://docs.python.org/3/library/__future__.html
[2] https://governance.openstack.org/tc/goals/selected/ussuri/drop-py27.html
[3] https://www.python.org/dev/peps/pep-0238
[4] https://www.python.org/dev/peps/pep-3105
[5] https://www.python.org/dev/peps/pep-3112
[6] https://www.python.org/dev/peps/pep-0343
[7] https://www.python.org/dev/peps/pep-0328

Change-Id: I3d9f56f908d58acc35d12abb66a95aa42b35cae7
2020-06-02 19:37:21 +02:00
David Ames f6546dda33 More robust hvac.Client post response handling
Pin the version of hvac for a consistent response type. Use the adpater
to get response code and json data.

Closes Bug: #1871981
Change-Id: Ia8517a75e7bc20f751eca83aaa84728cc62edee6
2020-04-29 12:16:22 -07:00
David Ames 4e1c539eaf Change in hvac.Client post response type
The hvac.Client post response is no longer an object with status_code and json
encoded data. It is a dictionary.

Change-Id: I1cacc8deda005cdbb2290d5ae821e4870608a41a
2020-04-24 21:37:21 +00:00
Frode Nordahl e23f232a68
Use system CA bundle when verifying Vault certificate
Change-Id: I39d761dfbe1500f06abd617dd97eced671971b7d
Closes-Bug: #1859092
2020-01-13 21:16:20 +01:00
Edward Hope-Morley 4a1517d2fb Support trying all available tokens
Since the relation with vault maybe contain more than one
token and we have no way to know if they are valid, we
support trying them all until we get a good one and raise
the error only if we tried them all unsuccessfully and
have no current secret-id otherwise return current
secret-id.

Change-Id: I2ee5ffe5d53e874efb3fabc6a880bf95b00a44f9
Partial-Bug: #1849323
2019-12-11 14:36:33 +00:00
Frode Nordahl 179ddd9618
Fix unit test 2018-11-09 12:05:38 +01:00
Frode Nordahl 7d763f717d
Update unit tests for ``install_ca_cert`` 2018-10-24 10:05:27 +02:00
Frode Nordahl 63af9a89b3
Handle SSL 2018-10-22 16:21:24 +02:00
Frode Nordahl f5db4bff62
Request initial token from vault only once 2018-10-22 15:15:58 +02:00
Frode Nordahl ba617f0672
Add missing check in unit test 2018-10-22 14:37:05 +02:00
Frode Nordahl 5ee8482fdc
Ensure handler fires only when data is changed
At present the charm will attempt to request a one-shot token
multiple times which leads to hook errors.
2018-10-22 14:10:19 +02:00
Frode Nordahl dd1df7a42b
Retrieve secret-id from vault using one-shot token 2018-10-19 14:42:38 +02:00
Frode Nordahl 449b85d0b5
Add ``kv_mountpoint`` to plugin configuration
Use bus for auto-loading charm modules instead of import.
2018-10-19 10:08:03 +02:00
Frode Nordahl bdcf367efc
Add barbican-vault charm code and unit tests 2018-10-17 16:52:15 +02:00
Frode Nordahl 3c85a815a2
Initial commit of charm skeleton 2018-10-11 11:31:52 +02:00