anchor.diff:      set_config("couchdb_peruser", "enable", "false"),
       create_user(TestAuthDb, User),
       ?_assert(not lists:member(UserDbName, all_dbs())).
  +
  +should_assign_user_to_db_admins(TestAuthDb) ->
  +    User = "qux",
  +    UserDbName = <<"userdb-717578">>,
  +    create_user(TestAuthDb, User),
  +    ?_assertEqual(
  +        {[{<<"names">>,[<<"qux">>]}]},
  +        proplists:get_value(<<"admins">>, get_security(UserDbName))).
  +
  +should_assign_user_to_db_members(TestAuthDb) ->
  +    User = "qux",
  +    UserDbName = <<"userdb-717578">>,
  +    create_user(TestAuthDb, User),
  +    ?_assertEqual(
  +        {[{<<"names">>,[<<"qux">>]}]},
  +        proplists:get_value(<<"members">>, get_security(UserDbName))).
  +
  +should_not_remove_existing_db_admins(TestAuthDb) ->
  +    User = "qux",
  +    UserDbName = <<"userdb-717578">>,
  +    SecurityProperties = [
  +        {<<"admins">>,{[{<<"names">>,[<<"foo">>,<<"bar">>]}]}},
  +        {<<"members">>,{[{<<"names">>,[<<"baz">>,<<"pow">>]}]}}
  +    ],
  +    create_db(UserDbName),
  +    set_security(UserDbName, SecurityProperties),
  +    create_user(TestAuthDb, User),
  +    {AdminProperties} = proplists:get_value(<<"admins">>,
  +        get_security(UserDbName)),
  +    AdminNames = proplists:get_value(<<"names">>, AdminProperties),
  +    ?_assert(lists:member(<<"foo">>, AdminNames)),
  +    ?_assert(lists:member(<<"bar">>, AdminNames)),
  +    ?_assert(lists:member(<<"qux">>, AdminNames)).
  +
  +should_not_remove_existing_db_members(TestAuthDb) ->
  +    User = "qux",
  +    UserDbName = <<"userdb-717578">>,
  +    SecurityProperties = [
  +        {<<"admins">>,{[{<<"names">>,[<<"pow">>,<<"wow">>]}]}},
  +        {<<"members">>,{[{<<"names">>,[<<"pow">>,<<"wow">>]}]}}
  +    ],
  +    create_db(UserDbName),
  +    set_security(UserDbName, SecurityProperties),
  +    create_user(TestAuthDb, User),
  +    {MemberProperties} = proplists:get_value(<<"members">>,
  +        get_security(UserDbName)),
  +    MemberNames = proplists:get_value(<<"names">>, MemberProperties),
  +    ?_assert(lists:member(<<"pow">>, MemberNames)),
  +    ?_assert(lists:member(<<"wow">>, MemberNames)),
  +    ?_assert(lists:member(<<"qux">>, MemberNames)).
   
   couchdb_peruser_test_() ->
       {
  
positive.code:                     fun should_create_user_db/1,
                      fun should_not_delete_user_db/1,
                      fun should_delete_user_db/1,
                      fun should_reflect_config_changes/1
                  ]
              }
          }
  
negative.code:     Rev = proplists:get_value(<<"_rev">>, DocProps),
      {ok, 200, _, _} = do_request(delete, Url ++ "?rev=" ++ ?b2l(Rev)),
      % let's proceed after giving couchdb_peruser some time to delete the user db
      timer:sleep(1000).
  
  get_security(DbName) ->
      Url = lists:concat([
          get_cluster_base_url(), "/", ?b2l(DbName), "/_security"]),
      {ok, 200, _, Body} = do_request(get, Url),
      {SecurityProperties} = jiffy:decode(Body),
      SecurityProperties.
  
  set_security(DbName, SecurityProperties) ->
      Url = lists:concat([
          get_cluster_base_url(), "/", ?b2l(DbName), "/_security"]),
      Body = jiffy:encode({SecurityProperties}),
      {ok, 200, _, _} = do_request(put, Url, Body).
  
  all_dbs() ->
      {ok, 200, _, Body} = do_request(get, get_cluster_base_url() ++ "/_all_dbs"),
  