forked from airbytehq/airbyte
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🎉Source MySQL - added option to connect using SSL (airbytehq#6510)
* Source MySQL - added option to connect using SSL
- Loading branch information
Showing
10 changed files
with
181 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
...t-integration/java/io/airbyte/integrations/source/mysql/MySqlSslSourceAcceptanceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
* MIT License | ||
* | ||
* Copyright (c) 2020 Airbyte | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
|
||
package io.airbyte.integrations.source.mysql; | ||
|
||
import static io.airbyte.integrations.source.mysql.MySqlSource.SSL_PARAMETERS; | ||
|
||
import com.google.common.collect.ImmutableMap; | ||
import io.airbyte.commons.json.Jsons; | ||
import io.airbyte.db.Database; | ||
import io.airbyte.db.Databases; | ||
import io.airbyte.integrations.source.mysql.MySqlSource.ReplicationMethod; | ||
import io.airbyte.integrations.standardtest.source.TestDestinationEnv; | ||
import org.jooq.SQLDialect; | ||
import org.testcontainers.containers.MySQLContainer; | ||
|
||
public class MySqlSslSourceAcceptanceTest extends MySqlSourceAcceptanceTest { | ||
|
||
@Override | ||
protected void setupEnvironment(TestDestinationEnv environment) throws Exception { | ||
container = new MySQLContainer<>("mysql:8.0"); | ||
container.start(); | ||
|
||
config = Jsons.jsonNode(ImmutableMap.builder() | ||
.put("host", container.getHost()) | ||
.put("port", container.getFirstMappedPort()) | ||
.put("database", container.getDatabaseName()) | ||
.put("username", container.getUsername()) | ||
.put("password", container.getPassword()) | ||
.put("ssl", true) | ||
.put("replication_method", ReplicationMethod.STANDARD) | ||
.build()); | ||
|
||
final Database database = Databases.createDatabase( | ||
config.get("username").asText(), | ||
config.get("password").asText(), | ||
String.format("jdbc:mysql://%s:%s/%s?%s", | ||
config.get("host").asText(), | ||
config.get("port").asText(), | ||
config.get("database").asText(), | ||
String.join("&", SSL_PARAMETERS)), | ||
"com.mysql.cj.jdbc.Driver", | ||
SQLDialect.MYSQL); | ||
|
||
database.query(ctx -> { | ||
ctx.fetch("CREATE TABLE id_and_name(id INTEGER, name VARCHAR(200));"); | ||
ctx.fetch( | ||
"INSERT INTO id_and_name (id, name) VALUES (1,'picard'), (2, 'crusher'), (3, 'vash');"); | ||
ctx.fetch("CREATE TABLE starships(id INTEGER, name VARCHAR(200));"); | ||
ctx.fetch( | ||
"INSERT INTO starships (id, name) VALUES (1,'enterprise-d'), (2, 'defiant'), (3, 'yamato');"); | ||
return null; | ||
}); | ||
|
||
database.close(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
.../src/test/java/io/airbyte/integrations/source/mysql/MySqlSslJdbcSourceAcceptanceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* MIT License | ||
* | ||
* Copyright (c) 2020 Airbyte | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
|
||
package io.airbyte.integrations.source.mysql; | ||
|
||
import static io.airbyte.integrations.source.mysql.MySqlSource.SSL_PARAMETERS; | ||
|
||
import com.google.common.collect.ImmutableMap; | ||
import io.airbyte.commons.json.Jsons; | ||
import io.airbyte.commons.string.Strings; | ||
import io.airbyte.db.Databases; | ||
import org.jooq.SQLDialect; | ||
import org.junit.jupiter.api.BeforeEach; | ||
|
||
class MySqlSslJdbcSourceAcceptanceTest extends MySqlJdbcSourceAcceptanceTest { | ||
|
||
@BeforeEach | ||
public void setup() throws Exception { | ||
config = Jsons.jsonNode(ImmutableMap.builder() | ||
.put("host", container.getHost()) | ||
.put("port", container.getFirstMappedPort()) | ||
.put("database", Strings.addRandomSuffix("db", "_", 10)) | ||
.put("username", TEST_USER) | ||
.put("password", TEST_PASSWORD) | ||
.put("ssl", true) | ||
.build()); | ||
|
||
database = Databases.createDatabase( | ||
config.get("username").asText(), | ||
config.get("password").asText(), | ||
String.format("jdbc:mysql://%s:%s?%s", | ||
config.get("host").asText(), | ||
config.get("port").asText(), | ||
String.join("&", SSL_PARAMETERS)), | ||
MySqlSource.DRIVER_CLASS, | ||
|
||
SQLDialect.MYSQL); | ||
|
||
database.query(ctx -> { | ||
ctx.fetch("CREATE DATABASE " + config.get("database").asText()); | ||
ctx.fetch("SHOW STATUS LIKE 'Ssl_cipher'"); | ||
return null; | ||
}); | ||
database.close(); | ||
|
||
super.setup(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters