Skip to content

Commit db34ad4

Browse files
sagarp337jotruon
authored andcommitted
Bug Fix - Fixed the test cases for APIGateway Client mTLS feature
1 parent 34ab7f0 commit db34ad4

File tree

3 files changed

+41
-27
lines changed

3 files changed

+41
-27
lines changed

internal/integrationtest/apigateway_deployment_resource_test.go

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,25 @@ var (
2222
"specification.request_policies.authentication.type",
2323
acctest.Representation{RepType: acctest.Required, Create: `JWT_AUTHENTICATION`, Update: `JWT_AUTHENTICATION`},
2424
deploymentRepresentation)
25+
deploymentRepresentationWithMtlsDisabled = acctest.GetUpdatedRepresentationCopy(
26+
"specification.request_policies.mutual_tls.is_verified_certificate_required",
27+
acctest.Representation{RepType: acctest.Optional, Create: `false`, Update: `false`},
28+
deploymentRepresentationJwt)
2529
deploymentRepresentationJwtRemoteJWKS = acctest.GetRepresentationCopyWithMultipleRemovedProperties([]string{
2630
"specification.request_policies.authentication.function_id",
2731
"specification.request_policies.authentication.public_keys.keys",
28-
}, deploymentRepresentationJwt)
32+
}, deploymentRepresentationWithMtlsDisabled)
2933
deploymentRepresentationJwtStaticKeys = acctest.GetRepresentationCopyWithMultipleRemovedProperties([]string{
3034
"specification.request_policies.authentication.function_id",
3135
"specification.request_policies.authentication.public_keys.uri",
3236
"specification.request_policies.authentication.public_keys.max_cache_duration_in_hours",
3337
"specification.request_policies.authentication.public_keys.is_ssl_verify_disabled",
3438
"specification.request_policies.authentication.public_keys.keys.key",
35-
}, deploymentRepresentationJwt)
36-
DeploymentResourceConfigJwt = DeploymentResourceDependencies +
39+
}, deploymentRepresentationWithMtlsDisabled)
40+
41+
DeploymentResourceConfigCommon = DeploymentResourceDependenciesWithoutCABundle + acctest.GenerateResourceFromRepresentationMap("oci_apigateway_gateway", "test_gateway", acctest.Required, acctest.Create, gatewayRepresentation)
42+
43+
DeploymentResourceConfigJwt = DeploymentResourceConfigCommon +
3744
acctest.GenerateResourceFromRepresentationMap("oci_apigateway_deployment", "test_deployment", acctest.Optional, acctest.Update, deploymentRepresentationJwtStaticKeys)
3845
)
3946

@@ -59,7 +66,7 @@ func TestResourceApigatewayDeploymentResourceJwt_basic(t *testing.T) {
5966
acctest.ResourceTest(t, testAccCheckApigatewayDeploymentDestroy, []resource.TestStep{
6067
//verify Create
6168
{
62-
Config: config + compartmentIdVariableStr + DeploymentResourceDependencies +
69+
Config: config + compartmentIdVariableStr + DeploymentResourceConfigCommon +
6370
acctest.GenerateResourceFromRepresentationMap("oci_apigateway_deployment", "test_deployment", acctest.Required, acctest.Create, deploymentRepresentationJwtRemoteJWKS),
6471
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
6572
resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentId),
@@ -76,11 +83,11 @@ func TestResourceApigatewayDeploymentResourceJwt_basic(t *testing.T) {
7683

7784
// delete before next Create
7885
{
79-
Config: config + compartmentIdVariableStr + DeploymentResourceDependencies,
86+
Config: config + compartmentIdVariableStr + DeploymentResourceConfigCommon,
8087
},
8188
//verify Create with optionals
8289
{
83-
Config: config + compartmentIdVariableStr + imageVariableStr + DeploymentResourceDependencies +
90+
Config: config + compartmentIdVariableStr + imageVariableStr + DeploymentResourceConfigCommon +
8491
acctest.GenerateResourceFromRepresentationMap("oci_apigateway_deployment", "test_deployment", acctest.Optional, acctest.Create, deploymentRepresentationJwtRemoteJWKS),
8592
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
8693
resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentId),
@@ -163,7 +170,7 @@ func TestResourceApigatewayDeploymentResourceJwt_basic(t *testing.T) {
163170
},
164171
// verify updates to updatable parameters
165172
{
166-
Config: config + compartmentIdVariableStr + imageVariableStr + DeploymentResourceDependencies +
173+
Config: config + compartmentIdVariableStr + imageVariableStr + DeploymentResourceConfigCommon +
167174
acctest.GenerateResourceFromRepresentationMap("oci_apigateway_deployment", "test_deployment", acctest.Optional, acctest.Update, deploymentRepresentationJwtStaticKeys),
168175
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
169176
resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentId),
@@ -254,7 +261,7 @@ func TestResourceApigatewayDeploymentResourceJwt_basic(t *testing.T) {
254261
{
255262
Config: config + imageVariableStr +
256263
acctest.GenerateDataSourceFromRepresentationMap("oci_apigateway_deployments", "test_deployments", acctest.Optional, acctest.Update, deploymentDataSourceRepresentation) +
257-
compartmentIdVariableStr + DeploymentResourceDependencies +
264+
compartmentIdVariableStr + DeploymentResourceConfigCommon +
258265
acctest.GenerateResourceFromRepresentationMap("oci_apigateway_deployment", "test_deployment", acctest.Optional, acctest.Update, deploymentRepresentationJwtStaticKeys),
259266
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
260267
resource.TestCheckResourceAttr(datasourceName, "compartment_id", compartmentId),

internal/integrationtest/apigateway_deployment_test.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,11 +274,25 @@ var (
274274
"use": acctest.Representation{RepType: acctest.Optional, Create: `use`, Update: `sig`},
275275
}
276276

277-
DeploymentResourceDependencies = acctest.GenerateResourceFromRepresentationMap("oci_apigateway_gateway", "test_gateway", acctest.Required, acctest.Create, gatewayRepresentation) +
278-
acctest.GenerateResourceFromRepresentationMap("oci_core_subnet", "test_subnet", acctest.Required, acctest.Create, subnetRegionalRepresentation) +
277+
gatewayCaBundlesRepresentationWithCABundle = acctest.GetUpdatedRepresentationCopy(
278+
"ca_bundle_id",
279+
acctest.Representation{RepType: acctest.Required, Create: `${oci_certificates_management_ca_bundle.test_ca_bundle_dep.id}`},
280+
gatewayCaBundlesRepresentation)
281+
282+
gatewayRepresentationWithCABundle = acctest.GetUpdatedRepresentationCopy(
283+
"ca_bundles",
284+
acctest.RepresentationGroup{RepType: acctest.Required, Group: gatewayCaBundlesRepresentationWithCABundle},
285+
gatewayRepresentation)
286+
287+
DeploymentResourceGatewayDependency = acctest.GenerateResourceFromRepresentationMap("oci_apigateway_gateway", "test_gateway", acctest.Required, acctest.Create, gatewayRepresentationWithCABundle)
288+
289+
DeploymentResourceDependenciesWithoutCABundle = acctest.GenerateResourceFromRepresentationMap("oci_core_subnet", "test_subnet", acctest.Required, acctest.Create, subnetRegionalRepresentation) +
279290
acctest.GenerateResourceFromRepresentationMap("oci_core_vcn", "test_vcn", acctest.Required, acctest.Create, vcnRepresentation) +
280291
DefinedTagsDependencies
281292

293+
DeploymentResourceDependencies = DeploymentResourceGatewayDependency + DeploymentResourceDependenciesWithoutCABundle +
294+
acctest.GenerateResourceFromRepresentationMap("oci_certificates_management_ca_bundle", "test_ca_bundle_dep", acctest.Optional, acctest.Create, caBundleRepresentation)
295+
282296
deploymentRepresentationCustomAuth = acctest.GetRepresentationCopyWithMultipleRemovedProperties([]string{
283297
"specification.request_policies.authentication.audiences",
284298
"specification.request_policies.authentication.issuers",

internal/integrationtest/apigateway_gateway_test.go

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ var (
6060
}
6161
gatewayCaBundlesRepresentation = map[string]interface{}{
6262
"type": acctest.Representation{RepType: acctest.Required, Create: `CA_BUNDLE`, Update: `CERTIFICATE_AUTHORITY`},
63-
"ca_bundle_id": acctest.Representation{RepType: acctest.Optional, Create: `${var.ca_bundle_id}`},
64-
"certificate_authority_id": acctest.Representation{RepType: acctest.Optional, Create: `${var.certificate_authority_id}`},
63+
"ca_bundle_id": acctest.Representation{RepType: acctest.Optional, Create: `${oci_certificates_management_ca_bundle.test_ca_bundle.id}`, Update: ``},
64+
"certificate_authority_id": acctest.Representation{RepType: acctest.Optional, Update: `${oci_certificates_management_certificate_authority.test_certificate_authority.id}`},
6565
}
6666
gatewayResponseCacheDetailsRepresentation = map[string]interface{}{
6767
"type": acctest.Representation{RepType: acctest.Required, Create: `EXTERNAL_RESP_CACHE`},
@@ -84,6 +84,8 @@ var (
8484
acctest.GenerateResourceFromRepresentationMap("oci_core_network_security_group", "test_network_security_group2", acctest.Required, acctest.Create, networkSecurityGroupRepresentation) +
8585
acctest.GenerateResourceFromRepresentationMap("oci_core_subnet", "test_subnet", acctest.Required, acctest.Create, subnetRepresentation) +
8686
acctest.GenerateResourceFromRepresentationMap("oci_core_vcn", "test_vcn", acctest.Required, acctest.Create, vcnRepresentation) +
87+
acctest.GenerateResourceFromRepresentationMap("oci_certificates_management_ca_bundle", "test_ca_bundle", acctest.Required, acctest.Create, caBundleRepresentationRequired) +
88+
acctest.GenerateResourceFromRepresentationMap("oci_certificates_management_certificate_authority", "test_certificate_authority", acctest.Required, acctest.Create, certificateAuthorityRepresentationRoot) +
8789
DefinedTagsDependencies +
8890
apiCertificateVariableStr + apiPrivateKeyVariableStr
8991
)
@@ -101,12 +103,6 @@ func TestApigatewayGatewayResource_basic(t *testing.T) {
101103
compartmentIdU := utils.GetEnvSettingWithDefault("compartment_id_for_update", compartmentId)
102104
compartmentIdUVariableStr := fmt.Sprintf("variable \"compartment_id_for_update\" { default = \"%s\" }\n", compartmentIdU)
103105

104-
caBundleId := utils.GetEnvSettingWithBlankDefault("ca_bundle_id")
105-
caBundleIdVariableStr := fmt.Sprintf("variable \"ca_bundle_id\" { default = \"%s\" }\n", caBundleId)
106-
107-
certificateAuthorityId := utils.GetEnvSettingWithBlankDefault("certificate_authority_id")
108-
certificateAuthorityIdVariableStr := fmt.Sprintf("variable \"certificate_authority_id\" { default = \"%s\" }\n", certificateAuthorityId)
109-
110106
vaultSecretId := utils.GetEnvSettingWithBlankDefault("oci_vault_secret_id")
111107
vaultSecretIdStr := fmt.Sprintf("variable \"oci_vault_secret_id\" { default = \"%s\" }\n", vaultSecretId)
112108

@@ -122,7 +118,7 @@ func TestApigatewayGatewayResource_basic(t *testing.T) {
122118
acctest.ResourceTest(t, testAccCheckApigatewayGatewayDestroy, []resource.TestStep{
123119
// verify Create
124120
{
125-
Config: config + compartmentIdVariableStr + vaultSecretIdStr + GatewayResourceDependencies + caBundleIdVariableStr + certificateAuthorityIdVariableStr +
121+
Config: config + compartmentIdVariableStr + vaultSecretIdStr + GatewayResourceDependencies +
126122
acctest.GenerateResourceFromRepresentationMap("oci_apigateway_gateway", "test_gateway", acctest.Required, acctest.Create, gatewayRepresentation),
127123
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
128124
resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentId),
@@ -148,12 +144,11 @@ func TestApigatewayGatewayResource_basic(t *testing.T) {
148144
},
149145
// verify Create with optionals
150146
{
151-
Config: config + compartmentIdVariableStr + vaultSecretIdStr + GatewayResourceDependencies + caBundleIdVariableStr + certificateAuthorityIdVariableStr +
147+
Config: config + compartmentIdVariableStr + vaultSecretIdStr + GatewayResourceDependencies +
152148
acctest.GenerateResourceFromRepresentationMap("oci_apigateway_gateway", "test_gateway", acctest.Optional, acctest.Create, gatewayRepresentation),
153149
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
154150
resource.TestCheckResourceAttr(resourceName, "ca_bundles.#", "1"),
155151
resource.TestCheckResourceAttrSet(resourceName, "ca_bundles.0.ca_bundle_id"),
156-
resource.TestCheckResourceAttrSet(resourceName, "ca_bundles.0.certificate_authority_id"),
157152
resource.TestCheckResourceAttr(resourceName, "ca_bundles.0.type", "CA_BUNDLE"),
158153
resource.TestCheckResourceAttrSet(resourceName, "certificate_id"),
159154
resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentId),
@@ -189,15 +184,14 @@ func TestApigatewayGatewayResource_basic(t *testing.T) {
189184

190185
// verify Update to the compartment (the compartment will be switched back in the next step)
191186
{
192-
Config: config + compartmentIdVariableStr + compartmentIdUVariableStr + vaultSecretIdStr + GatewayResourceDependencies + caBundleIdVariableStr + certificateAuthorityIdVariableStr +
187+
Config: config + compartmentIdVariableStr + compartmentIdUVariableStr + vaultSecretIdStr + GatewayResourceDependencies +
193188
acctest.GenerateResourceFromRepresentationMap("oci_apigateway_gateway", "test_gateway", acctest.Optional, acctest.Create,
194189
acctest.RepresentationCopyWithNewProperties(gatewayRepresentation, map[string]interface{}{
195190
"compartment_id": acctest.Representation{RepType: acctest.Required, Create: `${var.compartment_id_for_update}`},
196191
})),
197192
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
198193
resource.TestCheckResourceAttr(resourceName, "ca_bundles.#", "1"),
199194
resource.TestCheckResourceAttrSet(resourceName, "ca_bundles.0.ca_bundle_id"),
200-
resource.TestCheckResourceAttrSet(resourceName, "ca_bundles.0.certificate_authority_id"),
201195
resource.TestCheckResourceAttr(resourceName, "ca_bundles.0.type", "CA_BUNDLE"),
202196
resource.TestCheckResourceAttrSet(resourceName, "certificate_id"),
203197
resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentIdU),
@@ -231,11 +225,10 @@ func TestApigatewayGatewayResource_basic(t *testing.T) {
231225

232226
// verify updates to updatable parameters
233227
{
234-
Config: config + compartmentIdVariableStr + vaultSecretIdStr + GatewayResourceDependencies + caBundleIdVariableStr + certificateAuthorityIdVariableStr +
228+
Config: config + compartmentIdVariableStr + vaultSecretIdStr + GatewayResourceDependencies +
235229
acctest.GenerateResourceFromRepresentationMap("oci_apigateway_gateway", "test_gateway", acctest.Optional, acctest.Update, gatewayRepresentation),
236230
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
237231
resource.TestCheckResourceAttr(resourceName, "ca_bundles.#", "1"),
238-
resource.TestCheckResourceAttrSet(resourceName, "ca_bundles.0.ca_bundle_id"),
239232
resource.TestCheckResourceAttrSet(resourceName, "ca_bundles.0.certificate_authority_id"),
240233
resource.TestCheckResourceAttr(resourceName, "ca_bundles.0.type", "CERTIFICATE_AUTHORITY"),
241234
resource.TestCheckResourceAttrSet(resourceName, "certificate_id"),
@@ -271,7 +264,7 @@ func TestApigatewayGatewayResource_basic(t *testing.T) {
271264
{
272265
Config: config +
273266
acctest.GenerateDataSourceFromRepresentationMap("oci_apigateway_gateways", "test_gateways", acctest.Optional, acctest.Update, gatewayDataSourceRepresentation) +
274-
compartmentIdVariableStr + vaultSecretIdStr + GatewayResourceDependencies + caBundleIdVariableStr + certificateAuthorityIdVariableStr +
267+
compartmentIdVariableStr + vaultSecretIdStr + GatewayResourceDependencies +
275268
acctest.GenerateResourceFromRepresentationMap("oci_apigateway_gateway", "test_gateway", acctest.Optional, acctest.Update, gatewayRepresentation),
276269
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
277270
resource.TestCheckResourceAttrSet(datasourceName, "certificate_id"),
@@ -288,7 +281,7 @@ func TestApigatewayGatewayResource_basic(t *testing.T) {
288281
{
289282
Config: config +
290283
acctest.GenerateDataSourceFromRepresentationMap("oci_apigateway_gateway", "test_gateway", acctest.Required, acctest.Create, gatewaySingularDataSourceRepresentation) +
291-
compartmentIdVariableStr + vaultSecretIdStr + GatewayResourceConfig + caBundleIdVariableStr + certificateAuthorityIdVariableStr,
284+
compartmentIdVariableStr + vaultSecretIdStr + GatewayResourceConfig,
292285
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
293286
resource.TestCheckResourceAttrSet(singularDatasourceName, "gateway_id"),
294287

0 commit comments

Comments
 (0)