mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-24 05:40:23 -07:00
Hana query userstore (#3125)
* add hdbuserstore ability * add description * fix * add default * add description * add sample * Apply suggestions from code review Co-authored-by: quidame <quidame@poivron.org> * add fragment, fix required if * remove whitespace * add coding fragment * Apply suggestions from code review Co-authored-by: Felix Fontein <felix@fontein.de> * added test for userstore * Update plugins/modules/database/saphana/hana_query.py Co-authored-by: Felix Fontein <felix@fontein.de> Co-authored-by: Rainer Leber <rainer.leber@sva.de> Co-authored-by: quidame <quidame@poivron.org> Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
a73720c103
commit
e9494c12f2
3 changed files with 72 additions and 8 deletions
|
@ -64,3 +64,39 @@ class Testhana_query(ModuleTestCase):
|
|||
{'username': 'myuser', 'name': 'my user'},
|
||||
]])
|
||||
self.assertEqual(run_command.call_count, 1)
|
||||
|
||||
def test_hana_userstore_query(self):
|
||||
"""Check that result is processed with userstore."""
|
||||
set_module_args({
|
||||
'sid': "HDB",
|
||||
'instance': "01",
|
||||
'encrypted': False,
|
||||
'host': "localhost",
|
||||
'user': "SYSTEM",
|
||||
'userstore': True,
|
||||
'database': "HDB",
|
||||
'query': "SELECT * FROM users;"
|
||||
})
|
||||
with patch.object(basic.AnsibleModule, 'run_command') as run_command:
|
||||
run_command.return_value = 0, 'username,name\n testuser,test user \n myuser, my user \n', ''
|
||||
with self.assertRaises(AnsibleExitJson) as result:
|
||||
hana_query.main()
|
||||
self.assertEqual(result.exception.args[0]['query_result'], [[
|
||||
{'username': 'testuser', 'name': 'test user'},
|
||||
{'username': 'myuser', 'name': 'my user'},
|
||||
]])
|
||||
self.assertEqual(run_command.call_count, 1)
|
||||
|
||||
def test_hana_failed_no_passwd(self):
|
||||
"""Check that result is failed with no password."""
|
||||
with self.assertRaises(AnsibleFailJson):
|
||||
set_module_args({
|
||||
'sid': "HDB",
|
||||
'instance': "01",
|
||||
'encrypted': False,
|
||||
'host': "localhost",
|
||||
'user': "SYSTEM",
|
||||
'database': "HDB",
|
||||
'query': "SELECT * FROM users;"
|
||||
})
|
||||
self.module.main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue