mirror of
https://github.com/internetee/epp_proxy.git
synced 2025-08-21 22:50:48 +02:00
Here's what happens: When a client sends simple command without any values in XML, registry can drop the `raw_frame` parameter completely. If so, it relies on `frame` parameter being passed on to create XML document. https://github.com/internetee/registry/blame/ad823391b75509d5be20ee6ef217aa4f35a4c994/lib/epp_constraint.rb#L14 Fix involves sending the XML string twice, as `frame` and `raw_frame`, the same as `mod_epp` did.
83 lines
3.3 KiB
Erlang
83 lines
3.3 KiB
Erlang
-module(epp_http_client_SUITE).
|
|
|
|
-include("epp_proxy.hrl").
|
|
-include_lib("common_test/include/ct.hrl").
|
|
|
|
-export([all/0]).
|
|
-export([init_per_suite/1, end_per_suite/1]).
|
|
-export([hello_request_builder_test_case/1,
|
|
error_request_builder_test_case/1,
|
|
command_request_builder_test_case/1,
|
|
registry_unreachable_test_case/1]).
|
|
|
|
all() ->
|
|
[hello_request_builder_test_case,
|
|
error_request_builder_test_case,
|
|
command_request_builder_test_case,
|
|
registry_unreachable_test_case].
|
|
|
|
init_per_suite(Config) ->
|
|
application:ensure_all_started(hackney),
|
|
Config.
|
|
|
|
end_per_suite(Config) ->
|
|
application:stop(hackney),
|
|
Config.
|
|
|
|
hello_request_builder_test_case(_Config) ->
|
|
RequestMap = #{command => "hello", session_id => "Random",
|
|
cl_trid => "EE-123456789", raw_frame => "",
|
|
headers => [{"User-Agent", <<"EPP proxy">>}]},
|
|
Request = epp_http_client:request_builder(RequestMap),
|
|
ExpectedTuple = {epp_request,get,"http://localhost:9292/session/hello",
|
|
[],
|
|
[<<"session=Random; Version=1">>],
|
|
[{"User-Agent",<<"EPP proxy">>}], "hello"},
|
|
true = is_record(Request, epp_request),
|
|
ExpectedTuple = Request.
|
|
|
|
error_request_builder_test_case(_Config) ->
|
|
RequestMap = #{command => "error", session_id => "Random",
|
|
cl_trid => "EE-123456789", code => <<"2001">>,
|
|
message => <<"Expected better XML">>,
|
|
headers => [{"User-Agent", <<"EPP proxy">>}]},
|
|
Request = epp_http_client:request_builder(RequestMap),
|
|
ExpectedTuple = {epp_request,get,"http://localhost:9292/error",
|
|
[{<<"code">>,<<"2001">>},
|
|
{<<"msg">>,<<"Expected better XML">>},
|
|
{<<"clTRID">>,"EE-123456789"}],
|
|
[<<"session=Random; Version=1">>],
|
|
[{"User-Agent",<<"EPP proxy">>}], "error"},
|
|
true = is_record(Request, epp_request),
|
|
ExpectedTuple = Request,
|
|
ok.
|
|
|
|
command_request_builder_test_case(_Config) ->
|
|
RequestMap = #{command => "create", session_id => "Random",
|
|
cl_trid => "EE-123456789", raw_frame => "Some XML here",
|
|
headers => [{"User-Agent", <<"EPP proxy">>}]},
|
|
Request = epp_http_client:request_builder(RequestMap),
|
|
ExpectedTuple = {epp_request,post,
|
|
"http://localhost:9292/command/create",
|
|
{multipart,
|
|
[{<<"raw_frame">>,"Some XML here"},
|
|
{<<"frame">>,"Some XML here"},
|
|
{<<"clTRID">>,"EE-123456789"}]},
|
|
[<<"session=Random; Version=1">>],
|
|
[{"User-Agent",<<"EPP proxy">>}], "create"},
|
|
true = is_record(Request, epp_request),
|
|
ExpectedTuple = Request,
|
|
ok.
|
|
|
|
registry_unreachable_test_case(_Config) ->
|
|
Request = {epp_request,
|
|
post,
|
|
"http://localhost:9999/someurl",
|
|
{multipart,
|
|
[{<<"raw_frame">>,"Some XML here"},
|
|
{<<"frame">>,"Some XML here"},
|
|
{<<"clTRID">>,"EE-123456789"}]},
|
|
[<<"session=Random; Version=1">>],
|
|
[{"User-Agent",<<"EPP proxy">>}], "create"},
|
|
{2400, _CannedResponse} = epp_http_client:request(Request),
|
|
ok.
|