File tree Expand file tree Collapse file tree 2 files changed +31
-1
lines changed
test/java/com/github/jasync/r2dbc/mysql Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ import io.r2dbc.spi.ConnectionFactoryOptions.USER
15
15
import io.r2dbc.spi.ConnectionFactoryProvider
16
16
import io.r2dbc.spi.Option
17
17
import mu.KotlinLogging
18
+ import java.nio.file.Paths
18
19
import java.time.Duration
19
20
import kotlin.properties.ReadWriteProperty
20
21
import kotlin.reflect.KProperty
@@ -30,6 +31,12 @@ class MysqlConnectionFactoryProvider : ConnectionFactoryProvider {
30
31
@JvmField
31
32
val APPLICATION_NAME : Option <String > = Option .valueOf(" applicationName" )
32
33
34
+ /* *
35
+ * Server rsa public key file.
36
+ */
37
+ @JvmField
38
+ val SERVER_RSA_PUBLIC_KEY_FILE : Option <String > = Option .valueOf(" serverRSAPublicKeyFile" )
39
+
33
40
/* *
34
41
* Driver option value.
35
42
*/
@@ -72,7 +79,8 @@ class MysqlConnectionFactoryProvider : ConnectionFactoryProvider {
72
79
applicationName = connectionFactoryOptions.getValue(APPLICATION_NAME ) as String? ,
73
80
connectionTimeout = (connectionFactoryOptions.getValue(CONNECT_TIMEOUT ) as Duration ? )?.toMillis()?.toInt() ? : 5000 ,
74
81
queryTimeout = connectionFactoryOptions.getValue(STATEMENT_TIMEOUT ) as Duration ? ,
75
- ssl = MysqlSSLConfigurationFactory .create(connectionFactoryOptions)
82
+ ssl = MysqlSSLConfigurationFactory .create(connectionFactoryOptions),
83
+ rsaPublicKey = (connectionFactoryOptions.getValue(SERVER_RSA_PUBLIC_KEY_FILE ) as String? )?.let { Paths .get(it) }
76
84
)
77
85
return JasyncConnectionFactory (MySQLConnectionFactory (configuration))
78
86
}
Original file line number Diff line number Diff line change @@ -41,4 +41,26 @@ class MysqlConnectionFactoryProviderTest {
41
41
// then
42
42
assertEquals(3307 , result.mySQLConnectionFactory.configuration.port)
43
43
}
44
+
45
+ @Test
46
+ fun shouldNotUseWhenRsaPublicKeyIsNotSpecified () {
47
+ val options = ConnectionFactoryOptions .parse(" r2dbc:mysql://user@host/" )
48
+
49
+ // when
50
+ val result = provider.create(options)
51
+
52
+ // then
53
+ assertEquals(null , result.mySQLConnectionFactory.configuration.rsaPublicKey)
54
+ }
55
+
56
+ @Test
57
+ fun shouldUseSpecifiedRsaPublicKey () {
58
+ val options = ConnectionFactoryOptions .parse(" r2dbc:mysql://user@host/db?serverRSAPublicKeyFile=rsa.pem" )
59
+
60
+ // when
61
+ val result = provider.create(options)
62
+
63
+ // then
64
+ assertEquals(" rsa.pem" , result.mySQLConnectionFactory.configuration.rsaPublicKey.toString())
65
+ }
44
66
}
You can’t perform that action at this time.
0 commit comments