Skip to content

Commit

Permalink
OAS-4172: Allow detaching IP allowlists and make remote inspection fi…
Browse files Browse the repository at this point in the history
…eld optional (#37)
  • Loading branch information
Sedat Gokcen authored Mar 17, 2022
1 parent 57e579f commit dfdb7b3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
4 changes: 1 addition & 3 deletions pkg/resource_deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -693,9 +693,7 @@ func resourceDeploymentUpdate(d *schema.ResourceData, m interface{}) error {
if sec.caCertificate != "" {
depl.Certificates.CaCertificateId = sec.caCertificate
}
if sec.ipAllowlist != "" {
depl.IpallowlistId = sec.ipAllowlist
}
depl.IpallowlistId = sec.ipAllowlist
}
if d.HasChange(deplConfigurationFieldName) {
conf, err := expandConfiguration(d.Get(deplConfigurationFieldName).([]interface{}))
Expand Down
2 changes: 0 additions & 2 deletions pkg/resource_ip_allowlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,6 @@ func expandToIPAllowlist(d *schema.ResourceData, defaultProject string) (*securi
}
if v, ok := d.GetOk(ipRemoteInspectionAllowedFieldName); ok {
remoteInspectionAllowed = v.(bool)
} else {
return nil, fmt.Errorf("failed to parse field %s", ipRemoteInspectionAllowedFieldName)
}
project := defaultProject
if v, ok := d.GetOk(ipDescriptionFieldName); ok {
Expand Down
25 changes: 17 additions & 8 deletions pkg/resource_ip_allowlist_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,22 +79,31 @@ func TestFlattenIPAllowlistResource(t *testing.T) {
ipCreatedAtFieldName: "1980-03-03T01:01:01Z",
ipProjectFieldName: "123456789",
ipCIDRRangeFieldName: []string{"1.2.3.4/32", "88.11.0.0/16", "0.0.0.0/0"},
ipRemoteInspectionAllowedFieldName: true,
ipRemoteInspectionAllowedFieldName: false,
ipIsDeletedFieldName: false,
}

created, _ := types.TimestampProto(time.Date(1980, 03, 03, 1, 1, 1, 0, time.UTC))
cert := security.IPAllowlist{
Name: "test-name",
Description: "test-description",
ProjectId: "123456789",
CidrRanges: []string{"1.2.3.4/32", "88.11.0.0/16", "0.0.0.0/0"},
RemoteInspectionAllowed: true,
CreatedAt: created,
IsDeleted: false,
Name: "test-name",
Description: "test-description",
ProjectId: "123456789",
CidrRanges: []string{"1.2.3.4/32", "88.11.0.0/16", "0.0.0.0/0"},
CreatedAt: created,
IsDeleted: false,
}
got := flattenIPAllowlistResource(&cert)
assert.Equal(t, expected, got)

cert.RemoteInspectionAllowed = true
expected[ipRemoteInspectionAllowedFieldName] = true
got = flattenIPAllowlistResource(&cert)
assert.Equal(t, expected, got)

cert.RemoteInspectionAllowed = false
expected[ipRemoteInspectionAllowedFieldName] = false
got = flattenIPAllowlistResource(&cert)
assert.Equal(t, expected, got)
}

func TestExpandingIPAllowlistResource(t *testing.T) {
Expand Down

0 comments on commit dfdb7b3

Please sign in to comment.