From a7e66b9910a0abd0c6af8099aa42e0088cb26c7a Mon Sep 17 00:00:00 2001 From: Bala Konda Reddy M Date: Tue, 13 Oct 2020 18:20:47 +0530 Subject: [Test] Add test for heketi authentication Change-Id: I2dc817dafffa6c313d24fdd11014dc3f3e203aa8 Signed-off-by: Bala Konda Reddy M --- .../heketi/test_heketi_authentication.py | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 tests/functional/heketi/test_heketi_authentication.py (limited to 'tests/functional/heketi/test_heketi_authentication.py') diff --git a/tests/functional/heketi/test_heketi_authentication.py b/tests/functional/heketi/test_heketi_authentication.py new file mode 100644 index 00000000..5979c808 --- /dev/null +++ b/tests/functional/heketi/test_heketi_authentication.py @@ -0,0 +1,33 @@ +from glusto.core import Glusto as g +import pytest + +from openshiftstoragelibs import baseclass +from openshiftstoragelibs import heketi_ops + + +class TestHeketiAuthenticationFromOCPClient(baseclass.BaseClass): + """Class to test heketi-client authentication""" + + @pytest.mark.tier1 + def test_heketi_authentication_with_user_credentials(self): + """Heketi command authentication with invalid and valid credentials""" + + h_client, h_server = self.heketi_client_node, self.heketi_server_url + err_msg = "Error: Invalid JWT token: Token missing iss claim" + + # Run heketi commands with invalid credentials + for each_cmd in ("volume list", "topology info"): + cmd = "timeout 120 heketi-cli -s {} {}".format( + self.heketi_server_url, each_cmd) + ret, _, err = g.run(h_client, cmd) + self.assertTrue(ret, "Command execution with invalid credentials" + " should not succeed") + self.assertEqual( + err_msg, err.strip(), "Error is different from the command" + " execution {}".format(err.strip())) + + # Run heketi commands with valid credentials + kwar = {'json_arg': True, 'secret': self.heketi_cli_key, + 'user': self.heketi_cli_user} + heketi_ops.heketi_volume_list(h_client, h_server, **kwar) + heketi_ops.heketi_topology_info(h_client, h_server, **kwar) -- cgit