summaryrefslogtreecommitdiffstats
path: root/test/functional_auth/gswauth
diff options
context:
space:
mode:
authorThiago da Silva <thiago@redhat.com>2013-12-04 18:12:12 -0500
committerChetan Risbud <crisbud@redhat.com>2014-01-14 23:06:44 -0800
commitbf643c49164d291d25f4f86d32efd7aa2000272e (patch)
tree233e512a4fd34d3948dd82af9da024b945e1950d /test/functional_auth/gswauth
parent41c7bbcc74b64babefa0455917cbd04c89b9c94d (diff)
fix error handing in swauth tools
The swauth tools did not handle an invalid admin_url, so it just failed printing the stacktrace, which is not useful to end users. This fix catches the exception and prints an error message that can help user solve the issue. Change-Id: I806c1cf191b5921e904b155f65cdbde5f2aac695 Signed-off-by: Thiago da Silva <thiago@redhat.com> Reviewed-on: http://review.gluster.org/6431 Reviewed-by: Luis Pabon <lpabon@redhat.com> Tested-by: Luis Pabon <lpabon@redhat.com> Reviewed-on: http://review.gluster.org/6707 Reviewed-by: Chetan Risbud <crisbud@redhat.com> Tested-by: Chetan Risbud <crisbud@redhat.com>
Diffstat (limited to 'test/functional_auth/gswauth')
-rw-r--r--test/functional_auth/gswauth/test_gswauth_cli.py53
1 files changed, 48 insertions, 5 deletions
diff --git a/test/functional_auth/gswauth/test_gswauth_cli.py b/test/functional_auth/gswauth/test_gswauth_cli.py
index e228f31..29a48b3 100644
--- a/test/functional_auth/gswauth/test_gswauth_cli.py
+++ b/test/functional_auth/gswauth/test_gswauth_cli.py
@@ -124,6 +124,14 @@ class TestSwauthPrep(unittest.TestCase):
self.assertNotEqual(status, 0, 'Invalid swauth-prep request accepted(wrong key provided):'+output)
self.assertEqual('gswauth preparation failed: 401 Unauthorized: Invalid user/key provided' \
in output,True, 'Invalid swauth-prep request accepted: '+output)
+
+ (status,output)=Utils.swauthPrep(authurl='http://127.0.0.1:80/auth/')
+ self.assertEqual('ECONNREFUSED' in output, True,
+ 'Invalid swauth-prep request accepted(wrong admin-url provided): %s' % output)
+
+ (status,output)=Utils.swauthPrep(authurl='http://127.0.1:80/auth/')
+ self.assertEqual('No address associated with hostname' in output, True,
+ 'Invalid swauth-prep request accepted(wrong admin-url provided): %s' % output)
#TODO:More cases for invalid url and admin user
def testAddAccountWithoutSwauthPrep(self):
@@ -176,8 +184,15 @@ class TestAccount(unittest.TestCase):
(status,output)=Utils.addAccount('testinvalidkey',key='invalidkey')
self.assertEqual('Account creation failed: 401 Unauthorized: Invalid user/key provided' \
- in output,True, 'Invalid account creation request accepted: '+output)
- #TODO:more cases?
+ in output,True, 'Invalid account creation request accepted: '+output)
+
+ (status,output)=Utils.addAccount('test2', authurl='http://127.0.0.1:80/auth/')
+ self.assertEqual('ECONNREFUSED' in output, True,
+ 'Invalid account creation request accepted(wrong admin-url provided): %s' % output)
+
+ (status,output)=Utils.addAccount('test2', authurl='http://127.0.1:80/auth/')
+ self.assertEqual('No address associated with hostname' in output, True,
+ 'Invalid account creation request accepted(wrong admin-url provided): %s' % output)
def testAddAccountNonSuperAdminUsers(self):
#set test account with all types of user
@@ -229,7 +244,14 @@ class TestAccount(unittest.TestCase):
(status,output)=Utils.deleteAccount('accountdoesnotexist')
self.assertNotEqual(status, 0, 'account deletion failed for accountdoesnotexist'+output)
self.assertEqual('Delete account failed: 404 Not Found: Account accountdoesnotexist does not exist' in output,True, 'account deletion failed for test account'+output)
- #TODO:more cases
+
+ (status,output)=Utils.deleteAccount('test3', authurl='http://127.0.0.1:80/auth/')
+ self.assertEqual('ECONNREFUSED' in output, True,
+ 'Invalid deletion request accepted(wrong admin-url provided): %s' % output)
+
+ (status,output)=Utils.deleteAccount('test3', authurl='http://127.0.1:80/auth/')
+ self.assertEqual('No address associated with hostname' in output, True,
+ 'Invalid deletion request accepted(wrong admin-url provided): %s' % output)
def testDeleteAccountNonSuperAdminUsers(self):
#set test account with all types of user
@@ -264,6 +286,14 @@ class TestAccount(unittest.TestCase):
'+----------+\n| Accounts |\n+----------+\n| test |\n+----------+',
'swauth-list failed:\n%s' % output)
+ (status,output)=Utils.listAccounts(authurl='http://127.0.0.1:80/auth/')
+ self.assertEqual('ECONNREFUSED' in output, True,
+ 'Invalid list request accepted(wrong admin-url provided): %s' % output)
+
+ (status,output)=Utils.listAccounts(authurl='http://127.0.1:80/auth/')
+ self.assertEqual('No address associated with hostname' in output, True,
+ 'Invalid list request accepted(wrong admin-url provided): %s' % output)
+
(status,output)=Utils.listAccounts('-j')
self.assertEqual(output,
'{"accounts": [{"name": "test"}]}',
@@ -293,7 +323,6 @@ class TestAccount(unittest.TestCase):
self.assertNotEqual(status, 0, 'account listing success with regular user: '+output)
self.assertEqual('403 Forbidden' in output,True, 'account listing success with regular user: '+output)
-
class TestUser(unittest.TestCase):
def setUp(self):
@@ -348,7 +377,14 @@ class TestUser(unittest.TestCase):
(status,output) = Utils.addAdminUser('accountdoesnotexist', 'testcli', 'testcli')
self.assertEqual(status, 0, 'User creation request failed, where accountdoesnotexist: '+output)
- #TODO: more test cases?
+
+ (status,output)=Utils.addAdminUser('test', 'admin2', 'adminpwd', authurl='http://127.0.0.1:80/auth/')
+ self.assertEqual('ECONNREFUSED' in output, True,
+ 'Invalid add user request accepted(wrong admin-url provided): %s' % output)
+
+ (status,output)=Utils.addAdminUser('test', 'admin2', 'adminpwd', authurl='http://127.0.1:80/auth/')
+ self.assertEqual('No address associated with hostname' in output, True,
+ 'Invalid add user request accepted(wrong admin-url provided): %s' % output)
def testAddUserNonSuperAdminUsers (self):
#setup test,testr accounts with all user types
@@ -463,6 +499,13 @@ class TestUser(unittest.TestCase):
(status,output) = Utils.deleteUser('accountisnothere', 'testcli')
self.assertNotEqual(status, 0, 'Invalid user deletion request accepted, accountdoesnotexist:'+output)
#TODO:more testcases?
+ (status,output)=Utils.deleteUser('test', 'admin2', authurl='http://127.0.0.1:80/auth/')
+ self.assertEqual('ECONNREFUSED' in output, True,
+ 'Invalid delete user request accepted(wrong admin-url provided): %s' % output)
+
+ (status,output)=Utils.deleteUser('test', 'admin2', authurl='http://127.0.1:80/auth/')
+ self.assertEqual('No address associated with hostname' in output, True,
+ 'Invalid delete user request accepted(wrong admin-url provided): %s' % output)
def testDeleteUserNonSuperAdminUsers(self):