Search in sources :

Example 16 with GDSServerVersion

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))));
}
Also used : GDSServerVersion(org.firebirdsql.gds.impl.GDSServerVersion) FBServiceManager(org.firebirdsql.management.FBServiceManager) Test(org.junit.Test)

Example 17 with GDSServerVersion

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))));
}
Also used : GDSServerVersion(org.firebirdsql.gds.impl.GDSServerVersion) FBServiceManager(org.firebirdsql.management.FBServiceManager) Test(org.junit.Test)

Example 18 with GDSServerVersion

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());
    }
}
Also used : GDSServerVersion(org.firebirdsql.gds.impl.GDSServerVersion) FBManagedConnection(org.firebirdsql.jaybird.xca.FBManagedConnection) JaybirdSystemProperties(org.firebirdsql.gds.JaybirdSystemProperties) IConnectionProperties(org.firebirdsql.gds.ng.IConnectionProperties) Properties(java.util.Properties) FBTestProperties(org.firebirdsql.common.FBTestProperties) Test(org.junit.Test)

Example 19 with GDSServerVersion

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");
        }
    }
}
Also used : GDSServerVersion(org.firebirdsql.gds.impl.GDSServerVersion) FBManagedConnection(org.firebirdsql.jaybird.xca.FBManagedConnection) JaybirdSystemProperties(org.firebirdsql.gds.JaybirdSystemProperties) IConnectionProperties(org.firebirdsql.gds.ng.IConnectionProperties) Properties(java.util.Properties) FBTestProperties(org.firebirdsql.common.FBTestProperties)

Example 20 with GDSServerVersion

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());
    }
}
Also used : GDSServerVersion(org.firebirdsql.gds.impl.GDSServerVersion) FBManagedConnection(org.firebirdsql.jaybird.xca.FBManagedConnection) JaybirdSystemProperties(org.firebirdsql.gds.JaybirdSystemProperties) IConnectionProperties(org.firebirdsql.gds.ng.IConnectionProperties) Properties(java.util.Properties) FBTestProperties(org.firebirdsql.common.FBTestProperties) Test(org.junit.Test)

Aggregations

GDSServerVersion (org.firebirdsql.gds.impl.GDSServerVersion)20 Test (org.junit.Test)17 FirebirdConnection (org.firebirdsql.jdbc.FirebirdConnection)4 FBServiceManager (org.firebirdsql.management.FBServiceManager)4 Connection (java.sql.Connection)3 Properties (java.util.Properties)3 FBTestProperties (org.firebirdsql.common.FBTestProperties)3 JaybirdSystemProperties (org.firebirdsql.gds.JaybirdSystemProperties)3 IConnectionProperties (org.firebirdsql.gds.ng.IConnectionProperties)3 FBManagedConnection (org.firebirdsql.jaybird.xca.FBManagedConnection)3 PooledConnection (javax.sql.PooledConnection)1 XAConnection (javax.sql.XAConnection)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1 MethodSource (org.junit.jupiter.params.provider.MethodSource)1