Browse Source

use non-deprecated exports from public_key

Will 13 years ago
parent
commit
d5089a8fe3
1 changed files with 9 additions and 7 deletions
  1. 9 7
      test_src/pgsql_tests.erl

+ 9 - 7
test_src/pgsql_tests.erl

@@ -3,12 +3,14 @@
 -export([run_tests/0]).
 -export([run_tests/0]).
 
 
 -include_lib("eunit/include/eunit.hrl").
 -include_lib("eunit/include/eunit.hrl").
--include_lib("ssl/include/OTP-PKIX.hrl").
+-include_lib("public_key/include/public_key.hrl").
 -include("pgsql.hrl").
 -include("pgsql.hrl").
 
 
 -define(host, "localhost").
 -define(host, "localhost").
 -define(port, 5432).
 -define(port, 5432).
 
 
+-define(ssl_apps, [crypto, public_key, ssl]).
+
 connect_test() ->
 connect_test() ->
     connect_only([]).
     connect_only([]).
 
 
@@ -48,7 +50,7 @@ connect_with_invalid_password_test() ->
 
 
 
 
 connect_with_ssl_test() ->
 connect_with_ssl_test() ->
-    lists:foreach(fun application:start/1, [crypto, ssl]),
+    lists:foreach(fun application:start/1, ?ssl_apps),
     with_connection(
     with_connection(
       fun(C) ->
       fun(C) ->
               {ok, _Cols, [{true}]} = pgsql:equery(C, "select ssl_is_used()")
               {ok, _Cols, [{true}]} = pgsql:equery(C, "select ssl_is_used()")
@@ -57,12 +59,12 @@ connect_with_ssl_test() ->
       [{ssl, true}]).
       [{ssl, true}]).
 
 
 connect_with_client_cert_test() ->
 connect_with_client_cert_test() ->
-    lists:foreach(fun application:start/1, [crypto, ssl]),
-
+    lists:foreach(fun application:start/1, ?ssl_apps),
     Dir = filename:join(filename:dirname(code:which(pgsql_tests)), "../test_data"),
     Dir = filename:join(filename:dirname(code:which(pgsql_tests)), "../test_data"),
     File = fun(Name) -> filename:join(Dir, Name) end,
     File = fun(Name) -> filename:join(Dir, Name) end,
-    {ok, [{cert, Der, _}]} = public_key:pem_to_der(File("epgsql.crt")),
-    {ok, Cert} = public_key:pkix_decode_cert(Der, plain),
+    {ok, Pem} = file:read_file(File("epgsql.crt")),
+    [{'Certificate', Der, not_encrypted}] = public_key:pem_decode(Pem),
+    Cert = public_key:pkix_decode_cert(Der, plain),
     #'TBSCertificate'{serialNumber = Serial} = Cert#'Certificate'.tbsCertificate,
     #'TBSCertificate'{serialNumber = Serial} = Cert#'Certificate'.tbsCertificate,
     Serial2 = list_to_binary(integer_to_list(Serial)),
     Serial2 = list_to_binary(integer_to_list(Serial)),
 
 
@@ -557,7 +559,7 @@ listen_notify_payload_test() ->
       [{async, self()}]).
       [{async, self()}]).
 
 
 application_test() ->
 application_test() ->
-    lists:foreach(fun application:start/1, [crypto, ssl]),
+    lists:foreach(fun application:start/1, ?ssl_apps),
     ok = application:start(epgsql).
     ok = application:start(epgsql).
 
 
 %% -- run all tests --
 %% -- run all tests --