From a0b128a381aa3f97073779206ed67e03cc2b33fe Mon Sep 17 00:00:00 2001 From: thuva4 Date: Thu, 8 Mar 2018 13:56:20 +0530 Subject: Do not need to check if user has existing session We are currently checking no matter user has a session or not.Fix it. Current implemetation don't allow user to use existing session. Fix it. Change-Id: I5c1bf2bf9b3475f4723d7e136a60effd4287199d Signed-off-by: thuva4 --- testapi/testapi-client/testapiclient/identity.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'testapi') diff --git a/testapi/testapi-client/testapiclient/identity.py b/testapi/testapi-client/testapiclient/identity.py index 03b3ac5..f38d8e1 100644 --- a/testapi/testapi-client/testapiclient/identity.py +++ b/testapi/testapi-client/testapiclient/identity.py @@ -17,19 +17,21 @@ def _authenticate(username, password): 'form_id': 'user_login' } response = session.post(hostname, data) - user.User.session = session + if "login" not in response.text: + user.User.session = session return response def authenticate(xstep): @functools.wraps(xstep) def wrapper(self, parsed_args): - username = parsed_args.u - password = parsed_args.p - if(username and password): - response = _authenticate(username, password) - if "login" in response.text: - print "Authentication has failed." - else: - xstep(self, parsed_args) + if(user.User.session is None): + username = parsed_args.u + password = parsed_args.p + if(username and password): + response = _authenticate(username, password) + if "login" in response.text: + print "Authentication has failed." + return + xstep(self, parsed_args) return wrapper -- cgit 1.2.3-korg