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:
rainerleber 2021-08-05 22:42:43 +02:00 committed by GitHub
commit e9494c12f2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 72 additions and 8 deletions

View file

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