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.
π Destination Oracle: implemented connection encryption using Nβ¦ (airβ¦
β¦bytehq#6893) * airbytehq#6013 π Destination Oracle: implemented connection encryption using NNE and TLS
- Loading branch information
1 parent
c4d44bc
commit 06fd641
Showing
11 changed files
with
482 additions
and
184 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
78 changes: 78 additions & 0 deletions
78
...n/java/io/airbyte/integrations/destination/oracle/NneOracleDestinationAcceptanceTest.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,78 @@ | ||
/* | ||
* Copyright (c) 2021 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.integrations.destination.oracle; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.fasterxml.jackson.databind.node.ObjectNode; | ||
import com.google.common.collect.ImmutableMap; | ||
import io.airbyte.commons.json.Jsons; | ||
import io.airbyte.db.Databases; | ||
import io.airbyte.db.jdbc.JdbcDatabase; | ||
import java.sql.SQLException; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
import org.junit.Test; | ||
|
||
public class NneOracleDestinationAcceptanceTest extends UnencryptedOracleDestinationAcceptanceTest { | ||
|
||
@Test | ||
public void testEncryption() throws SQLException { | ||
String algorithm = "AES256"; | ||
|
||
final JsonNode config = getConfig(); | ||
((ObjectNode) config).put("encryption", Jsons.jsonNode(ImmutableMap.builder() | ||
.put("encryption_method", "client_nne") | ||
.put("encryption_algorithm", algorithm) | ||
.build())); | ||
|
||
JdbcDatabase database = Databases.createJdbcDatabase(config.get("username").asText(), | ||
config.get("password").asText(), | ||
String.format("jdbc:oracle:thin:@//%s:%s/%s", | ||
config.get("host").asText(), | ||
config.get("port").asText(), | ||
config.get("sid").asText()), | ||
"oracle.jdbc.driver.OracleDriver", | ||
"oracle.net.encryption_client=REQUIRED;" + | ||
"oracle.net.encryption_types_client=( " | ||
+ algorithm + " )"); | ||
|
||
String network_service_banner = "select network_service_banner from v$session_connect_info where sid in (select distinct sid from v$mystat)"; | ||
List<JsonNode> collect = database.query(network_service_banner).collect(Collectors.toList()); | ||
|
||
assertThat(collect.get(2).get("NETWORK_SERVICE_BANNER").asText(), | ||
equals("Oracle Advanced Security: " + algorithm + " encryption")); | ||
} | ||
|
||
@Test | ||
public void testCheckProtocol() throws SQLException { | ||
final JsonNode clone = Jsons.clone(getConfig()); | ||
((ObjectNode) clone).put("encryption", Jsons.jsonNode(ImmutableMap.builder() | ||
.put("encryption_method", "client_nne") | ||
.put("encryption_algorithm", "AES256") | ||
.build())); | ||
|
||
String algorithm = clone.get("encryption") | ||
.get("encryption_algorithm").asText(); | ||
|
||
JdbcDatabase database = Databases.createJdbcDatabase(clone.get("username").asText(), | ||
clone.get("password").asText(), | ||
String.format("jdbc:oracle:thin:@//%s:%s/%s", | ||
clone.get("host").asText(), | ||
clone.get("port").asText(), | ||
clone.get("sid").asText()), | ||
"oracle.jdbc.driver.OracleDriver", | ||
"oracle.net.encryption_client=REQUIRED;" + | ||
"oracle.net.encryption_types_client=( " | ||
+ algorithm + " )"); | ||
|
||
String network_service_banner = "SELECT sys_context('USERENV', 'NETWORK_PROTOCOL') as network_protocol FROM dual"; | ||
List<JsonNode> collect = database.query(network_service_banner).collect(Collectors.toList()); | ||
|
||
assertEquals("tcp", collect.get(0).get("NETWORK_PROTOCOL").asText()); | ||
} | ||
} |
Oops, something went wrong.