|
26 | 26 | import org.firebirdsql.gds.JaybirdErrorCodes; |
27 | 27 | import org.firebirdsql.gds.TransactionParameterBuffer; |
28 | 28 | import org.firebirdsql.gds.ng.wire.auth.legacy.LegacyAuthenticationPluginSpi; |
29 | | -import org.firebirdsql.gds.ng.wire.auth.srp.*; |
| 29 | +import org.firebirdsql.gds.ng.wire.auth.srp.Srp224AuthenticationPluginSpi; |
| 30 | +import org.firebirdsql.gds.ng.wire.auth.srp.Srp256AuthenticationPluginSpi; |
| 31 | +import org.firebirdsql.gds.ng.wire.auth.srp.Srp384AuthenticationPluginSpi; |
| 32 | +import org.firebirdsql.gds.ng.wire.auth.srp.Srp512AuthenticationPluginSpi; |
| 33 | +import org.firebirdsql.gds.ng.wire.auth.srp.SrpAuthenticationPluginSpi; |
| 34 | +import org.firebirdsql.jaybird.props.PropertyNames; |
30 | 35 | import org.firebirdsql.util.FirebirdSupportInfo; |
31 | 36 | import org.junit.jupiter.api.Test; |
32 | 37 | import org.junit.jupiter.api.extension.RegisterExtension; |
|
37 | 42 | import java.lang.reflect.InvocationTargetException; |
38 | 43 | import java.lang.reflect.Method; |
39 | 44 | import java.sql.*; |
40 | | -import java.util.*; |
| 45 | +import java.util.Calendar; |
| 46 | +import java.util.GregorianCalendar; |
| 47 | +import java.util.HashMap; |
| 48 | +import java.util.Map; |
| 49 | +import java.util.Properties; |
| 50 | +import java.util.TimeZone; |
41 | 51 | import java.util.stream.Stream; |
42 | 52 |
|
43 | | -import static org.firebirdsql.common.FBTestProperties.*; |
| 53 | +import static org.firebirdsql.common.FBTestProperties.GDS_TYPE; |
| 54 | +import static org.firebirdsql.common.FBTestProperties.getConnectionViaDriverManager; |
| 55 | +import static org.firebirdsql.common.FBTestProperties.getDefaultPropertiesForConnection; |
| 56 | +import static org.firebirdsql.common.FBTestProperties.getDefaultSupportInfo; |
| 57 | +import static org.firebirdsql.common.FBTestProperties.getUrl; |
44 | 58 | import static org.firebirdsql.common.FbAssumptions.assumeFeature; |
45 | 59 | import static org.firebirdsql.common.assertions.CustomAssertions.assertThrowsForAutoCloseable; |
46 | 60 | import static org.firebirdsql.common.matchers.GdsTypeMatchers.isEmbeddedType; |
47 | 61 | import static org.firebirdsql.common.matchers.GdsTypeMatchers.isPureJavaType; |
48 | 62 | import static org.firebirdsql.common.matchers.MatcherAssume.assumeThat; |
49 | | -import static org.firebirdsql.common.matchers.SQLExceptionMatchers.*; |
50 | | -import static org.firebirdsql.jaybird.fb.constants.TpbItems.*; |
51 | | -import static org.hamcrest.CoreMatchers.*; |
| 63 | +import static org.firebirdsql.common.matchers.SQLExceptionMatchers.errorCodeEquals; |
| 64 | +import static org.firebirdsql.common.matchers.SQLExceptionMatchers.getFbMessage; |
| 65 | +import static org.firebirdsql.common.matchers.SQLExceptionMatchers.message; |
| 66 | +import static org.firebirdsql.common.matchers.SQLExceptionMatchers.sqlState; |
| 67 | +import static org.firebirdsql.jaybird.fb.constants.TpbItems.isc_tpb_no_rec_version; |
| 68 | +import static org.firebirdsql.jaybird.fb.constants.TpbItems.isc_tpb_nowait; |
| 69 | +import static org.firebirdsql.jaybird.fb.constants.TpbItems.isc_tpb_read_committed; |
| 70 | +import static org.firebirdsql.jaybird.fb.constants.TpbItems.isc_tpb_write; |
| 71 | +import static org.hamcrest.CoreMatchers.allOf; |
| 72 | +import static org.hamcrest.CoreMatchers.containsString; |
| 73 | +import static org.hamcrest.CoreMatchers.is; |
| 74 | +import static org.hamcrest.CoreMatchers.isA; |
| 75 | +import static org.hamcrest.CoreMatchers.not; |
| 76 | +import static org.hamcrest.CoreMatchers.startsWith; |
52 | 77 | import static org.hamcrest.MatcherAssert.assertThat; |
53 | 78 | import static org.junit.jupiter.api.Assertions.assertEquals; |
54 | 79 | import static org.junit.jupiter.api.Assertions.assertFalse; |
@@ -530,5 +555,25 @@ void testNonAsciiLegacyAuth(String password) throws Exception { |
530 | 555 | } |
531 | 556 | } |
532 | 557 |
|
| 558 | + /** |
| 559 | + * Rationale: see <a href="https://github.com/FirebirdSQL/jaybird/issues/940">jaybird#940</a>. |
| 560 | + * <p> |
| 561 | + * NOTE: The original problem (throwing a {@code NullPointerException}) this test checks for was only reproduced |
| 562 | + * with {@code AuthServer = Srp256} <em>if</em> {@code enableProtocol} is not set or does not enable protocol 10. |
| 563 | + * Having multiple authentication plugins configured server-side will make it work because then authentication will |
| 564 | + * only fail after the <em>identify</em> phase. In other words, in our regular test setup, this test will not |
| 565 | + * reproduce this error if it ever regresses. |
| 566 | + * </p> |
| 567 | + */ |
| 568 | + @Test |
| 569 | + void testUserDoesNotExist_enableProtocolNotSet() { |
| 570 | + var props = new Properties(); |
| 571 | + props.setProperty(PropertyNames.user, "doesnotexist"); |
| 572 | + props.setProperty(PropertyNames.password, "password"); |
| 573 | + |
| 574 | + assertThrows(SQLInvalidAuthorizationSpecException.class, |
| 575 | + () -> DriverManager.getConnection(getUrl(), props)); |
| 576 | + } |
| 577 | + |
533 | 578 | } |
534 | 579 |
|
0 commit comments