anchor.diff:                           'MetaWrite','Read','SimpleStats','TapConsumer',
                            'TapProducer','Write','XattrRead','XattrWrite']}]}},
               {privileges,[]},
  -            {type, builtin}]}},
  -         {<<"ivanivanov">>,
  -          {[{buckets,{[{<<"default">>,
  -                        ['DcpConsumer','IdleConnection','MetaRead','Read',
  -                         'TapConsumer','XattrRead']},
  -                       {<<"test">>,
  -                        ['DcpConsumer','DcpProducer','IdleConnection','MetaRead',
  -                         'MetaWrite','Read','SimpleStats','TapConsumer',
  -                         'TapProducer','Write','XattrRead','XattrWrite']}]}},
  -            {privileges,['Stats']},
  -            {type, builtin}]}},
  -         {<<"petrpetrov">>,
  -          {[{buckets,{[{<<"default">>,
  -                        ['DcpConsumer','DcpProducer','IdleConnection','MetaRead',
  -                         'MetaWrite','Read','SimpleStats','TapConsumer',
  -                         'TapProducer','Write','XattrRead','XattrWrite']},
  -                       {<<"test">>,
  -                        ['DcpConsumer','DcpProducer','IdleConnection','MetaRead',
  -                         'MetaWrite','Read','SimpleStats','TapConsumer',
  -                         'TapProducer','Write','XattrRead','XattrWrite']}]}},
  -            {privileges,['AuditManagement','BucketManagement',
  -                         'NodeManagement','SessionManagement','Stats']},
  -            {type, saslauthd}]}}],
  -    ?assertEqual(Json, generate_json(Buckets, RoleDefinitions, Users)).
  +            {type, builtin}]}}],
  +    ?assertEqual(Json, generate_json_45(Buckets, RoleDefinitions)).
  
positive.code: memcached_admin_json(AU, Buckets) ->
      jsonify_user({AU, builtin}, [{global, [all]} | [{Name, [all]} || Name <- Buckets]]).
  
  generate_json(Buckets, RoleDefinitions, Users) ->
      RolesDict = dict:new(),
      BucketUsers = [{{Name, builtin}, menelaus_roles:get_roles({Name, bucket})} ||
                        Name <- Buckets],
      {Json, _} =
          lists:foldl(fun ({Identity, Roles}, {Acc, Dict}) ->
                              {Permissions, NewDict} =
                                  permissions_for_user(Roles, Buckets, RoleDefinitions, Dict),
                              {[jsonify_user(Identity, Permissions) | Acc], NewDict}
                      end, {[], RolesDict}, BucketUsers ++ Users),
      lists:reverse(Json).
  
  generate_json_test() ->
      Buckets = ["default", "test"],
      Users = [{{"ivanivanov", builtin}, [{views_admin, ["default"]}, {bucket_admin, ["test"]}]},
               {{"petrpetrov", saslauthd}, [admin]}],
      RoleDefinitions = menelaus_roles:preconfigured_roles(),
  
      Json =
  
negative.code: -include_lib("eunit/include/eunit.hrl").
  
  -record(state, {buckets,
                  roles,
                  admin_user}).
  
  