Debian Codegraph @

ansible_collections/community/general/tests/unit/plugins/lookup/test_revbitspss.py

raw
1 # Copyright (c) 2021, RevBits <[email protected]>
2 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
3 # SPDX-License-Identifier: GPL-3.0-or-later
4 from __future__ import annotations
5
6 from unittest import TestCase
7 from unittest.mock import (
8 MagicMock,
9 patch,
10 )
11
12 from ansible.plugins.loader import lookup_loader
13
14 from ansible_collections.community.general.plugins.lookup import revbitspss
15
16
17 class MockPamSecrets(MagicMock):
18 RESPONSE = "dummy value"
19
20 def get_pam_secret(self, path):
21 return self.RESPONSE
22
23
24 class TestLookupModule(TestCase):
25 def setUp(self):
26 revbitspss.ANOTHER_LIBRARY_IMPORT_ERROR = None
27 self.lookup = lookup_loader.get("community.general.revbitspss")
28
29 @patch(
30 "ansible_collections.community.general.plugins.lookup.revbitspss.LookupModule.Client",
31 MockPamSecrets(),
32 )
33 def test_get_pam_secret(self):
34 terms = ["dummy secret"]
35 variables = []
36 kwargs = {"base_url": "https://dummy.url", "api_key": "dummy"}
37 self.assertListEqual([{"dummy secret": "dummy value"}], self.lookup.run(terms, variables, **kwargs))