Skip to content

Commit

Permalink
Fix for AuthenticationTest.testWl14650() failures when running in Doc…
Browse files Browse the repository at this point in the history
…ker.

Change-Id: I24eb516341400300de874327113ccc619f073b62
  • Loading branch information
fjssilva committed May 27, 2022
1 parent 3659ab5 commit 0604bf4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 18 deletions.
2 changes: 1 addition & 1 deletion build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1241,7 +1241,7 @@ See also com.mysql.cj.conf.PropertyDefinitions.SYSP_* variables for other test o
<available file="${com.mysql.cj.extra.libs}/ant/junit-frames.xsl" type="file" />
</condition>

<target name="-check-custom-xslt" unless="file.exists">
<target name="-check-custom-xslt">
<available property="custom.xslt.exists" file="${com.mysql.cj.extra.libs}/ant/junit-frames.xsl" type="file" />
</target>

Expand Down
26 changes: 9 additions & 17 deletions src/test/java/testsuite/simple/AuthenticationTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, 2021, Oracle and/or its affiliates.
* Copyright (c) 2020, 2022, Oracle and/or its affiliates.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, version 2.0, as published by the
Expand Down Expand Up @@ -605,19 +605,16 @@ public void testWl14650() throws Exception {

// TS.1.2: 2FA fail - 1st password wrong.
props.setProperty(PropertyKey.password1.getKeyName(), "wrongpwd");
assertThrows(SQLException.class, "Access denied for user 'wl14650_2fa'@'localhost' \\(using password: YES\\)",
() -> getConnectionWithProps(url1, props));
assertThrows(SQLException.class, "Access denied for user 'wl14650_2fa'@.* \\(using password: YES\\)", () -> getConnectionWithProps(url1, props));

// TS.1.3: 2FA fail - 2nd password wrong.
props.setProperty(PropertyKey.password1.getKeyName(), "testpwd1");
props.setProperty(PropertyKey.password2.getKeyName(), "wrongpwd");
assertThrows(SQLException.class, "Access denied for user 'wl14650_2fa'@'localhost' \\(using password: YES\\)",
() -> getConnectionWithProps(url1, props));
assertThrows(SQLException.class, "Access denied for user 'wl14650_2fa'@.* \\(using password: YES\\)", () -> getConnectionWithProps(url1, props));

// TS.1.4: 2FA fail - missing required password.
props.remove(PropertyKey.password2.getKeyName());
assertThrows(SQLException.class, "Access denied for user 'wl14650_2fa'@'localhost' \\(using password: YES\\)",
() -> getConnectionWithProps(url1, props));
assertThrows(SQLException.class, "Access denied for user 'wl14650_2fa'@.* \\(using password: YES\\)", () -> getConnectionWithProps(url1, props));

// TS.2.1: 3FA successful.
props.setProperty(PropertyKey.USER.getKeyName(), "wl14650_3fa");
Expand All @@ -635,25 +632,21 @@ public void testWl14650() throws Exception {

// TS.2.2: 2FA fail - 1st password wrong.
props.setProperty(PropertyKey.password1.getKeyName(), "wrongpwd");
assertThrows(SQLException.class, "Access denied for user 'wl14650_3fa'@'localhost' \\(using password: YES\\)",
() -> getConnectionWithProps(url1, props));
assertThrows(SQLException.class, "Access denied for user 'wl14650_3fa'@.* \\(using password: YES\\)", () -> getConnectionWithProps(url1, props));

// TS.2.3: 2FA fail - 2nd password wrong.
props.setProperty(PropertyKey.password1.getKeyName(), "testpwd1");
props.setProperty(PropertyKey.password2.getKeyName(), "wrongpwd");
assertThrows(SQLException.class, "Access denied for user 'wl14650_3fa'@'localhost' \\(using password: YES\\)",
() -> getConnectionWithProps(url1, props));
assertThrows(SQLException.class, "Access denied for user 'wl14650_3fa'@.* \\(using password: YES\\)", () -> getConnectionWithProps(url1, props));

// TS.2.4: 2FA fail - 3rd password wrong.
props.setProperty(PropertyKey.password2.getKeyName(), "testpwd2");
props.setProperty(PropertyKey.password3.getKeyName(), "wrongpwd");
assertThrows(SQLException.class, "Access denied for user 'wl14650_3fa'@'localhost' \\(using password: YES\\)",
() -> getConnectionWithProps(url1, props));
assertThrows(SQLException.class, "Access denied for user 'wl14650_3fa'@.* \\(using password: YES\\)", () -> getConnectionWithProps(url1, props));

// TS.2.5: 2FA fail - missing required password.
props.remove(PropertyKey.password3.getKeyName());
assertThrows(SQLException.class, "Access denied for user 'wl14650_3fa'@'localhost' \\(using password: YES\\)",
() -> getConnectionWithProps(url1, props));
assertThrows(SQLException.class, "Access denied for user 'wl14650_3fa'@.* \\(using password: YES\\)", () -> getConnectionWithProps(url1, props));

// TS.3/TS.4/TS.5: new password options don't pollute original ones.
props.setProperty(PropertyKey.USER.getKeyName(), "wl14650_1fa");
Expand Down Expand Up @@ -732,8 +725,7 @@ public void testWl14650() throws Exception {
final StringBuilder urlBuilder7 = new StringBuilder("jdbc:mysql://").append(getHostFromTestsuiteUrl()).append(":").append(getPortFromTestsuiteUrl())
.append("/");
final String url7 = urlBuilder7.toString();
assertThrows(SQLException.class, "Access denied for user 'wl14650_1fa'@'localhost' \\(using password: YES\\)",
() -> getConnectionWithProps(url7, props));
assertThrows(SQLException.class, "Access denied for user 'wl14650_1fa'@.* \\(using password: YES\\)", () -> getConnectionWithProps(url7, props));
} finally {
if (installPluginInRuntime) {
this.stmt.executeUpdate("UNINSTALL PLUGIN cleartext_plugin_server");
Expand Down

0 comments on commit 0604bf4

Please sign in to comment.