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>
This commit is contained in:
Emilien Escalle 2024-02-25 19:44:37 +01:00 committed by GitHub
commit 6cafd3bed7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 45 additions and 0 deletions

View file

@ -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)