Browse Source

accept new invalid_password error code added in 9.0

Will 15 years ago
parent
commit
8f5de83d95
2 changed files with 16 additions and 3 deletions
  1. 1 0
      src/pgsql_connection.erl
  2. 15 3
      test_src/pgsql_tests.erl

+ 1 - 0
src/pgsql_connection.erl

@@ -159,6 +159,7 @@ auth({$R, <<M:?int32, _/binary>>}, State) ->
 auth({error, E}, State) ->
     case E#error.code of
         <<"28000">> -> Why = invalid_authorization_specification;
+        <<"28P01">> -> Why = invalid_password;
         Any         -> Why = Any
     end,
     gen_fsm:reply(State#state.reply_to, {error, Why}),

+ 15 - 3
test_src/pgsql_tests.erl

@@ -28,13 +28,25 @@ connect_with_md5_test() ->
                   "epgsql_test_md5",
                   [{database, "epgsql_test_db1"}]]).
 
-connect_with_invalid_password_test() ->
+connect_with_invalid_user_test() ->
     {error, invalid_authorization_specification} =
         pgsql:connect(?host,
-                      "epgsql_test_md5",
-                      "epgsql_test_sha1",
+                      "epgsql_test_invalid",
+                      "epgsql_test_invalid",
                       [{port, ?port}, {database, "epgsql_test_db1"}]).
 
+connect_with_invalid_password_test() ->
+    {error, Why} =
+        pgsql:connect(?host,
+                      "epgsql_test_md5",
+                      "epgsql_test_invalid",
+                      [{port, ?port}, {database, "epgsql_test_db1"}]),
+    case Why of
+        invalid_authorization_specification -> ok; % =< 8.4
+        invalid_password                    -> ok  % >= 9.0
+    end.
+
+
 connect_with_ssl_test() ->
     lists:foreach(fun application:start/1, [crypto, ssl]),
     with_connection(