mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-05-10 00:02:38 +02:00
feat: +unit test
This commit is contained in:
parent
e3dc289e1a
commit
9668a6918f
2 changed files with 105 additions and 14 deletions
37
tests/metagpt/utils/test_hashicorp_vault.py
Normal file
37
tests/metagpt/utils/test_hashicorp_vault.py
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
#!/usr/bin/env python3
|
||||
# _*_ coding: utf-8 _*_
|
||||
import pytest
|
||||
|
||||
from metagpt.utils.hashicorp_vault import HashicorpAuth, HashicorpVaultSecrets
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.parametrize(
|
||||
("root_token", "vault_addr", "user_name", "kvs"),
|
||||
[
|
||||
(
|
||||
"hvs.gMkrxXDhVNkeg4H50Vb9tUeg",
|
||||
"http://127.0.0.1:8200",
|
||||
"a@dafcSSD/a",
|
||||
{"user": "a", "pwd": "a", "ip": "a", "port": "a"},
|
||||
)
|
||||
],
|
||||
)
|
||||
@pytest.mark.skip
|
||||
async def test_vault_secret(root_token, vault_addr, user_name, kvs, context):
|
||||
root_vault = HashicorpVaultSecrets(
|
||||
auth=HashicorpAuth(vault_addr=vault_addr, access_token=root_token), user_name=user_name
|
||||
)
|
||||
user_auth = await root_vault.create_user()
|
||||
user_vault = HashicorpVaultSecrets(
|
||||
auth=user_auth,
|
||||
user_name=user_name,
|
||||
)
|
||||
|
||||
await user_vault.upsert_kv(kvs=kvs, app_name="redis-config")
|
||||
kvs1 = await user_vault.get_kv(app_name="redis-config")
|
||||
assert kvs1 == kvs
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
pytest.main([__file__, "-s"])
|
||||
Loading…
Add table
Add a link
Reference in a new issue