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 08:35:46.832000000

Uploaded patch set 1.

-------------------------------------
author: Hugo Blankenship
date: 2015-01-08 08:35:54.659000000

Patch Set 1:

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

-------------------------------------
author: Hugo Blankenship
date: 2015-01-08 08:49:54.805000000

Patch Set 1: Verified+1

Build Successful 

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

-------------------------------------
author: Trevor Santana
date: 2015-01-08 10:53:40.033000000

Patch Set 1:

(26 comments)

Line:30, pytests/security/ldaptest.py -> can this be handled by parameters for tests case? i think there is no need to have it hardcoded

Line:105, pytests/security/ldaptest.py -> a message will be usefull here

Line:118, pytests/security/ldaptest.py -> this can be handled by self.nodes_init param

Line:133, pytests/security/ldaptest.py -> this is second case, isn't it?

Line:145, pytests/security/ldaptest.py -> handled by common tear down

Line:172, pytests/security/ldaptest.py -> same

Line:229, pytests/security/ldaptest.py -> for all asserts it is good to have a message

Line:286, pytests/security/ldaptest.py -> this case is equal to previous except user, so it can be a parameter

Line:314, pytests/security/ldaptest.py -> also equal

Line:341, pytests/security/ldaptest.py -> could you please explain what does this assert try to do? and the one from else clause also

Line:355, pytests/security/ldaptest.py -> equal to previous, can be handled in one

Line:397, pytests/security/ldaptest.py -> also equal

Line:419, pytests/security/ldaptest.py -> handled by nodes_init

Line:453, pytests/security/ldaptest.py -> handled by tear down

Line:464, pytests/security/ldaptest.py -> same as above

Line:504, pytests/security/ldaptest.py -> same comments are applicable

Line:611, pytests/security/ldaptest.py -> disconnect has to be in finally block i think

Line:625, pytests/security/ldaptest.py -> same as above

Line:641, pytests/security/ldaptest.py -> variables names have to give more sense of what they are meaning

Line:642, pytests/security/ldaptest.py -> check at least the length

Line:657, pytests/security/ldaptest.py -> how does response looks like? can we simplify this?

Line:666, pytests/security/ldaptest.py -> 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

Line:667, pytests/security/ldaptest.py -> return flag == len(list1)

Line:2479, lib/membase/api/rest_client.py -> same as above

Line:2494, lib/membase/api/rest_client.py -> why _http_request is not used?

Line:2829, lib/membase/api/rest_client.py -> I think this has to be a parameter but with default value

-------------------------------------
author: Ean Andrews
date: 2015-01-09 03:58:52.914000000

Patch Set 1:

(23 comments)

Line:30, pytests/security/ldaptest.py -> I would not say these 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.

I have done this on purpose, since I wanted the test data to be on the top and all test cases using it. My ldap server currently is pre-populated with these users. In future I can move this code to create as part of setup. I would not count this as hardcoding, since if I have to change the test data, I can change it here. This will be done later as I pass arguments to function of which datatype to use. Another way to have the data would be in a file and then I can use parameters for the data load.

Line:105, pytests/security/ldaptest.py -> I can add message in next version that I check-in

Line:118, pytests/security/ldaptest.py -> Done

Line:133, pytests/security/ldaptest.py -> No it is not second test case, it is part of the same test case. Want to check that once the node comes out of the cluster it does not carry settings of the cluster.
No changes for this piece of code

Line:145, pytests/security/ldaptest.py -> Done

Line:172, pytests/security/ldaptest.py -> Done

Line:286, pytests/security/ldaptest.py -> Done

Line:341, pytests/security/ldaptest.py -> Just checks for multiple users added to the LDAPAuth or not. I got what you are saying. I will update this.

Line:355, pytests/security/ldaptest.py -> I would like to have it different, since the test data resides in the class itself. I need to figure out how do pass an object as parameters from conf file.

Line:397, pytests/security/ldaptest.py -> Done

Line:419, pytests/security/ldaptest.py -> Done

Line:453, pytests/security/ldaptest.py -> Done

Line:464, pytests/security/ldaptest.py -> Done

Line:504, pytests/security/ldaptest.py -> Done

Line:611, pytests/security/ldaptest.py -> Does not need a finally block here. I will have to use try/catch/finally block. This is simply closing the connection

Line:625, pytests/security/ldaptest.py -> Does not need a finally block here. I will have to use try/catch/finally block. This is simply closing the connection

Line:641, pytests/security/ldaptest.py -> Done

Line:642, pytests/security/ldaptest.py -> The response is a string and I split it based on the stuff and I don't use entire length. Reason for using while is because the string comes in a specified format. There is not need to check for length of string.

Line:657, pytests/security/ldaptest.py -> The response is a string, if you look at the API, it is not the standard API. it is something that I have tried to get from firebug. When I convert it to son, I get a unicode character and I wanted to return a  list of admin and ROAdmin for my code to handler single and multiple users.

Line:666, pytests/security/ldaptest.py -> Sorry, but list1 and list2 are different kinds of list. list1 is list of string and list2 is a list of object that has an attribute userName. so I will have iterate both the list to compare them. From your comments i could have used a different iteration for lists.

Line:2479, lib/membase/api/rest_client.py -> I wanted to have the actual command different. Things are in flux, might change in future.
Fixed username and password.

Line:2494, lib/membase/api/rest_client.py -> I saw some issues with specific header that I have been using, since this is not a plain api, it is more an emulation of form submission from UI. I tried using the default one as used above, but it is not work.

Line:2829, lib/membase/api/rest_client.py -> Fixed.

-------------------------------------
author: Trevor Santana
date: 2015-01-09 06:46:47.663000000

Patch Set 1:

(6 comments)

Line:355, pytests/security/ldaptest.py -> at least do a common function with steps, right now it looks like copy paste

Line:397, pytests/security/ldaptest.py -> at least do a common function with steps, right now it looks like copy paste

Line:611, pytests/security/ldaptest.py -> in your case if you have an exception it won't be disconnected and connection will be kept alive

Line:625, pytests/security/ldaptest.py -> in your case if you have an exception it won't be disconnected and connection will be kept alive

Line:666, pytests/security/ldaptest.py -> list2_usernames = [user.userName for user in list2]
list1 == list2_usernames

Line:667, pytests/security/ldaptest.py -> less code is more readable, but is up to you

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