mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-08-14 10:01:43 -07:00
[PR #7994/6cafd3be backport][stable-8] feat(lookup/bitwarden): add support for "session" arg (#8030)
feat(lookup/bitwarden): add support for "session" arg (#7994)
Allows pass session key instead of reading from env.
Signed-off-by: Emilien Escalle <emilien.escalle@escemi.com>
(cherry picked from commit 6cafd3bed7
)
Co-authored-by: Emilien Escalle <neilime@users.noreply.github.com>
This commit is contained in:
parent
755ee2b4d0
commit
9a7a0ca526
3 changed files with 45 additions and 0 deletions
|
@ -158,3 +158,23 @@ class TestLookupModule(unittest.TestCase):
|
|||
record_name = record['name']
|
||||
with self.assertRaises(AnsibleError):
|
||||
self.lookup.run([record_name], field='password')
|
||||
|
||||
def test_bitwarden_plugin_without_session_option(self):
|
||||
mock_bitwarden = MockBitwarden()
|
||||
with patch("ansible_collections.community.general.plugins.lookup.bitwarden._bitwarden", mock_bitwarden):
|
||||
record = MOCK_RECORDS[0]
|
||||
record_name = record['name']
|
||||
session = 'session'
|
||||
|
||||
self.lookup.run([record_name], field=None)
|
||||
self.assertIsNone(mock_bitwarden.session)
|
||||
|
||||
def test_bitwarden_plugin_session_option(self):
|
||||
mock_bitwarden = MockBitwarden()
|
||||
with patch("ansible_collections.community.general.plugins.lookup.bitwarden._bitwarden", mock_bitwarden):
|
||||
record = MOCK_RECORDS[0]
|
||||
record_name = record['name']
|
||||
session = 'session'
|
||||
|
||||
self.lookup.run([record_name], field=None, bw_session=session)
|
||||
self.assertEqual(mock_bitwarden.session, session)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue