mirror of
https://github.com/internetee/epp_proxy.git
synced 2025-08-14 19:43:48 +02:00
Add test case for error request
This commit is contained in:
parent
7f7eea8149
commit
45f99a2f77
3 changed files with 38 additions and 5 deletions
|
@ -27,7 +27,11 @@ class BackendServer < Roda
|
|||
|
||||
end
|
||||
|
||||
r.on "error" do
|
||||
r.get "error" do
|
||||
@code = r.params['code']
|
||||
@msg = r.params['msg']
|
||||
|
||||
render("error")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
13
apps/epp_proxy/priv/test_backend_app/views/error.erb
Normal file
13
apps/epp_proxy/priv/test_backend_app/views/error.erb
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="lib/schemas/epp-ee-1.0.xsd">
|
||||
<response>
|
||||
<result code="<%= @code %>">
|
||||
<msg lang="en">
|
||||
<%= @msg %>
|
||||
</msg>
|
||||
</result>
|
||||
<trID>
|
||||
<svTRID>ccReg-4018856528</svTRID>
|
||||
</trID>
|
||||
</response>
|
||||
</epp>
|
|
@ -9,14 +9,16 @@
|
|||
greetings_test_case/1,
|
||||
session_test_case/1,
|
||||
valid_command_test_case/1,
|
||||
invalid_command_test_case/1]).
|
||||
invalid_command_test_case/1,
|
||||
error_test_case/1]).
|
||||
|
||||
all() ->
|
||||
[frame_size_test_case,
|
||||
greetings_test_case,
|
||||
session_test_case,
|
||||
valid_command_test_case,
|
||||
invalid_command_test_case].
|
||||
invalid_command_test_case,
|
||||
error_test_case].
|
||||
|
||||
init_per_suite(Config) ->
|
||||
application:ensure_all_started(epp_proxy),
|
||||
|
@ -112,7 +114,7 @@ invalid_command_test_case(Config) ->
|
|||
_Data = receive_data(Socket),
|
||||
ok = send_data(login_command(), Socket),
|
||||
_LoginResponse = receive_data(Socket),
|
||||
PollCommand =
|
||||
InvalidCommand =
|
||||
<<"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"
|
||||
"<epp xmlns=\"https://epp.tld.ee/schema/epp-ee-1.0.xsd\">\n"
|
||||
"<command>\n"
|
||||
|
@ -120,10 +122,24 @@ invalid_command_test_case(Config) ->
|
|||
"<clTRID>foo bar baz</clTRID>\n"
|
||||
"</command>\n"
|
||||
"</epp>\n">>,
|
||||
ok = send_data(PollCommand, Socket),
|
||||
ok = send_data(InvalidCommand, Socket),
|
||||
{error, closed} = receive_data(Socket),
|
||||
ok.
|
||||
|
||||
error_test_case(Config) ->
|
||||
Options = proplists:get_value(ssl_options, Config),
|
||||
{ok, Socket} = ssl:connect("localhost", 1443, Options, 2000),
|
||||
_Data = receive_data(Socket),
|
||||
ok = send_data(login_command(), Socket),
|
||||
_LoginResponse = receive_data(Socket),
|
||||
InvalidXml =
|
||||
<<"</epp>\n">>,
|
||||
ok = send_data(InvalidXml, Socket),
|
||||
ErrorResponse = receive_data(Socket),
|
||||
match_data(ErrorResponse,
|
||||
"Command syntax error."),
|
||||
ok.
|
||||
|
||||
%% Helper functions:
|
||||
length_of_data(Data) ->
|
||||
EPPEnvelope = binary:part(Data, {0, 4}),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue