anchor.diff:           end_per_suite/1,
            %% init_per_group/2,
            %% end_per_group/2,
  -         %% init_per_testcase/2,
  -         %% end_per_testcase/2,
  +         init_per_testcase/2,
  +         end_per_testcase/2,
   
            update_config/1,
  +         service_config/1,
            %% provider_list/0,
  -         provider_list/1
  -
  -
  +         provider_list/1,
  +         service_list/1,
  +         credential_list/1,
  +         credential_request/1,
  +         credential_revoke/1
           ]).
   
   all() ->
       [
        update_config,
  -     provider_list
  +     service_config,
  +     provider_list,
  +     service_list,
  +     credential_request,
  +     credential_list,
  +     credential_revoke
       ].
   
   %% groups() ->
  
positive.code:     wait_for_config(),
      AppConf = application:get_all_env(tts),
      ct:pal("the configuration is: ~p",[AppConf]),
      ok.
  
  provider_list(_Config) ->
      {ok, _Json} = perform_rest_request("lsprov localhost"),
      ok.
  
  
  perform_rest_request(Params) ->
      Script = tts_based_dir("./client/ttsc.sh"),
      Cmd = "URI_SCHEME=http && "++Script++" "++Params,
      Json = os:cmd(Cmd),
      ct:log("executed ~p with result ~p",[Cmd, Json]),
      case jsx:is_json(Json) of
          true -> {ok, jsx:decode(Json, [return_maps, {labels, attempt_atom}])};
          false -> {error, not_json, Json}
      end.
  
  wait_for_config() ->
  
negative.code:     [BinBaseDir | _] = binary:split(list_to_binary(PrivDir),<<"_build">>),
      tts_file_util:to_abs(Dir, binary_to_list(BinBaseDir)).
  
  wait_for_oidcc_ready() ->
      {ok, OidcList} = oidcc:get_openid_provider_list(),
      wait_for_oidcc_ready(OidcList).
  wait_for_oidcc_ready(List) ->
      Ready = fun({Id, Pid}, NotReady) ->
                      case oidcc_openid_provider:is_ready(Pid) of
                          true -> NotReady;
                          false -> [{Id, Pid} | NotReady]
                      end
              end,
      case lists:foldl(Ready, [], List) of
          [] -> ok;
          NewList ->
              timer:sleep(200),
              wait_for_oidcc_ready(NewList)
      end.
  
  
  
  mock_oidcc() ->
      Info = #{sub => <<"tts_test_user">>, name => <<"joe">>},
      meck:new(oidcc, [passthrough]),
      UserInfo2 = fun(Token, ProviderId) ->
                         ct:log("Returning UserInfo ~p for request to provider ~p
                         with token ~p~n",[Info, ProviderId, Token]),
                         {ok, Info}
                 end,
      UserInfo3 = fun(Token, ProviderId, _Subject) ->
                         ct:log("Returning UserInfo ~p for request to provider ~p
                         with token ~p~n",[Info, ProviderId, Token]),
                         {ok, Info}
                 end,
      meck:expect(oidcc, retrieve_user_info, UserInfo2),
      meck:expect(oidcc, retrieve_user_info, UserInfo3),
      ok.
  
  unmock_oidcc() ->
      true = meck:validate(oidcc),
      ok = meck:unload(oidcc),
      ok.
  