summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBala Konda Reddy M <bala12352@gmail.com>2020-10-13 18:20:47 +0530
committerVaibhav Mahajan <vamahaja@redhat.com>2020-11-05 12:16:54 +0000
commita7e66b9910a0abd0c6af8099aa42e0088cb26c7a (patch)
tree835df5fb91c2deec2e58184483046d47aba50344
parent2c7908c6be8184617f7046bc08a54b54512fed3e (diff)
[Test] Add test for heketi authentication
Change-Id: I2dc817dafffa6c313d24fdd11014dc3f3e203aa8 Signed-off-by: Bala Konda Reddy M <bala12352@gmail.com>
-rw-r--r--tests/functional/heketi/test_heketi_authentication.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/functional/heketi/test_heketi_authentication.py b/tests/functional/heketi/test_heketi_authentication.py
new file mode 100644
index 0000000..5979c80
--- /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)