fix: Fix network interface handling of allowed addresses and security… (#579)
* fix: Fix network interface handling of allowed addresses and security fields * fix: Simplify toCreatePayload
This commit is contained in:
parent
f1a6179ccf
commit
c1ada319ce
2 changed files with 88 additions and 7 deletions
|
|
@ -130,6 +130,30 @@ func TestMapFields(t *testing.T) {
|
|||
},
|
||||
true,
|
||||
},
|
||||
{
|
||||
"empty_list_allowed_addresses",
|
||||
Model{
|
||||
ProjectId: types.StringValue("pid"),
|
||||
NetworkId: types.StringValue("nid"),
|
||||
NetworkInterfaceId: types.StringValue("nicid"),
|
||||
AllowedAddresses: types.ListValueMust(types.StringType, []attr.Value{}),
|
||||
},
|
||||
&iaas.NIC{
|
||||
Id: utils.Ptr("nicid"),
|
||||
AllowedAddresses: nil,
|
||||
},
|
||||
Model{
|
||||
Id: types.StringValue("pid,nid,nicid"),
|
||||
ProjectId: types.StringValue("pid"),
|
||||
NetworkId: types.StringValue("nid"),
|
||||
NetworkInterfaceId: types.StringValue("nicid"),
|
||||
Name: types.StringNull(),
|
||||
SecurityGroupIds: types.ListNull(types.StringType),
|
||||
AllowedAddresses: types.ListValueMust(types.StringType, []attr.Value{}),
|
||||
Labels: types.MapNull(types.StringType),
|
||||
},
|
||||
true,
|
||||
},
|
||||
{
|
||||
"response_nil_fail",
|
||||
Model{},
|
||||
|
|
@ -184,6 +208,7 @@ func TestToCreatePayload(t *testing.T) {
|
|||
AllowedAddresses: types.ListValueMust(types.StringType, []attr.Value{
|
||||
types.StringValue("aa1"),
|
||||
}),
|
||||
Security: types.BoolValue(true),
|
||||
},
|
||||
&iaas.CreateNICPayload{
|
||||
Name: utils.Ptr("name"),
|
||||
|
|
@ -196,6 +221,28 @@ func TestToCreatePayload(t *testing.T) {
|
|||
String: utils.Ptr("aa1"),
|
||||
},
|
||||
},
|
||||
NicSecurity: utils.Ptr(true),
|
||||
},
|
||||
true,
|
||||
},
|
||||
{
|
||||
"empty_allowed_addresses",
|
||||
&Model{
|
||||
Name: types.StringValue("name"),
|
||||
SecurityGroupIds: types.ListValueMust(types.StringType, []attr.Value{
|
||||
types.StringValue("sg1"),
|
||||
types.StringValue("sg2"),
|
||||
}),
|
||||
|
||||
AllowedAddresses: types.ListNull(types.StringType),
|
||||
},
|
||||
&iaas.CreateNICPayload{
|
||||
Name: utils.Ptr("name"),
|
||||
SecurityGroups: &[]string{
|
||||
"sg1",
|
||||
"sg2",
|
||||
},
|
||||
AllowedAddresses: nil,
|
||||
},
|
||||
true,
|
||||
},
|
||||
|
|
@ -237,6 +284,7 @@ func TestToUpdatePayload(t *testing.T) {
|
|||
AllowedAddresses: types.ListValueMust(types.StringType, []attr.Value{
|
||||
types.StringValue("aa1"),
|
||||
}),
|
||||
Security: types.BoolValue(true),
|
||||
},
|
||||
&iaas.UpdateNICPayload{
|
||||
Name: utils.Ptr("name"),
|
||||
|
|
@ -249,6 +297,28 @@ func TestToUpdatePayload(t *testing.T) {
|
|||
String: utils.Ptr("aa1"),
|
||||
},
|
||||
},
|
||||
NicSecurity: utils.Ptr(true),
|
||||
},
|
||||
true,
|
||||
},
|
||||
{
|
||||
"empty_allowed_addresses",
|
||||
&Model{
|
||||
Name: types.StringValue("name"),
|
||||
SecurityGroupIds: types.ListValueMust(types.StringType, []attr.Value{
|
||||
types.StringValue("sg1"),
|
||||
types.StringValue("sg2"),
|
||||
}),
|
||||
|
||||
AllowedAddresses: types.ListNull(types.StringType),
|
||||
},
|
||||
&iaas.UpdateNICPayload{
|
||||
Name: utils.Ptr("name"),
|
||||
SecurityGroups: &[]string{
|
||||
"sg1",
|
||||
"sg2",
|
||||
},
|
||||
AllowedAddresses: utils.Ptr([]iaas.AllowedAddressesInner{}),
|
||||
},
|
||||
true,
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue