use of org.firebirdsql.gds.impl.GDSServerVersion in project jaybird by FirebirdSQL.
the class Firebird3PlusAuthenticationTest method authenticateServiceUsingLegacyAuth.
/**
* This test assumes that the Firebird 3 config for {@code UserManager} contains {@code Legacy_UserManager}.
* <p>
* Replicates the test of {@code FBServiceManagerTest.testGetServerVersion()}.
* </p>
*/
@Test
public void authenticateServiceUsingLegacyAuth() throws Exception {
final String username = "legacyauth";
final String password = "legacy";
databaseUserRule.createUser(username, password, "Legacy_UserManager");
final FBServiceManager fbServiceManager = new FBServiceManager(FBTestProperties.getGdsType());
fbServiceManager.setServerName(FBTestProperties.DB_SERVER_URL);
fbServiceManager.setPortNumber(FBTestProperties.DB_SERVER_PORT);
fbServiceManager.setUser(username);
fbServiceManager.setPassword(password);
fbServiceManager.setAuthPlugins("Legacy_Auth");
final GDSServerVersion serverVersion = fbServiceManager.getServerVersion();
assertThat(serverVersion, allOf(notNullValue(), not(equalTo(GDSServerVersion.INVALID_VERSION))));
}
use of org.firebirdsql.gds.impl.GDSServerVersion in project jaybird by FirebirdSQL.
the class Firebird3PlusAuthenticationTest method authenticateServiceUsingSrpAuth.
/**
* This test assumes that the Firebird 3 config for {@code UserManager} contains {@code Srp}.
* <p>
* Replicates the test of {@code FBServiceManagerTest.testGetServerVersion()}.
* </p>
*/
@Test
public void authenticateServiceUsingSrpAuth() throws Exception {
final String username = "srpauth";
final String password = "srp";
databaseUserRule.createUser(username, password, "Srp");
final FBServiceManager fbServiceManager = new FBServiceManager(FBTestProperties.getGdsType());
fbServiceManager.setServerName(FBTestProperties.DB_SERVER_URL);
fbServiceManager.setPortNumber(FBTestProperties.DB_SERVER_PORT);
fbServiceManager.setUser(username);
fbServiceManager.setPassword(password);
final GDSServerVersion serverVersion = fbServiceManager.getServerVersion();
assertThat(serverVersion, allOf(notNullValue(), not(equalTo(GDSServerVersion.INVALID_VERSION))));
}
use of org.firebirdsql.gds.impl.GDSServerVersion in project jaybird by FirebirdSQL.
the class FBConnectionTest method testWireCompression.
@Test
public void testWireCompression() throws Exception {
assumeThat("Test only works with pure java connections", FBTestProperties.GDS_TYPE, isPureJavaType());
assumeTrue("Test requires wire compression", getDefaultSupportInfo().supportsWireCompression());
Properties props = getDefaultPropertiesForConnection();
props.setProperty("wireCompression", "true");
try (Connection connection = DriverManager.getConnection(getUrl(), props)) {
assertTrue(connection.isValid(0));
GDSServerVersion serverVersion = connection.unwrap(FirebirdConnection.class).getFbDatabase().getServerVersion();
assertTrue("expected wire compression in use", serverVersion.isWireCompressionUsed());
}
}
use of org.firebirdsql.gds.impl.GDSServerVersion in project jaybird by FirebirdSQL.
the class FBConnectionTest method testWireCrypt_FB3_0_and_later.
private void testWireCrypt_FB3_0_and_later(WireCrypt wireCrypt) {
assumeThat("Test doesn't work with embedded", FBTestProperties.GDS_TYPE, not(isEmbeddedType()));
assumeTrue("Test for Firebird versions with wire encryption support", getDefaultSupportInfo().supportsWireEncryption());
Properties props = getDefaultPropertiesForConnection();
props.setProperty("wireCrypt", wireCrypt.name());
try (Connection connection = DriverManager.getConnection(getUrl(), props)) {
assertTrue(connection.isValid(0));
GDSServerVersion serverVersion = connection.unwrap(FirebirdConnection.class).getFbDatabase().getServerVersion();
boolean encryptionUsed = serverVersion.isWireEncryptionUsed();
switch(wireCrypt) {
case DEFAULT:
case ENABLED:
if (!encryptionUsed) {
System.err.println("WARNING: wire encryption level " + wireCrypt + " requested, but no encryption " + "used. Consider re-running the test with a WireCrypt=Enabled in firebird.conf");
}
// intentional fall-through
case REQUIRED:
assertTrue("Expected wire encryption to be used for wireCrypt=" + wireCrypt, encryptionUsed);
break;
case DISABLED:
assertFalse("Expected wire encryption not to be used for wireCrypt=" + wireCrypt, encryptionUsed);
}
} catch (SQLException e) {
if (e.getErrorCode() == ISCConstants.isc_wirecrypt_incompatible) {
System.err.println("WARNING: wire encryption level " + wireCrypt + " requested, but rejected by server." + " Consider re-running the test with a WireCrypt=Enabled in firebird.conf");
}
}
}
use of org.firebirdsql.gds.impl.GDSServerVersion in project jaybird by FirebirdSQL.
the class FBConnectionTest method legacyAuthUserWithWireCrypt_ENABLED_canCreateConnection.
@Test
public void legacyAuthUserWithWireCrypt_ENABLED_canCreateConnection() throws Exception {
assumeTrue("Test for Firebird versions with wire encryption support", getDefaultSupportInfo().supportsWireEncryption());
final String user = "legacy_auth";
final String password = "leg_auth";
databaseUserRule.createUser(user, password, "Legacy_UserManager");
Properties props = getDefaultPropertiesForConnection();
props.setProperty("user", user);
props.setProperty("password", password);
props.setProperty("wireCrypt", "ENABLED");
props.setProperty("authPlugins", "Legacy_Auth");
try (Connection connection = DriverManager.getConnection(getUrl(), props)) {
assertTrue(connection.isValid(0));
GDSServerVersion serverVersion = connection.unwrap(FirebirdConnection.class).getFbDatabase().getServerVersion();
assertFalse("Expected wire encryption not to be used when connecting with legacy auth user", serverVersion.isWireEncryptionUsed());
}
}
Aggregations