anchor.diff:                                _ -> false
                             end
                 end,
  -
  -
  -    ok = test_util:meck_new(MeckModules),
  -    ok = meck:expect(tts, does_credential_exist, CredExists),
  -    ok = meck:expect(tts, does_temp_cred_exist, CredDataExists),
  -    ok = meck:expect(cowboy_req, set_resp_body, fun(_, Req) -> Req end),
  -
  -    Requests = [
  -                %% good requests
  -                {#state{id = undefined}, false},
  -                {#state{id = undefined, type=oidcp}, true},
  -                {#state{id = undefined, type=service}, true},
  -                {#state{id = undefined, type=credential}, true},
  -                {#state{id = <<"123">>, type=credential}, true},
  -                {#state{type = cred_data, id= <<"someid">>}, true},
  -
  -                %% bad requests
  -                {#state{id = <<"123">>, type=oidcp}, false},
  -                {#state{id = <<"123">>, type=service}, false},
  -                {#state{id = <<"124">>, type=oidcp}, false},
  -                {#state{id = <<"124">>, type=service}, false},
  -                {#state{type = creddata, id= <<"someid">>}, false},
  -                {#state{type = creddata }, false}
  -
  -               ],
  -
  -    Test  = fun({State, ExpResult}, _) ->
  -                    io:format("testing ~p, expecting: ~p~n", [State, ExpResult]),
  -                    {Result, req, _} = tts_rest:resource_exists(req, State),
  -                    ?assertEqual(ExpResult, Result),
  -                    ok
  -            end,
  -    ok = lists:foldl(Test,ok,Requests),
  -    ok = test_util:meck_done(MeckModules),
  -    ok.
  -
  -get_json_test() ->
  -    MeckModules = [tts],
   
       GetProvider = fun() ->
                             {ok, [#{id => <<"ID1">>,
  
positive.code:                               _ -> {error, not_found}
                            end
                end,
      ok = test_util:meck_new(MeckModules),
      ok = meck:expect(tts, get_service_list_for, GetServiceList),
      ok = meck:expect(tts, get_openid_provider_list, GetProvider),
      ok = meck:expect(tts, get_credential_list_for, GetCredList),
      ok = meck:expect(tts, get_temp_cred, GetCred),
      ok = meck:expect(tts, logout, fun(_) -> ok end),
  
      Requests = [
                  {#state{version = latest,
                          type = service,
                          id = undefined,
                          session_pid = pid1,
                          method = get
                         }, <<"{\"service_list\":[{}]}">> },
                  {#state{version = latest,
                          type = service,
                          id = undefined,
                          session_pid = pid2,
                          method = get
                         }, <<"{\"service_list\":[]}">> },
                  {#state{version = latest,
                          type = oidcp,
                          id = undefined,
                          session_pid = undefined,
                          method = get
                         },<<"{\"openid_provider_list\":[{\"id\":\"ID1\",\"issuer\":\"https:\\/\\/test.tts\",\"ready\":true},{\"id\":\"ID2\",\"issuer\":\"https:\\/\\/other.tts\",\"ready\":false}]}">>
                  },
                  %% {#state{version = latest,
                  %%         type = credential,
                  %%         id = undefined,
                  %%         session_pid = pid1,
                  %%         method = get
                  %%        },<<"{\"credential_list\":[{\"id\":\"CredId\"}]}">> },
                  {#state{version = latest,
                          type = cred_data,
                          id = <<"CRED1">>,
                          session_pid = pid1,
                          method = get
                         },<<"{\"password\":\"secret\"}">> },
                  {#state{version = latest,
                          type = cred_data,
                          id = <<"CRED1">>,
                          session_pid = pid2,
                          method = get
                         },<<"{\"result\":\"error\",\"user_msg\":\"Sorry, the requested data was not found\"}">> }
                 ],
  
      Test  = fun({State, ExpResult}, _) ->
                      io:format("Expecting ~p on state ~p~n",[ExpResult, State]),
                      {Result, req, _NewState} = tts_rest:get_json(req, State),
                      ?assertEqual(ExpResult, Result),
                      ok
              end,
      ok = lists:foldl(Test,ok,Requests),
      ok = test_util:meck_done(MeckModules),
  
      ok.
  
  post_json_test() ->
      application:set_env(tts, ep_main, <<"/">>),
      MeckModules = [ tts ],
      CredRequest = fun(_ServiceId, SessionPid, _Params, _IFace) ->
                          case SessionPid of
                              pid1 -> {ok, #{}};
  
negative.code:                     end,
  
      ok = test_util:meck_new(MeckModules),
      ok = meck:expect(cowboy_req, binding, Binding),
      ok = meck:expect(cowboy_req, binding, Binding2),
      ok = meck:expect(cowboy_req, cookie, GetCookie),
      ok = meck:expect(cowboy_req, header, Header),
      ok = meck:expect(cowboy_req, parse_header, ParseHeader),
      ok = meck:expect(cowboy_req, method, Method),
      ok = meck:expect(cowboy_req, body, Body),
      ok = meck:expect(cowboy_req, set_resp_body, fun(_, Req) -> Req end),
      ok = meck:expect(cowboy_req, set_resp_header, SetHeader),
      ok = meck:expect(oidcc, get_openid_provider_info, GetOidcProvider),
      ok = meck:expect(tts, login_with_access_token, Login),
      ok = meck:expect(tts, does_credential_exist, CredExists),
      ok = meck:expect(tts, does_temp_cred_exist, CredDataExists),
      ok = meck:expect(tts, get_service_list_for, GetServiceList),
      ok = meck:expect(tts, get_openid_provider_list, GetProvider),
      ok = meck:expect(tts, get_credential_list_for, GetCredList),
      ok = meck:expect(tts, get_temp_cred, GetCred),
      ok = meck:expect(tts, revoke_credential_for, Revoke),
      ok = meck:expect(tts, logout, fun(_) -> ok end),
      ok = meck:expect(tts, request_credential_for, CredRequest),
      ok = meck:expect(tts, store_temp_cred, StoreTempCred),
      ok = meck:expect(tts_session, is_logged_in, fun(_) -> false end),
      {ok, {MeckModules}}.
  
  stop_meck({MeckModules}) ->
      ok = test_util:meck_done(MeckModules),
      ok.
  