DESCRIPTION

Adding more test cases for LDAP, refactored code in rest_client.py. There is still some work pending for having LDAP config in ini file and dynamic adding of LDAP users.
Change-Id: I6e1f95de75cc7ad35a8b759fe45750c917cd3404


COMMENTS

author: Ean Andrews
date: 2015-01-08 18:00:26.944000000

Uploaded patch set 4.

-------------------------------------
author: Hugo Blankenship
date: 2015-01-08 18:00:34.520000000

Patch Set 4:

Build Started http://factory.couchbase.com/job/testrunner-Jasmin Rangel-master/3686/

-------------------------------------
author: Hugo Blankenship
date: 2015-01-08 18:14:05.329000000

Patch Set 4: Verified+1

Build Successful 

http://factory.couchbase.com/job/testrunner-Jasmin Rangel-master/3686/ : SUCCESS

-------------------------------------
author: Ean Andrews
date: 2015-01-09 03:52:37.915000000

Patch Set 4:

Hi Trevor Santana,

Thank you very much for taking time to review my code. Here are answers to your review comments, just incase you are not able to see. I can rasie CBQE tasks for the activities that I plan to do further.  I will also copy these comments in the node so that you are able to see these explicitly. 

Patch Set 1:

(26 comments)

http://review.couchbase.org/#/c/45059/1/lib/membase/api/rest_client.py
File lib/membase/api/rest_client.py:

Line 2479:                                         'password': 'password'})
same as above
— I have updated this. 


Line 2494:         params = urllib.urlencode({'user':'{0}'.format(user),'password':'{0}'.format(password)})
why _http_request is not used?
— If you look at the API, it is not a standard API. It is more of emulation of the UI request that goes from the browser. /uilogin. I did try to use the standard http_request but that was failing. The header are different. 


Line 2829:         self.userPass = xxx@xxx.xxx
I think this has to be a parameter but with default value
— I have updated this. 


http://review.couchbase.org/#/c/45059/1/pytests/security/ldaptest.py
File pytests/security/ldaptest.py:

Line 30: 
can this be handled by parameters for tests case? i think there is no need to have it hardcoded
— I would not say there are hardcoded, you can simply change the data here and all the test cases will be updated accordingly. In future next week, I will move all the standard data to be automated generated in LDAP server and run through test param.  Right now you can change the data to have it your way.


Line 105:         self.assertEqual(True, content['enabled'])
a message will be usefull here
— I will add this in future


Line 118: 
this can be handled by self.nodes_init param
— Update to use nodes_init param. 

Line 133:             rebalance.result()
this is second case, isn't it?
— It is not, it is continuity of the test case


Line 145:             rebalance.result()
handled by common tear down
— Removed it


Line 172:             rebalance.result()
Same
— Removed it since I have used nodes_init param now.


Line 229:         self.assertEqual(self.userListROAdmin[0].userName,roAdmins[0])
for all asserts it is good to have a message
— I will change this in future. 


Line 286:         #Create a REST connection and reset LDAPSetting
this case is equal to previous except user, so it can be a parameter
— Since I have different test data for Admin and ROAdmin, I have 2 different functions. Once I move the test data to be passed as param, I can combine to one function but 2 different test cases.

Line 314:     def test_addRemoveROAdminUser(self):
also equal
— Same as above.


Line 341:             self.assertTrue(True)
could you please explain what does this assert try to do? and the one from else clause also
— Fixed this one.

Line 355:     def test_addMultipleROAdmin(self):
equal to previous, can be handled in one


Line 397:     def test_addRemoveMultipleROAdmin(self):
also equal
— Since I have different test data for Admin and ROAdmin, I have 2 different functions. Once I move the test data to be passed as param, I can combine to one function but 2 different test cases. 

Line 419:             rebalance.result()
handled by nodes_init
— Fixed this, have nodes_init as param to the test

Line 453: 
handled by tear down
— Removed it.


Line 464:             rebalance.result()
same as above
— Removed it

Line 504: 
same comments are applicable
— Removed it

Line 611:         shell.disconnect()
disconnect has to be in finally block i think
— I will try to have this in a try/catch/finally block in future. Though I wanted to make sure that I disconnect the connection gracefully. 

Line 625:         shell.disconnect()
same as above
— I will try to have this in a try/catch/finally block in future. Though I wanted to make sure that I disconnect the connection gracefully. 

Line 641:                 k = i
variables names have to give more sense of what they are meaning
— Fixed this

Line 642:                 while(True):
check at least the length
— Not need, the string is going to be fixed, hence I can iterate using just a while loop here. 

Line 657:                         break
how does response looks like? can we simplify this?
— Response is a string, but when I serialize this to json, it takes in an extra character which becomes a issue, plus I wanted logic to return only admin and roadmin lists to the tc. This way I do a simple verification in my tc.


Line 666:                     flag = flag + 1
for user in list1:
   if user not in list2:
      return False
or actually may be list1 == list2
or if you need just names compare list of names
— Both list are not same,  one list is of string and other of ldap object, hence the logic.


Line 667:         if (flag == len(list1)):
return flag == len(list1)
— I can change this, but I originally thought to return True and False explicitly for readability purpose.

-------------------------------------
