DESCRIPTION

CBQE-3940- Add support for rbac username/pass for memacached client.
1. Changed direct_client and addmemcached to take user/pass for rbac
2. Added fixed RBAC user in basetest and other tests for tests to run

Link to Sanity test passing from my private repo:
http://qa.sc.couchbase.com/job/cen006-p0-sanit-vset01-00/2496/
http://qa.sc.couchbase.com/job/cen006-p0-sanit-vset01-01/749/

Change-Id: I3f2f8c74aa8492a45b8aac042b5bd21296a64371


COMMENTS

author: Ean Andrews
date: 2017-03-06 10:39:34.935000000

Uploaded patch set 5.

-------------------------------------
author: Titus Ho
date: 2017-03-06 15:08:11.968000000

Patch Set 5:

Hi Ritam,

Thanks for your work here. My only recommendation is more of design rather than correctness, as I prefer we make the user/pass a part of the Bucket object:
https://github.com/couchbase/testrunner/blob/master/lib/membase/api/rest_client.py#L3711

This way when we init a Bucket object then we can create the user needed to do loading into that bucket in a single place and pass that bucket around to various methods with assurance that it's user exists.  Then on teardown we can loop through all our bucket objects and delete any users associated with them.

You will notice too we already have checks wether or not we are passing bucket around as string or object - so it seems like using more of an object approach will not require much change...
https://github.com/couchbase/testrunner/blob/master/lib/memcached/helper/data_helper.py#L735

-------------------------------------
author: Ean Andrews
date: 2017-03-06 16:35:17.451000000

Patch Set 5:

Hi Tommie,

a) The change is mainly for data port at 11210.  For Rest API, we allow passing of username and password in the rest API, and primarily Administrator/password; except for RBAC tests that I have.  Right now there is a defect where if bucket name is equal to the username, things will fail. There is another code change pending that I am testing against. This fix is to get rid of error authentication at port 11210. Next change will have this fixed and that is what I will be doing, having a username == bucket_name, and have it propagated correctly. 

b) Unfortunately we don't have a strong encapsulation in our code, n1ql called data_client from bucket information from rest api. Just to be safe I have decoded bucket name to ascii

-------------------------------------
author: Titus Ho
date: 2017-03-06 16:47:15.244000000

Patch Set 5:

This fix does more than get rid of error authentication -- it actually *adds* a fundamental change to the framework regarding how we do authentication.   Furthermore, this change is also a workaround for broken code in server.  Ideally, you should push what *should* work, then push the workaround if necessary and later revert that.

I'm saying this because your suggestion to propagate username as bucket_name presents an even stronger case to couple rbac user/pass with Bucket object.

Again, this is me *looking* at code.  You're doing the lifting, )

-------------------------------------
author: Ean Andrews
date: 2017-03-06 16:56:28.590000000

Patch Set 5:

Tommie, all of tests are running with Administrator user. Current changes are only for memcached, and these are the places were memached are hit. There are going to be specific test cases for RBAC for kv + n1ql + fts + tools. All of these layers have their own implementation for different roles for user actions. I would like to have specific tests around each component for each role and permission set.

-------------------------------------
author: Ean Andrews
date: 2017-03-06 16:57:25.855000000

Patch Set 5:

The code is not broken in server, but only available for memached authentication.

-------------------------------------
author: Titus Ho
date: 2017-03-06 17:00:53.900000000

Patch Set 5:

I understand everything you're saying.  All I've suggested is *where* we store username/pass going forward.  Instead of passing separately into static methods, they could be encapsulated in bucket object

-------------------------------------
author: Ean Andrews
date: 2017-03-06 17:28:08.552000000

Patch Set 5:

I agree to that Tommie, next change in ns_server will be best place for encapsulation.
Thank You

-------------------------------------
author: Ezekiel Beck
date: 2017-03-06 18:56:36.852000000

Patch Set 5: Code-Review+1

-------------------------------------
author: Ezekiel Beck
date: 2017-03-06 18:56:47.216000000

Patch Set 5: Code-Review+2

-------------------------------------
author: Ean Andrews
date: 2017-03-07 02:13:53.523000000

Patch Set 5: Verified+1

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