Skip to content

Commit

Permalink
Merge pull request #9 from internetee/fix-test
Browse files Browse the repository at this point in the history
Extend the test suite
  • Loading branch information
Maciej Szlosarczyk authored Jul 15, 2019
2 parents fc890b0 + f659a1f commit f00a17b
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ rebar3.crashdump
*~

config/dev.config
apps/epp_proxy/priv/test_backend_app/pidfile
6 changes: 2 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ WORKDIR /opt/erlang/epp_proxy
COPY .tool-versions ./
RUN asdf plugin-add erlang
RUN asdf install
RUN asdf global erlang $(grep erlang .tool-versions | cut -d' ' -f2)
RUN asdf plugin-add ruby
RUN asdf plugin-add rebar
RUN asdf install

RUN curl https://s3.amazonaws.com/rebar3/rebar3 -o /rebar3
RUN mv /rebar3 /usr/local/bin
RUN chmod +x /usr/local/bin/rebar3
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,22 @@ $ rebar3 tar # Creates an archive that can be shipped to another machine
$ rebar3 as prod release tar # Combines the steps above into single one, uses production profile.
```

### Creating Releases

The application is configured to automatically create releases based on git tags. After you develop
a new functionality, you can create a tag with incremental release:

$ git tag -a v0.1.10 -m "update tcp handler."

After that, you can run the same relx command to create a tarball with new release:

```sh
$ rebar3 as prod release tar
# [Creating the release...]
===> tarball /opt/erlang/epp_proxy/_build/prod/rel/epp_proxy/epp_proxy-0.1.10+build.1.ref0eb7caa.tar.gz
successfully created!
```

Configuration
-----
Configuration for the application tries to emulate the mod_epp configuration as close as possible
Expand Down
Binary file added apps/epp_proxy/priv/armstrong_thesis_2003.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion apps/epp_proxy/test/epp_util_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,5 @@ path_for_file_test_case(_Config) ->
AbsoluteFilename = "/usr/bin",
AbsoluteFilename = epp_util:path_for_file(AbsoluteFilename),
RelativeFilename = "usr/bin",
RelativeFilename =:= epp_util:path_for_file(RelativeFilename),
true = (AbsoluteFilename =:= epp_util:path_for_file(AbsoluteFilename)),
ok.
30 changes: 30 additions & 0 deletions apps/epp_proxy/test/tcp_client_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
greetings_test_case/1,
session_test_case/1,
valid_command_test_case/1,
long_message_test_case/1,
invalid_command_test_case/1,
error_test_case/1]).

Expand All @@ -17,6 +18,7 @@ all() ->
greetings_test_case,
session_test_case,
valid_command_test_case,
long_message_test_case,
invalid_command_test_case,
error_test_case].

Expand Down Expand Up @@ -103,6 +105,34 @@ valid_command_test_case(Config) ->
"Command completed successfully; no messages"),
ok.

long_message_test_case(Config) ->
Options = proplists:get_value(tcp_options, Config),
{ok, Socket} = gen_tcp:connect("localhost", 1180, Options, 2000),
_Data = receive_data(Socket),
CWD = code:priv_dir(epp_proxy),
{ok, File} = file:read_file(
filename:join(CWD, "armstrong_thesis_2003.pdf")
),
Base64 = base64:encode(File),
CommandBeginning =
<<"<?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"
"<poll op=\"req\">\n"
"<legalDoc>\n">>,
CommandEnd =
<<"</legalDoc>\n"
"</poll>\n"
"<clTRID>foo bar baz</clTRID>\n"
"</command>\n"
"</epp>\n">>,
FullCommand = <<CommandBeginning/binary, Base64/binary, CommandEnd/binary>>,
ok = send_data(FullCommand, Socket),
PollResponse = receive_data(Socket),
match_data(PollResponse,
"Command completed successfully; no messages"),
ok.

%% Sending an invalid command frame should close the connection.
%% It also crashes the process.
invalid_command_test_case(Config) ->
Expand Down
30 changes: 30 additions & 0 deletions apps/epp_proxy/test/tls_client_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
greetings_test_case/1,
session_test_case/1,
valid_command_test_case/1,
long_message_test_case/1,
invalid_command_test_case/1,
error_test_case/1]).

Expand All @@ -17,6 +18,7 @@ all() ->
greetings_test_case,
session_test_case,
valid_command_test_case,
long_message_test_case,
invalid_command_test_case,
error_test_case].

Expand Down Expand Up @@ -106,6 +108,34 @@ valid_command_test_case(Config) ->
"Command completed successfully; no messages"),
ok.

long_message_test_case(Config) ->
Options = proplists:get_value(ssl_options, Config),
{ok, Socket} = ssl:connect("localhost", 1443, Options, 2000),
_Data = receive_data(Socket),
CWD = code:priv_dir(epp_proxy),
{ok, File} = file:read_file(
filename:join(CWD, "armstrong_thesis_2003.pdf")
),
Base64 = base64:encode(File),
CommandBeginning =
<<"<?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"
"<poll op=\"req\">\n"
"<legalDoc>\n">>,
CommandEnd =
<<"</legalDoc>\n"
"</poll>\n"
"<clTRID>foo bar baz</clTRID>\n"
"</command>\n"
"</epp>\n">>,
FullCommand = <<CommandBeginning/binary, Base64/binary, CommandEnd/binary>>,
ok = send_data(FullCommand, Socket),
PollResponse = receive_data(Socket),
match_data(PollResponse,
"Command completed successfully; no messages"),
ok.

%% Sending an invalid command frame should close the connection.
%% It also crashes the process.
invalid_command_test_case(Config) ->
Expand Down
2 changes: 1 addition & 1 deletion rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{lager, "3.7.0"},
{lager_syslog, {git, "https://github.com/erlang-lager/lager_syslog.git"}}]}.

{relx, [{release, {epp_proxy, "0.1.0"},
{relx, [{release, {epp_proxy, semver},
[epp_proxy,
lager,
lager_syslog,
Expand Down

0 comments on commit f00a17b

Please sign in to comment.