Skip to content

Commit

Permalink
Merge pull request #28 from erlcloud/rebar3
Browse files Browse the repository at this point in the history
Use rebar3 for building/tests on repo
  • Loading branch information
rmpalomino authored Jul 18, 2024
2 parents 405c9bf + 17e272a commit 179963e
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 51 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
ebin/*
_build
rebar.lock

doc/edoc-info
doc/*.html
Expand All @@ -8,6 +10,7 @@ util/*.beam
cover_report/
test/*.beam
test/*.log
TEST-*

.eunit

Expand Down
15 changes: 4 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
.PHONY: all release compile test clean rel doc build-plt dialyzer
.PHONY: all release compile test clean doc dialyzer

PROJECT = lhttpc

REBAR := ./rebar
DIALYZER = dialyzer
REBAR := ./rebar3

APPS = kernel stdlib sasl inets ssl public_key crypto compiler

Expand All @@ -13,7 +12,7 @@ compile:
$(REBAR) compile

doc:
$(REBAR) doc
$(REBAR) edoc

test: compile
$(REBAR) eunit
Expand All @@ -24,11 +23,5 @@ release: all dialyze test
clean:
$(REBAR) clean

build-plt: compile
@$(DIALYZER) --build_plt --output_plt .$(PROJECT).plt \
--apps $(APPS)

dialyzer:
@$(DIALYZER) --fullpath --src ./src \
--plt .$(PROJECT).plt --no_native \
-Werror_handling #-Wrace_conditions
@$(REBAR) dialyzer
Binary file removed rebar
Binary file not shown.
Binary file added rebar3
Binary file not shown.
35 changes: 20 additions & 15 deletions test/crt.pem
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
-----BEGIN CERTIFICATE-----
MIICqzCCAhQCCQCDYWGxYNaErjANBgkqhkiG9w0BAQUFADCBmTELMAkGA1UEBhMC
VUsxDzANBgNVBAgTBkVybGFuZzEPMA0GA1UEBxMGTG9uZG9uMSwwKgYDVQQKEyNF
cmxhbmcgVHJhaW5pbmcgYW5kIENvbnN1bHRpbmcgTHRkLjEPMA0GA1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MAwGA1UE
CgwFTEhUVFAxETAPBgNVBAsMCFVuaXRUZXN0MREwDwYDVQQDDAhUZXN0Q2VydDCC
ASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKxLlqXggR5+JIzF3/a4G8al
BKm1cX299p1N8JmRpPajipKok2xpuZxX1sxVNgQ4rBk6Vufo1CGKCaZbvnpqP8Rp
YSzJljAMH7ndZK2dZlQjN0hdsR9zanb3ir6P8J2K3wttwbWWkE2SpgzOtLsaLW/N
4swOgg3E7JbTIy4H73nacxqmLN89Cnfor+DUTvEMqs1CictGz2zPNEhbTF6jATZX
Ewvqsll4Xp0TdQGBeQZrUeOwO9rGeM7XtPJZaQ6IWaL3Np32R+sBK7O6MmUe+FE3
/IsuTUV6xjvSmQGBCO8lEG7PNcxSiGH8KHRsByewMeFXlh5QkWycPPOQzrlQRpUC
AwEAAaNTMFEwHQYDVR0OBBYEFMFvhToOjxW52FzjrfuAt/bDJBnTMB8GA1UdIwQY
MBaAFMFvhToOjxW52FzjrfuAt/bDJBnTMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZI
hvcNAQELBQADggEBAG5b+SCpfARbaRL2Ek99IgcExFGruka/rOEuQ8nquMujPt40
+Fs807qcU9pRxFxpIa9Gor8K6phK5uWL9owExPUG81D2y/cNCpC2/RU9d2wiFAWd
cWzhI5WoEL6JC1XltgyK/U5IE5shs87SKNgxQYx+Lg7XJRBjLfbc3rH+rM3wXgBt
eWOiApQBTslad+M4kX0Ga42m+fYZs/AnFylpCu2MNLYyXxbl2ipBWfFuXadXgEMB
goazxiXjsamk5dbLq7lYO0NTU4MiZbI8S9SPoXPybxM8Kd7yiTpFlbNC0OeBihpV
NX6NKcN1HYOzzVothXBwzUpK+zimqgrJXFUc3pU=
-----END CERTIFICATE-----
43 changes: 28 additions & 15 deletions test/key.pem
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
-----BEGIN RSA PRIVATE KEY-----
MIICXQIBAAKBgQC6YrA5HIBj817qplK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AzpD06F94b56MEvG/dmbsQ1w1AMA
X+5z4WzKsUn+nWISMWYnNZ+ni7Jkxg8YT/kJlbWllUCAy3tDlwymHmTnyu0kgVcN
BUST1Q/zDXeKnw44P1pcmtJXz0tuWnUJSoaAxIqBAoGAXTsaZUyQD0iVJyWj4+XL
w2FAtySizO7Zzs9vsuzWA9FYqgXQzxPps3BoanJULCcuCKMfvX7gV5iPImweuNQH
CawuLM8xBeClEl8KvYeNnKD01TMHBqDO/IMhQwOR9bKhiKkbAmSc24GgZc3ceVN4
XTEwkKV0OmaRHr05PmNMp40=
-----END PRIVATE KEY-----
10 changes: 5 additions & 5 deletions test/lhttpc_tests.erl
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ close_connection() ->
ssl_get() ->
Port = start(ssl, [fun simple_response/5]),
URL = ssl_url(Port, "/simple"),
{ok, Response} = lhttpc:request(URL, "GET", [], 1000),
{ok, Response} = lhttpc:request(URL, "GET", [], [], 1000, [{connect_options, [{verify, verify_none}]}]),
?assertEqual({200, "OK"}, status(Response)),
?assertEqual(<<?DEFAULT_STRING>>, body(Response)).

Expand All @@ -740,7 +740,7 @@ ssl_get_ipv6() ->
?debugMsg("WARNING: impossible to test IPv6 support~n");
Port when is_number(Port) ->
URL = ssl_url(inet6, Port, "/simple"),
{ok, Response} = lhttpc:request(URL, "GET", [], 1000),
{ok, Response} = lhttpc:request(URL, "GET", [], [], 1000, [{connect_options, [{verify, verify_none}]}]),
?assertEqual({200, "OK"}, status(Response)),
?assertEqual(<<?DEFAULT_STRING>>, body(Response))
end.
Expand All @@ -750,21 +750,21 @@ ssl_post() ->
URL = ssl_url(Port, "/simple"),
Body = "SSL Test <o/",
BinaryBody = list_to_binary(Body),
{ok, Response} = lhttpc:request(URL, "POST", [], Body, 1000),
{ok, Response} = lhttpc:request(URL, "POST", [], Body, 1000, [{connect_options, [{verify, verify_none}]}]),
?assertEqual({200, "OK"}, status(Response)),
?assertEqual(BinaryBody, body(Response)).

ssl_chunked() ->
Port = start(ssl, [fun chunked_response/5, fun chunked_response_t/5]),
URL = ssl_url(Port, "/ssl_chunked"),
FirstResult = lhttpc:request(URL, get, [], 100),
FirstResult = lhttpc:request(URL, get, [], [], 100, [{connect_options, [{verify, verify_none}]}]),
?assertMatch({ok, _}, FirstResult),
{ok, FirstResponse} = FirstResult,
?assertEqual({200, "OK"}, status(FirstResponse)),
?assertEqual(<<?DEFAULT_STRING>>, body(FirstResponse)),
?assertEqual("chunked", lhttpc_lib:header_value("transfer-encoding",
headers(FirstResponse))),
SecondResult = lhttpc:request(URL, get, [], 100),
SecondResult = lhttpc:request(URL, get, [], [], 100, [{connect_options, [{verify, verify_none}]}]),
{ok, SecondResponse} = SecondResult,
?assertEqual({200, "OK"}, status(SecondResponse)),
?assertEqual(<<"Again, great success!">>, body(SecondResponse)),
Expand Down
19 changes: 14 additions & 5 deletions test/webserver.erl
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ listen(ssl, Addr, Family) ->
binary,
{active, false},
{ip, Addr},
{verify,0},
{keyfile, "../test/key.pem"},
{certfile, "../test/crt.pem"}
{verify, verify_none},
{keyfile, "test/key.pem"},
{certfile, "test/crt.pem"}
],
{ok, LS} = ssl:listen(0, Opts),
LS;
Expand All @@ -145,9 +145,18 @@ get_addr(Host, Family) ->
{error, family_not_supported}
end.

% ssl:ssl_accept was deprecated in OTP 21
-define(SSL_HANDSHAKE(SslSocket), {ssl:ssl_accept(SslSocket), SslSocket}).
-ifdef(OTP_RELEASE).
-if(?OTP_RELEASE >= 21).
-undef(SSL_HANDSHAKE).
-define(SSL_HANDSHAKE(SslSocket), ssl:handshake(SslSocket)).
-endif.
-endif.

accept(ssl, ListenSocket) ->
{ok, Socket} = ssl:transport_accept(ListenSocket, 10000),
ok = ssl:ssl_accept(Socket),
{ok, SslSocket} = ssl:transport_accept(ListenSocket, 10000),
{ok, Socket} = ?SSL_HANDSHAKE(SslSocket),
Socket;
accept(Module, ListenSocket) ->
{ok, Socket} = Module:accept(ListenSocket, 1000),
Expand Down

0 comments on commit 179963e

Please sign in to comment.