forked from samcamwilliams/HyperBEAM
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1a0aad3
commit 2130746
Showing
5 changed files
with
29 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -154,7 +154,7 @@ all_signers(Msgs) -> | |
%% @doc Test that we can get the node message. | ||
config_test() -> | ||
Node = hb_http_server:start_test_node(#{ test_config_item => <<"test">> }), | ||
{ok, Res} = hb_http:get(Node, <<"/![email protected]/info">>, #{}), | ||
{ok, Res} = hb_http:get(Node, <<"/~m[email protected]/info">>, #{}), | ||
?event({res, Res}), | ||
?assertEqual(<<"test">>, hb_converge:get(<<"test_config_item">>, Res, #{})). | ||
|
||
|
@@ -166,7 +166,7 @@ priv_inaccessible_test() -> | |
priv_key => <<"BAD">> | ||
} | ||
), | ||
{ok, Res} = hb_http:get(Node, <<"/![email protected]/info">>, #{}), | ||
{ok, Res} = hb_http:get(Node, <<"/~m[email protected]/info">>, #{}), | ||
?event({res, Res}), | ||
?assertEqual(<<"test">>, hb_converge:get(<<"test_config_item">>, Res, #{})), | ||
?assertEqual(not_found, hb_converge:get(<<"priv_key">>, Res, #{})). | ||
|
@@ -180,15 +180,15 @@ unauthorized_set_node_msg_fails_test() -> | |
Node, | ||
hb_message:sign( | ||
#{ | ||
<<"path">> => <<"/![email protected]/info">>, | ||
<<"path">> => <<"/~m[email protected]/info">>, | ||
<<"evil_config_item">> => <<"BAD">> | ||
}, | ||
ar_wallet:new() | ||
), | ||
#{} | ||
), | ||
?event({res, SetRes}), | ||
{ok, Res} = hb_http:get(Node, <<"/![email protected]/info">>, #{}), | ||
{ok, Res} = hb_http:get(Node, <<"/~m[email protected]/info">>, #{}), | ||
?event({res, Res}), | ||
?assertEqual(not_found, hb_converge:get(<<"evil_config_item">>, Res, #{})). | ||
|
||
|
@@ -207,15 +207,15 @@ authorized_set_node_msg_succeeds_test() -> | |
Node, | ||
hb_message:sign( | ||
#{ | ||
<<"path">> => <<"/![email protected]/info">>, | ||
<<"path">> => <<"/~m[email protected]/info">>, | ||
<<"test_config_item">> => <<"test2">> | ||
}, | ||
Owner | ||
), | ||
#{} | ||
), | ||
?event({res, SetRes}), | ||
{ok, Res} = hb_http:get(Node, <<"/![email protected]/info">>, #{}), | ||
{ok, Res} = hb_http:get(Node, <<"/~m[email protected]/info">>, #{}), | ||
?event({res, Res}), | ||
?assertEqual(<<"test2">>, hb_converge:get(<<"test_config_item">>, Res, #{})). | ||
|
||
|
@@ -234,31 +234,31 @@ claim_node_test() -> | |
Node, | ||
hb_message:sign( | ||
#{ | ||
<<"path">> => <<"/![email protected]/info">>, | ||
<<"path">> => <<"/~m[email protected]/info">>, | ||
<<"operator">> => Address | ||
}, | ||
Owner | ||
), | ||
#{} | ||
), | ||
?event({res, SetRes}), | ||
{ok, Res} = hb_http:get(Node, <<"/![email protected]/info">>, #{}), | ||
{ok, Res} = hb_http:get(Node, <<"/~m[email protected]/info">>, #{}), | ||
?event({res, Res}), | ||
?assertEqual(Address, hb_converge:get(<<"operator">>, Res, #{})), | ||
{ok, SetRes2} = | ||
hb_http:post( | ||
Node, | ||
hb_message:sign( | ||
#{ | ||
<<"path">> => <<"/![email protected]/info">>, | ||
<<"path">> => <<"/~m[email protected]/info">>, | ||
<<"test_config_item">> => <<"test2">> | ||
}, | ||
Owner | ||
), | ||
#{} | ||
), | ||
?event({res, SetRes2}), | ||
{ok, Res2} = hb_http:get(Node, <<"/![email protected]/info">>, #{}), | ||
{ok, Res2} = hb_http:get(Node, <<"/~m[email protected]/info">>, #{}), | ||
?event({res, Res2}), | ||
?assertEqual(<<"test2">>, hb_converge:get(<<"test_config_item">>, Res2, #{})). | ||
|
||
|
@@ -278,7 +278,7 @@ preprocessor_test() -> | |
} | ||
} | ||
}), | ||
hb_http:get(Node, <<"/![email protected]/info">>, #{}), | ||
hb_http:get(Node, <<"/~m[email protected]/info">>, #{}), | ||
?assert(receive ok -> true after 1000 -> false end). | ||
|
||
%% @doc Test that we can halt a request if the preprocessor returns an error. | ||
|
@@ -295,7 +295,7 @@ halt_request_test() -> | |
} | ||
} | ||
}), | ||
{error, Res} = hb_http:get(Node, <<"/![email protected]/info">>, #{}), | ||
{error, Res} = hb_http:get(Node, <<"/~m[email protected]/info">>, #{}), | ||
?assertEqual(<<"Bad">>, Res). | ||
|
||
%% @doc Test that a preprocessor can modify a request. | ||
|
@@ -332,5 +332,5 @@ postprocessor_test() -> | |
} | ||
} | ||
}), | ||
hb_http:get(Node, <<"/![email protected]/info">>, #{}), | ||
hb_http:get(Node, <<"/~m[email protected]/info">>, #{}), | ||
?assert(receive ok -> true after 1000 -> false end). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -364,7 +364,7 @@ device_call_from_singleton_test() -> | |
<<"node">> => <<"old">>, | ||
<<"priority">> => 10 | ||
}]}, | ||
Msgs = hb_singleton:from(#{ <<"path">> => <<"![email protected]/routes">> }), | ||
Msgs = hb_singleton:from(#{ <<"path">> => <<"~r[email protected]/routes">> }), | ||
?event({msgs, Msgs}), | ||
?assertEqual( | ||
{ok, Routes}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -495,7 +495,7 @@ http_init(Opts) -> | |
|
||
http_post_schedule_sign(Node, Msg, ProcessMsg, Wallet) -> | ||
Msg1 = hb_message:sign(#{ | ||
<<"path">> => <<"/![email protected]/schedule">>, | ||
<<"path">> => <<"/~s[email protected]/schedule">>, | ||
<<"method">> => <<"POST">>, | ||
<<"process">> => ProcessMsg, | ||
<<"body">> => hb_message:sign(Msg, Wallet) | ||
|
@@ -504,14 +504,14 @@ http_post_schedule_sign(Node, Msg, ProcessMsg, Wallet) -> | |
|
||
http_get_slot(N, PMsg) -> | ||
{ok, _} = hb_http:get(N, #{ | ||
<<"path">> => <<"/![email protected]/slot">>, | ||
<<"path">> => <<"/~s[email protected]/slot">>, | ||
<<"method">> => <<"GET">>, | ||
<<"process">> => PMsg | ||
}, #{}). | ||
|
||
http_get_schedule(N, PMsg, From, To) -> | ||
{ok, _} = hb_http:get(N, #{ | ||
<<"path">> => <<"/![email protected]/schedule">>, | ||
<<"path">> => <<"/~s[email protected]/schedule">>, | ||
<<"method">> => <<"GET">>, | ||
<<"process">> => PMsg, | ||
<<"from">> => From, | ||
|
@@ -535,7 +535,7 @@ http_get_schedule_test() -> | |
{Node, Wallet} = http_init(), | ||
PMsg = hb_message:sign(test_process(Wallet), Wallet), | ||
Msg1 = hb_message:sign(#{ | ||
<<"path">> => <<"/![email protected]/schedule">>, | ||
<<"path">> => <<"/~s[email protected]/schedule">>, | ||
<<"method">> => <<"POST">>, | ||
<<"process">> => PMsg, | ||
<<"body">> => hb_message:sign(#{ <<"inner">> => <<"test">> }, Wallet) | ||
|
@@ -598,7 +598,7 @@ many_clients(Opts) -> | |
{Node, Wallet} = http_init(Opts), | ||
PMsg = hb_message:sign(test_process(Wallet), Wallet), | ||
Msg1 = hb_message:sign(#{ | ||
<<"path">> => <<"/![email protected]/schedule">>, | ||
<<"path">> => <<"/~s[email protected]/schedule">>, | ||
<<"method">> => <<"POST">>, | ||
<<"process">> => PMsg, | ||
<<"body">> => hb_message:sign(#{ <<"inner">> => <<"test">> }, Wallet) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -139,7 +139,7 @@ get_balance_and_top_up_test() -> | |
hb_http:get( | ||
Node, | ||
hb_message:sign( | ||
#{<<"path">> => <<"/![email protected]/balance">>}, | ||
#{<<"path">> => <<"/~s[email protected]/balance">>}, | ||
Wallet | ||
), | ||
#{} | ||
|
@@ -150,7 +150,7 @@ get_balance_and_top_up_test() -> | |
Node, | ||
hb_message:sign( | ||
#{ | ||
<<"path">> => <<"/![email protected]/topup">>, | ||
<<"path">> => <<"/~s[email protected]/topup">>, | ||
<<"amount">> => 100, | ||
<<"recipient">> => Address | ||
}, | ||
|
@@ -163,7 +163,7 @@ get_balance_and_top_up_test() -> | |
hb_http:get( | ||
Node, | ||
hb_message:sign( | ||
#{<<"path">> => <<"/![email protected]/balance">>}, | ||
#{<<"path">> => <<"/~s[email protected]/balance">>}, | ||
Wallet | ||
), | ||
#{} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters