Browse Source

Fix 'Access denied' test case failing on MariaDB

When logging in as a non-existent user, MariaDB (tested with
version 10.3.13) returns the error "Client does not support
authentication protocol requested by server[...]" instead
of "Access denied[...]". This commit updates the test case
to accept both variants.
Viktor Söderqvist 5 years ago
parent
commit
d15b552585
1 changed files with 10 additions and 3 deletions
  1. 10 3
      test/mysql_tests.erl

+ 10 - 3
test/mysql_tests.erl

@@ -47,10 +47,17 @@
 
 
 failing_connect_test() ->
 failing_connect_test() ->
     process_flag(trap_exit, true),
     process_flag(trap_exit, true),
-    ?assertMatch({error, {1045, <<"28000">>, <<"Access denied", _/binary>>}},
-                 mysql:start_link([{user, "dummy"}, {password, "junk"}])),
+    {error, Error} = mysql:start_link([{user, "dummy"}, {password, "junk"}]),
+    case Error of
+        {1045, <<"28000">>, <<"Access denie", _/binary>>} ->
+            ok; % MySQL 5.x, etc.
+        {1251, <<"08004">>, <<"Client does not support authentication "
+                              "protocol requested by server; consider "
+                              "upgrading MariaDB client">>} ->
+            ok % MariaDB 10.3.13
+    end,
     receive
     receive
-        {'EXIT', _Pid, {1045, <<"28000">>, <<"Access denie", _/binary>>}} -> ok
+        {'EXIT', _Pid, Error} -> ok
     after 1000 ->
     after 1000 ->
         error(no_exit_message)
         error(no_exit_message)
     end,
     end,