anchor.diff:            false
       end.
   
  +auth_header_() ->
  +    auth_header_("admin", "public").
  +
   auth_header_(User, Pass) ->
       Encoded = base64:encode_to_string(lists:append([User,":",Pass])),
       {"Authorization","Basic " ++ Encoded}.
   
  -connect_dashbaord_(Method, Api, Params) ->
  +connect_dashbaord_(Method, Api, Params, Auth) ->
       Url = "http://127.0.0.1:18083/" ++ Api,
  -    Auth = auth_header_("admin", "public"),
       case httpc:request(Method, {Url, [Auth], ?CONTENT_TYPE, Params}, [], []) of
       {error, socket_closed_remotely} ->
           false;
  
positive.code:     emqttd_mnesia:ensure_stopped().
   
  brokers(_) ->
      ?assert(connect_dashbaord_(get, "api/brokers")).
  
  stats(_) ->
      ?assert(connect_dashbaord_(get, "api/stats")).
  
  ptype(_) ->
      ?assert(connect_dashbaord_(get, "api/ptype")).
  
  memory(_) ->
      ?assert(connect_dashbaord_(get, "api/memory")).
  
  cpu(_) ->
      ?assert(connect_dashbaord_(get, "api/cpu")).
  
  nodes(_) ->
      ?assert(connect_dashbaord_(get, "api/nodes")).
  
  metrics(_) ->
      ?assert(connect_dashbaord_(get, "api/metrics")).
  
  listeners(_) ->
      ?assert(connect_dashbaord_(get, "api/listeners")).
  
  bnode(_) ->
      ?assert(connect_dashbaord_(get, "api/bnode")).
  
  clients(_) ->
      ?assert(connect_dashbaord_(post, "api/clients", "page_size=100&curr_page=1")).
     
  clients_query(_) ->
      Sock = client_connect_(<<16,12,0,4,77,81,84,84,4,0,0,90,0,0>>, 4),
  
negative.code:     ?assertEqual({ok, Entry}, emqttd_dashboard_subscription:list(ClientId, 1, 100)),
      gen_tcp:close(Sock).
  
  admins_add_delete(_) ->
      emqttd_dashboard_user:add(<<"username">>, <<"password">>, <<"tag">>),
      emqttd_dashboard_user:add(<<"username1">>, <<"password1">>, <<"tag1">>),
      {ok, Admins} = emqttd_dashboard_user:users(),
      ?assertEqual([[{name, <<"username">>}, {tag, <<"tag">>}],
                    [{name, <<"username1">>}, {tag, <<"tag1">>}],
                    [{name, <<"admin">>}, {tag, <<"administrator">>}]],
                  Admins),
      emqttd_dashboard_user:remover(<<"username1">>),
      ?assertEqual({ok, [[{name, <<"username">>}, {tag, <<"tag">>}],
                         [{name, <<"admin">>}, {tag, <<"administrator">>}]]}, 
                  emqttd_dashboard_user:users()),
      emqttd_dashboard_user:update(<<"username">>, <<"pwd">>, <<"login">>),
      timer:sleep(10),
      ?assert(connect_dashbaord_(get, "api/brokers", auth_header_("username", "pwd"))),
      emqttd_dashboard_user:remover(<<"username">>),
      ?assertEqual(false, connect_dashbaord_(get, "api/brokers", auth_header_("username", "pwd"))).
  
  client_connect_(Packet, RecvSize) ->
      {ok, Sock} = gen_tcp:connect({127,0,0,1}, 1883, [binary, {packet, raw}, {active, false}]),
      gen_tcp:send(Sock, Packet),
      gen_tcp:recv(Sock, RecvSize, 3000),
      Sock.
  
  connect_dashbaord_(Method, Api, Auth) ->
      Url = "http://127.0.0.1:18083/" ++ Api,
      case httpc:request(Method, {Url, [Auth]}, [], []) of
        {error, socket_closed_remotely} ->
            false;
  