summaryrefslogtreecommitdiff
path: root/test/catlfish_test.erl
blob: b098cc1e1d8f0e579404b1f5f9a038c2baf9b2fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
%%% Copyright (c) 2014, NORDUnet A/S.
%%% See LICENSE for licensing information.

-module(catlfish_test).
-include_lib("eunit/include/eunit.hrl").

%% Requires that catlfish is running (or, at the moment, that v1 has
%% been installed as an mod_esi module -- use https_server:start()).

-define(URL, "https://flimsytest:8080/ct/v1/add_chain").

add_chain_test_() ->
    {setup,
     fun() ->
             Input = "{\"chain\": [\"some test data\"]}",
             {OK, {{_, RC, _}, _, _}} = httpc:request(post, {?URL, [], [], Input}, [], []),
             %% TODO: Verify signature.
             {OK, RC}
     end,
     fun(_) -> ok end,
     fun({OK, RC}) ->
             [?_assertEqual(ok, OK),
              ?_assertEqual(RC, 200)]
     end}.

add_sth_test_() ->
    {setup,
     fun() ->
             {OK, {{_, RC, _}, _, _}} = httpc:request(get, {?URL, []}, [], []),
             {OK, RC}
     end,
     fun(_) -> ok end,
     fun({OK, RC}) ->
             [?_assertEqual(ok, OK),
              ?_assertEqual(RC, 200)]
     end}.