Skip to content

Commit 106dc8b

Browse files
vuikeyMaxrovr
authored andcommitted
Bug Fix: Fixed UpdateIpsecTunnel API Default Params
1 parent 0b71c8a commit 106dc8b

File tree

5 files changed

+55
-16
lines changed

5 files changed

+55
-16
lines changed

internal/integrationtest/core_ipsec_connection_tunnel_test.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ var (
3636
"display_name": acctest.Representation{RepType: acctest.Optional, Create: `MyIPSecConnectionTunnel`, Update: `displayName2`},
3737
"bgp_session_info": acctest.RepresentationGroup{RepType: acctest.Optional, Group: CoreIpSecConnectionTunnelConfigurationBgpSessionInfoRepresentation},
3838
"shared_secret": acctest.Representation{RepType: acctest.Optional, Create: `sharedsecret1`, Update: `sharedsecret2`},
39+
"dpd_config": acctest.RepresentationGroup{RepType: acctest.Optional, Group: ipSecConnectionTunnelConfigurationDpdConfigRepresentation},
3940
}
4041

4142
CoreIpSecConnectionTunnelConfigurationBgpSessionInfoRepresentation = map[string]interface{}{
@@ -44,6 +45,11 @@ var (
4445
"oracle_interface_ip": acctest.Representation{RepType: acctest.Optional, Update: `10.0.0.17/31`},
4546
}
4647

48+
ipSecConnectionTunnelConfigurationDpdConfigRepresentation = map[string]interface{}{
49+
"dpd_mode": acctest.Representation{RepType: acctest.Optional, Update: `RESPOND_ONLY`},
50+
"dpd_timeout_in_sec": acctest.Representation{RepType: acctest.Optional, Update: `200`},
51+
}
52+
4753
CoreIpSecConnectionTunnelResourceConfig = IpSecConnectionOptionalResource
4854
)
4955

@@ -118,6 +124,8 @@ func TestCoreIpSecConnectionTunnelResource_basic(t *testing.T) {
118124
resource.TestCheckResourceAttr(resourceName, "bgp_session_info.0.customer_bgp_asn", "1587232876"),
119125
resource.TestCheckResourceAttr(resourceName, "bgp_session_info.0.customer_interface_ip", "10.0.0.16/31"),
120126
resource.TestCheckResourceAttr(resourceName, "bgp_session_info.0.oracle_interface_ip", "10.0.0.17/31"),
127+
resource.TestCheckResourceAttr(resourceName, "dpd_config.0.dpd_mode", "RESPOND_ONLY"),
128+
resource.TestCheckResourceAttr(resourceName, "dpd_config.0.dpd_timeout_in_sec", "200"),
121129

122130
func(s *terraform.State) (err error) {
123131
resId2, err = acctest.FromInstanceState(s, resourceName, "id")
@@ -142,7 +150,6 @@ func TestCoreIpSecConnectionTunnelResource_basic(t *testing.T) {
142150
resource.TestCheckResourceAttrSet(datasourceName, "ip_sec_connection_tunnels.0.display_name"),
143151
resource.TestCheckResourceAttrSet(datasourceName, "ip_sec_connection_tunnels.0.dpd_mode"),
144152
resource.TestCheckResourceAttrSet(datasourceName, "ip_sec_connection_tunnels.0.dpd_timeout_in_sec"),
145-
resource.TestCheckResourceAttr(datasourceName, "ip_sec_connection_tunnels.0.encryption_domain_config.#", "1"),
146153
resource.TestCheckResourceAttrSet(datasourceName, "ip_sec_connection_tunnels.0.id"),
147154
resource.TestCheckResourceAttrSet(datasourceName, "ip_sec_connection_tunnels.0.ike_version"),
148155
resource.TestCheckResourceAttrSet(datasourceName, "ip_sec_connection_tunnels.0.nat_translation_enabled"),

internal/integrationtest/core_ipsec_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ var (
5151
"defined_tags": acctest.Representation{RepType: acctest.Optional, Create: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "value")}`, Update: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "updatedValue")}`},
5252
"display_name": acctest.Representation{RepType: acctest.Optional, Create: `MyIPSecConnection`, Update: `displayName2`},
5353
"freeform_tags": acctest.Representation{RepType: acctest.Optional, Create: map[string]string{"Department": "Finance"}, Update: map[string]string{"Department": "Accounting"}},
54+
"lifecycle": acctest.RepresentationGroup{RepType: acctest.Required, Group: ignoreDefinedTags},
55+
}
56+
57+
ignoreDefinedTags = map[string]interface{}{
58+
"ignore_changes": acctest.Representation{RepType: acctest.Required, Create: []string{`defined_tags`}},
5459
}
5560

5661
CoreIpSecConnectionResourceDependencies = acctest.GenerateResourceFromRepresentationMap("oci_core_cpe", "test_cpe", acctest.Required, acctest.Create, CoreCpeRepresentation) +

internal/service/core/core_ipsec_connection_tunnel_data_source.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ func CoreIpSecConnectionTunnelDataSource() *schema.Resource {
3636
// Optional
3737

3838
// Computed
39+
"bgp_ipv6state": {
40+
Type: schema.TypeString,
41+
Computed: true,
42+
},
3943
"bgp_state": {
4044
Type: schema.TypeString,
4145
Computed: true,

internal/service/core/core_ipsec_connection_tunnel_management_resource.go

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ func CoreIpSecConnectionTunnelManagementResource() *schema.Resource {
7676
Type: schema.TypeString,
7777
Computed: true,
7878
},
79+
"bgp_ipv6state": {
80+
Type: schema.TypeString,
81+
Computed: true,
82+
},
7983
},
8084
},
8185
},
@@ -114,6 +118,23 @@ func CoreIpSecConnectionTunnelManagementResource() *schema.Resource {
114118
Optional: true,
115119
Computed: true,
116120
},
121+
"dpd_config": {
122+
Type: schema.TypeList,
123+
Optional: true,
124+
Elem: &schema.Resource{
125+
Schema: map[string]*schema.Schema{
126+
// Optional
127+
"dpd_mode": {
128+
Type: schema.TypeString,
129+
Optional: true,
130+
},
131+
"dpd_timeout_in_sec": {
132+
Type: schema.TypeInt,
133+
Optional: true,
134+
},
135+
},
136+
},
137+
},
117138
"dpd_mode": {
118139
Type: schema.TypeString,
119140
Computed: true,
@@ -170,7 +191,7 @@ func CoreIpSecConnectionTunnelManagementResource() *schema.Resource {
170191
Computed: true,
171192
},
172193
"lifetime": {
173-
Type: schema.TypeString,
194+
Type: schema.TypeInt,
174195
Computed: true,
175196
},
176197
"negotiated_authentication_algorithm": {
@@ -231,7 +252,7 @@ func CoreIpSecConnectionTunnelManagementResource() *schema.Resource {
231252
Computed: true,
232253
},
233254
"lifetime": {
234-
Type: schema.TypeString,
255+
Type: schema.TypeInt,
235256
Computed: true,
236257
},
237258
"negotiated_authentication_algorithm": {
@@ -465,16 +486,18 @@ func (s *CoreIpSecConnectionTunnelManagementResourceCrud) Update() error {
465486
request.OracleInitiation = oci_core.UpdateIpSecConnectionTunnelDetailsOracleInitiationEnum(oracleInitiation.(string))
466487
}
467488

468-
dpdConfig := &oci_core.DpdConfig{}
469-
if dpdMode, ok := s.D.GetOkExists("dpd_mode"); ok {
470-
dpdConfig.DpdMode = oci_core.DpdConfigDpdModeEnum(dpdMode.(string))
471-
}
472-
473-
if dpdTimeout, ok := s.D.GetOkExists("dpd_timeout_in_sec"); ok {
474-
tmp := dpdTimeout.(int)
475-
dpdConfig.DpdTimeoutInSec = &tmp
489+
if _, ok := s.D.GetOkExists("dpd_config"); ok {
490+
dpdConfig := &oci_core.DpdConfig{}
491+
fieldKeyFormat := fmt.Sprintf("%s.%d.%%s", "dpd_config", 0)
492+
if dpdMode, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "dpd_mode")); ok {
493+
dpdConfig.DpdMode = oci_core.DpdConfigDpdModeEnum(dpdMode.(string))
494+
}
495+
if dpdTimeout, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "dpd_timeout_in_sec")); ok {
496+
tmp := dpdTimeout.(int)
497+
dpdConfig.DpdTimeoutInSec = &tmp
498+
}
499+
request.DpdConfig = dpdConfig
476500
}
477-
request.DpdConfig = dpdConfig
478501

479502
if _, ok := s.D.GetOkExists("phase_one_details"); ok {
480503
phaseOneDetails := &oci_core.PhaseOneConfigDetails{}

internal/service/core/core_ipsec_connection_tunnels_data_source.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ func CoreIpSecConnectionTunnelsDataSource() *schema.Resource {
172172
Computed: true,
173173
},
174174
"lifetime": {
175-
Type: schema.TypeString,
175+
Type: schema.TypeInt,
176176
Computed: true,
177177
},
178178
"negotiated_authentication_algorithm": {
@@ -233,7 +233,7 @@ func CoreIpSecConnectionTunnelsDataSource() *schema.Resource {
233233
Computed: true,
234234
},
235235
"lifetime": {
236-
Type: schema.TypeString,
236+
Type: schema.TypeInt,
237237
Computed: true,
238238
},
239239
"negotiated_authentication_algorithm": {
@@ -468,7 +468,7 @@ func TunnelPhaseOneDetailsToMap(obj *oci_core.TunnelPhaseOneDetails) map[string]
468468
}
469469

470470
if obj.Lifetime != nil {
471-
result["lifetime"] = strconv.FormatInt(*obj.Lifetime, 10)
471+
result["lifetime"] = int(*obj.Lifetime)
472472
}
473473

474474
if obj.NegotiatedAuthenticationAlgorithm != nil {
@@ -522,7 +522,7 @@ func TunnelPhaseTwoDetailsToMap(obj *oci_core.TunnelPhaseTwoDetails) map[string]
522522
}
523523

524524
if obj.Lifetime != nil {
525-
result["lifetime"] = strconv.FormatInt(*obj.Lifetime, 10)
525+
result["lifetime"] = int(*obj.Lifetime)
526526
}
527527

528528
if obj.NegotiatedAuthenticationAlgorithm != nil {

0 commit comments

Comments
 (0)