Skip to content

Commit 1e1865a

Browse files
Roland Kalmarsagarp337
authored andcommitted
Added - Remove hardcoded passwords from golden_gate integration test codes
1 parent 86c6204 commit 1e1865a

File tree

4 files changed

+49
-32
lines changed

4 files changed

+49
-32
lines changed

internal/integrationtest/golden_gate_connection_test.go

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ Following environment variables are required:
3232
- TF_VAR_vault_id
3333
- TF_VAR_subnet_id
3434
- TF_VAR_oracle_wallet - for oracle connection creation
35+
- TF_VAR_password - password used for create connection, due to sec central issues, we must use environment variables instead of hardcoded passwords
36+
- TF_VAR_new_password - new password used for update connection, due to sec central issues, we must use environment variables instead of hardcoded passwords
37+
"
3538
*/
3639
import (
3740
"context"
@@ -140,7 +143,7 @@ var (
140143
Create: `jdbc:sqlserver://ws1.sql.azuresynapse.net:1433;database=db1;encrypt=true;trustServerCertificate=false;hostNameInCertificate=*.sql.azuresynapse.net;loginTimeout=300;'`,
141144
Update: `jdbc:sqlserver://ws1.sql.azuresynapse.net:1433;database=db2;encrypt=true;trustServerCertificate=false;hostNameInCertificate=*.sql.azuresynapse.net;loginTimeout=300;'`},
142145
"username": acctest.Representation{RepType: acctest.Required, Create: `user`, Update: `updatedUser`},
143-
"password": acctest.Representation{RepType: acctest.Required, Create: `mypassword`, Update: `newpassword`},
146+
"password": acctest.Representation{RepType: acctest.Required, Create: `${var.password}`, Update: `${var.new_password}`},
144147
},
145148
},
146149

@@ -149,7 +152,7 @@ var (
149152
representation: map[string]interface{}{
150153
"host": acctest.Representation{RepType: acctest.Required, Create: `goldengate.oci.oraclecloud.com`, Update: `goldengate2.oci.oraclecloud.com`},
151154
"port": acctest.Representation{RepType: acctest.Required, Create: `9090`, Update: `9091`},
152-
"password": acctest.Representation{RepType: acctest.Required, Create: `mypassword`, Update: `newpassword`},
155+
"password": acctest.Representation{RepType: acctest.Required, Create: `${var.password}`, Update: `${var.new_password}`},
153156
"username": acctest.Representation{RepType: acctest.Required, Create: `user`, Update: `updatedUser`},
154157
"private_ip": acctest.Representation{RepType: acctest.Required, Create: `10.0.0.1`, Update: `10.0.0.2`},
155158
},
@@ -172,7 +175,7 @@ var (
172175
"should_use_jndi": acctest.Representation{RepType: acctest.Required, Create: `false`},
173176
"connection_url": acctest.Representation{RepType: acctest.Required, Create: `mq://foo.bar.com:7676`, Update: `mq://foo.bar.com:7677`},
174177
"connection_factory": acctest.Representation{RepType: acctest.Required, Create: `com.stc.jmsjca.core.JConnectionFactoryXA`, Update: `mq://foo.bar.com:7677`},
175-
"password": acctest.Representation{RepType: acctest.Required, Create: `mypassword`, Update: `newpassword`},
178+
"password": acctest.Representation{RepType: acctest.Required, Create: `${var.password}`, Update: `${var.new_password}`},
176179
"username": acctest.Representation{RepType: acctest.Required, Create: `user`, Update: `updatedUser`},
177180
"private_ip": acctest.Representation{RepType: acctest.Required, Create: `10.0.0.1`, Update: `10.0.0.2`},
178181
},
@@ -183,7 +186,7 @@ var (
183186
representation: map[string]interface{}{
184187
"security_protocol": acctest.Representation{RepType: acctest.Required, Create: string(oci_golden_gate.KafkaConnectionSecurityProtocolSaslSsl)},
185188
"username": acctest.Representation{RepType: acctest.Required, Create: `username`, Update: `newUsername`},
186-
"password": acctest.Representation{RepType: acctest.Required, Create: `password`, Update: `newPassword`},
189+
"password": acctest.Representation{RepType: acctest.Required, Create: `${var.password}`, Update: `${var.new_password}`},
187190
"bootstrap_servers": acctest.RepresentationGroup{RepType: acctest.Required, Group: map[string]interface{}{
188191
"host": acctest.Representation{RepType: acctest.Required, Create: `whatever.fqdn.oraclecloud.com`},
189192
"port": acctest.Representation{RepType: acctest.Required, Create: `9093`},
@@ -198,7 +201,7 @@ var (
198201
representation: map[string]interface{}{
199202
"authentication_type": acctest.Representation{RepType: acctest.Required, Create: string(oci_golden_gate.KafkaSchemaRegistryConnectionAuthenticationTypeBasic)},
200203
"username": acctest.Representation{RepType: acctest.Required, Create: `username`, Update: `newUsername`},
201-
"password": acctest.Representation{RepType: acctest.Required, Create: `password`, Update: `newPassword`},
204+
"password": acctest.Representation{RepType: acctest.Required, Create: `${var.password}`, Update: `${var.new_password}`},
202205
"url": acctest.Representation{RepType: acctest.Required, Create: `https://10.1.1.1:9091`, Update: `https://10.1.1.2:9091`},
203206
},
204207
},
@@ -211,26 +214,26 @@ var (
211214
"host": acctest.Representation{RepType: acctest.Required, Create: `whatever.fqdn.com`, Update: `whatever.fqdn.com`},
212215
"port": acctest.Representation{RepType: acctest.Required, Create: `10000`, Update: `10001`},
213216
"username": acctest.Representation{RepType: acctest.Required, Create: `username`, Update: `newUsername`},
214-
"password": acctest.Representation{RepType: acctest.Required, Create: `password`, Update: `newPassword`},
217+
"password": acctest.Representation{RepType: acctest.Required, Create: `${var.password}`, Update: `${var.new_password}`},
215218
"private_ip": acctest.Representation{RepType: acctest.Required, Create: `10.0.0.1`, Update: `10.0.0.2`},
216219
},
217220
},
218221

219222
// MongoDb
220223
{connectionType: oci_golden_gate.ConnectionTypeMongodb, technologyType: oci_golden_gate.TechnologyTypeMongodb,
221224
representation: map[string]interface{}{
222-
"connection_string": acctest.Representation{RepType: acctest.Required, Create: `mongodb://username:password@10.0.0.1:9000`,
223-
Update: `mongodb://newUsername:newPassword@10.0.0.1:9001`},
225+
"connection_string": acctest.Representation{RepType: acctest.Required, Create: `mongodb://10.0.0.1:9000`,
226+
Update: `mongodb://10.0.0.1:9001`},
224227
"username": acctest.Representation{RepType: acctest.Required, Create: `username`, Update: `newUsername`},
225-
"password": acctest.Representation{RepType: acctest.Required, Create: `password`, Update: `newPassword`},
228+
"password": acctest.Representation{RepType: acctest.Required, Create: `${var.password}`, Update: `${var.new_password}`},
226229
},
227230
},
228231

229232
// MYSQL
230233
{connectionType: oci_golden_gate.ConnectionTypeMysql, technologyType: oci_golden_gate.TechnologyTypeOciMysql,
231234
representation: map[string]interface{}{
232235
"username": acctest.Representation{RepType: acctest.Required, Create: `username`, Update: `newUsername`},
233-
"password": acctest.Representation{RepType: acctest.Required, Create: `password`, Update: `newPassword`},
236+
"password": acctest.Representation{RepType: acctest.Required, Create: `${var.password}`, Update: `${var.new_password}`},
234237
"database_name": acctest.Representation{RepType: acctest.Required, Create: `database`, Update: `anotherdatabase`},
235238
"security_protocol": acctest.Representation{RepType: acctest.Required, Create: string(oci_golden_gate.MysqlConnectionSecurityProtocolPlain)},
236239
"private_ip": acctest.Representation{RepType: acctest.Required, Create: `10.0.0.1`, Update: `10.0.0.2`},
@@ -247,7 +250,7 @@ var (
247250
"user_id": acctest.Representation{RepType: acctest.Required, Create: `ocid1.user.oc1..fakeaaaatswfukd4gymkjhngu3yp7galhoqzax6mi4ypgdt44ggbjaz2fake`,
248251
Update: `ocid1.user.oc2..fakeaaaatswfukd4gymkjhngu3yp7galhoqzax6mi4ypgdt44ggbjaz2fake`},
249252
"private_key_file": acctest.Representation{RepType: acctest.Required, Create: `my-private-key-file`, Update: `new-private-key-file`},
250-
"private_key_passphrase": acctest.Representation{RepType: acctest.Required, Create: `mypassphrase`, Update: `newpassphrase`},
253+
"private_key_passphrase": acctest.Representation{RepType: acctest.Required, Create: `${var.password}`, Update: `${var.new_password}`},
251254
"public_key_fingerprint": acctest.Representation{RepType: acctest.Required, Create: `myfingerprint`, Update: `newfingerprint`},
252255
},
253256
},
@@ -256,7 +259,7 @@ var (
256259
{connectionType: oci_golden_gate.ConnectionTypeOracle, technologyType: oci_golden_gate.TechnologyTypeAmazonRdsOracle,
257260
representation: map[string]interface{}{
258261
"username": acctest.Representation{RepType: acctest.Required, Create: `username`, Update: `newUsername`},
259-
"password": acctest.Representation{RepType: acctest.Required, Create: `password`, Update: `newPassword`},
262+
"password": acctest.Representation{RepType: acctest.Required, Create: `${var.password}`, Update: `${var.new_password}`},
260263
"session_mode": acctest.Representation{RepType: acctest.Required, Create: string(oci_golden_gate.OracleConnectionSessionModeDirect)},
261264
"connection_string": acctest.Representation{RepType: acctest.Required, Create: `alert-henry-IMUny-dev7-ggs.sub05140125230.integrationvcn.oraclevcn.com:1521/DB0609_phx2hg.sub05140125230.integrationvcn.oraclevcn.com`},
262265
"wallet": acctest.Representation{RepType: acctest.Required, Create: `${var.oracle_wallet}`},
@@ -283,7 +286,7 @@ var (
283286
"host": acctest.Representation{RepType: acctest.Required, Create: `whatever.fqdn.com`, Update: `whatever.fqdn.com`},
284287
"port": acctest.Representation{RepType: acctest.Required, Create: `10000`, Update: `10001`},
285288
"username": acctest.Representation{RepType: acctest.Required, Create: `admin`, Update: `new_admin`},
286-
"password": acctest.Representation{RepType: acctest.Required, Create: `mypassowrd`, Update: `updatedpassword`},
289+
"password": acctest.Representation{RepType: acctest.Required, Create: `${var.password}`, Update: `${var.new_password}`},
287290
"security_protocol": acctest.Representation{RepType: acctest.Required, Create: string(oci_golden_gate.PostgresqlConnectionSecurityProtocolPlain)},
288291
"private_ip": acctest.Representation{RepType: acctest.Required, Create: `10.0.0.1`, Update: `10.0.0.2`},
289292
},
@@ -296,7 +299,7 @@ var (
296299
Update: `jdbc:snowflake://myaccount.snowflakecomputing.com/?warehouse=dawarehous2&db=database2`},
297300
"authentication_type": acctest.Representation{RepType: acctest.Required, Create: string(oci_golden_gate.SnowflakeConnectionAuthenticationTypeBasic)},
298301
"username": acctest.Representation{RepType: acctest.Required, Create: `admin`, Update: `new_admin`},
299-
"password": acctest.Representation{RepType: acctest.Required, Create: `mypassowrd`, Update: `updatedpassword`},
302+
"password": acctest.Representation{RepType: acctest.Required, Create: `${var.password}`, Update: `${var.new_password}`},
300303
},
301304
},
302305
}
@@ -340,6 +343,8 @@ func TestGoldenGateConnectionResource_basic(t *testing.T) {
340343
CONNECTION_TYPE = "connection_type"
341344
TECHNOLOGY_TYPE = "technology_type"
342345
ORACLE_WALLET = "oracle_wallet"
346+
PASSWORD = "password"
347+
NEW_PASSWORD = "new_password"
343348
)
344349

345350
config := acctest.ProviderTestConfig() +
@@ -348,7 +353,9 @@ func TestGoldenGateConnectionResource_basic(t *testing.T) {
348353
makeVariableStr(KMS_KEY_ID, t) +
349354
makeVariableStr(SUBNET_ID, t) +
350355
makeVariableStr(VAULT_ID, t) +
351-
makeVariableStr(ORACLE_WALLET, t)
356+
makeVariableStr(ORACLE_WALLET, t) +
357+
makeVariableStr(PASSWORD, t) +
358+
makeVariableStr(NEW_PASSWORD, t)
352359

353360
var resId, resId2 string
354361
for _, connectionTestDescriptor := range ConnectionTestDescriptors {

internal/integrationtest/golden_gate_database_registration_test.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ func TestGoldenGateDatabaseRegistrationResource_basic(t *testing.T) {
4747
TEST_DB_ID = "test_db_id"
4848
KMS_KEY_ID = "kms_key_id"
4949
KMS_VAULT_ID = "kms_vault_id"
50+
PASSWORD = "password"
51+
NEW_PASSWORD = "new_password"
5052
)
5153

5254
var (
@@ -80,7 +82,7 @@ func TestGoldenGateDatabaseRegistrationResource_basic(t *testing.T) {
8082
"compartment_id": acctest.Representation{RepType: acctest.Required, Create: `${var.compartment_id}`},
8183
"display_name": acctest.Representation{RepType: acctest.Required, Create: `displayName`, Update: `displayName2`},
8284
"fqdn": acctest.Representation{RepType: acctest.Required, Create: `fqdn.example.com`, Update: `fqdn2.example.com`},
83-
"password": acctest.Representation{RepType: acctest.Required, Create: `BEstrO0ng_#11`, Update: `BEstrO0ng_#12`},
85+
"password": acctest.Representation{RepType: acctest.Required, Create: `${var.password}`, Update: `${var.new_password}`},
8486
"username": acctest.Representation{RepType: acctest.Required, Create: `username`, Update: `username2`},
8587
"connection_string": acctest.Representation{RepType: acctest.Optional, Create: `fqdn.example.com:1521/ORION_phx1gq.example.com`, Update: `fqdn2.example.com:1521/ORION_phx1gq.example.com`},
8688
"database_id": acctest.Representation{RepType: acctest.Optional, Create: `${var.test_db_id}`},
@@ -119,6 +121,8 @@ func TestGoldenGateDatabaseRegistrationResource_basic(t *testing.T) {
119121
makeVariableStr(TEST_DB_ID, t) +
120122
makeVariableStr(KMS_KEY_ID, t) +
121123
makeVariableStr(KMS_VAULT_ID, t) +
124+
makeVariableStr(PASSWORD, t) +
125+
makeVariableStr(NEW_PASSWORD, t) +
122126
DatabaseRegistrationResourceDependencies
123127

124128
// Save TF content to Create resource with optional properties. This has to be exactly the same as the config part in the "Create with optionals" step in the test.
@@ -135,7 +139,7 @@ func TestGoldenGateDatabaseRegistrationResource_basic(t *testing.T) {
135139
resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentId),
136140
resource.TestCheckResourceAttr(resourceName, "display_name", "displayName"),
137141
resource.TestCheckResourceAttr(resourceName, "fqdn", "fqdn.example.com"),
138-
resource.TestCheckResourceAttr(resourceName, "password", "BEstrO0ng_#11"),
142+
resource.TestCheckResourceAttrSet(resourceName, "password"),
139143
resource.TestCheckResourceAttr(resourceName, "username", "username"),
140144

141145
func(s *terraform.State) (err error) {
@@ -165,7 +169,7 @@ func TestGoldenGateDatabaseRegistrationResource_basic(t *testing.T) {
165169
resource.TestCheckResourceAttr(resourceName, "freeform_tags.%", "1"),
166170
resource.TestCheckResourceAttrSet(resourceName, "id"),
167171
resource.TestCheckResourceAttrSet(resourceName, "key_id"),
168-
resource.TestCheckResourceAttr(resourceName, "password", "BEstrO0ng_#11"),
172+
resource.TestCheckResourceAttrSet(resourceName, "password"),
169173
resource.TestCheckResourceAttrSet(resourceName, "secret_compartment_id"),
170174
resource.TestCheckResourceAttr(resourceName, "session_mode", "DIRECT"),
171175
resource.TestCheckResourceAttrSet(resourceName, "subnet_id"),

internal/integrationtest/golden_gate_deployment_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ func TestGoldenGateDeploymentResource_basic(t *testing.T) {
3636
DEPLOYMENT_OGG_KEY = "golden_gate_deployment_ogg_key"
3737
BASE_OGG_VERSION = "base_ogg_version"
3838
UPGRADED_OGG_VERSION = "upgraded_ogg_version"
39+
PASSWORD = "password"
40+
NEW_PASSWORD = "new_password"
3941
)
4042

4143
var (
@@ -74,7 +76,7 @@ func TestGoldenGateDeploymentResource_basic(t *testing.T) {
7476
}
7577

7678
goldenGateDeploymentOggDataRepresentation = map[string]interface{}{
77-
"admin_password": acctest.Representation{RepType: acctest.Required, Create: `BEstrO0ng_#11`, Update: `BEstrO0ng_#12`},
79+
"admin_password": acctest.Representation{RepType: acctest.Required, Create: `${var.password}`, Update: `${var.new_password}`},
7880
"admin_username": acctest.Representation{RepType: acctest.Required, Create: `adminUsername`, Update: `adminUsername2`},
7981
"deployment_name": acctest.Representation{RepType: acctest.Required, Create: `depl_test_ggs_deployment_name`},
8082
"certificate": acctest.Representation{RepType: acctest.Optional, Create: ``, Update: `-----BEGIN CERTIFICATE-----\nMIICljCCAX4CCQCEpaMjTCJ8WzANBgkqhkiG9w0BAQsFADANMQswCQYDVQQGEwJV\nUzAeFw0yMTAxMTkyMTI2MjRaFw0yNDAxMTkyMTI2MjRaMA0xCzAJBgNVBAYTAlVT\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAo83kaUQXpCcSoEuRVFX3\njztWDNKtWpjNG240f0RpERI1NnZtHH0qnZqfaWAQQa8kx3+W1LOeFbkkRnkJz19g\neIXR6TeavT+W5iRh4goK+N7gubYkSMa2shVf+XsoHKERSbhdhrtX+GqvKzAvplCt\nCgd4MDlsvLv/YHCLvJL4JgRxKyevjlnE1rqrICJMCLbbZMrIKTzwb/K13hGrm6Bc\n+Je9EC3MWWxd5jBwXu3vgIYRuGR4DPg/yfMKPZr2xFDLpBsv5jaqULS9t6GwoEBJ\nKN0NXp5obaQToYqMsvAZyHoEyfCBDka16Bm5hGF60FwqgUT3p/+qlBn61cAJe9t5\n8QIDAQABMA0GCSqGSIb3DQEBCwUAA4IBAQAX1rxV2hai02Pb4Cf8U44zj+1aY6wV\nLvOMWiL3zl53up4/X7PDcmWcPM9UMVCGTISZD6A6IPvNlkvbtvYCzgjhtGxDmrj7\nwTRV5gO9j3bAhxBO7XgTmwmD/9hpykM58nbhLFnkGf+Taja8qsy0U8H74Tr9w1M8\n8E5kghgGzBElNquM8AUuDakC1JL4aLO/VDMxe/1BLtmBHLZy3XTzVycjP9ZFPh6h\nT+cWJcVOjQSYY2U75sDnKD2Sg1cmK54HauA6SPh4kAkpmxyLyDZZjPBQe2sLFmmS\naZSE+g16yMR9TVHo3pTpRkxJwDEH0LePwYXA4vUIK3HHS6zgLe0ody8g\n-----END CERTIFICATE-----`},
@@ -125,6 +127,8 @@ func TestGoldenGateDeploymentResource_basic(t *testing.T) {
125127
makeVariableStr(DEPLOYMENT_OGG_KEY, t) +
126128
makeVariableStr(BASE_OGG_VERSION, t) +
127129
makeVariableStr(UPGRADED_OGG_VERSION, t) +
130+
makeVariableStr(PASSWORD, t) +
131+
makeVariableStr(NEW_PASSWORD, t) +
128132
GoldenGateDeploymentResourceDependencies
129133

130134
// Save TF content to Create resource with optional properties. This has to be exactly the same as the config part in the "Create with optionals" step in the test.

0 commit comments

Comments
 (0)