-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: fix nat rule type no_snat and no_dnat
- Loading branch information
David MICHENEAU
committed
Nov 18, 2024
1 parent
ff904b0
commit 481362b
Showing
10 changed files
with
364 additions
and
285 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:bug | ||
`resource/cloudavenue_vm` - Now Nat rule support correctly `NO_SNAT` and `NO_DNAT` type. | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,73 @@ | ||
package testsacc | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
|
||
"github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/helpers/testsacc" | ||
) | ||
|
||
var _ testsacc.TestACC = &EdgeGatewayNATRuleDataSource{} | ||
|
||
const ( | ||
EdgeGatewayNATRuleDataSourceName = testsacc.ResourceName("data.cloudavenue_edgegateway_nat_rule") | ||
) | ||
|
||
const testAccNATRuleDataSourceConfig = ` | ||
data "cloudavenue_edgegateway_nat_rule" "example" { | ||
depends_on = [cloudavenue_edgegateway.example_with_vdc, cloudavenue_edgegateway_nat_rule.example] | ||
edge_gateway_id = cloudavenue_edgegateway.example_with_vdc.id | ||
name = "example-snat" | ||
type EdgeGatewayNATRuleDataSource struct{} | ||
|
||
func NewEdgeGatewayNATRuleDataSourceTest() testsacc.TestACC { | ||
return &EdgeGatewayNATRuleDataSource{} | ||
} | ||
` | ||
|
||
func TestAccNatRuleDataSource(t *testing.T) { | ||
dataSourceName := "data.cloudavenue_edgegateway_nat_rule.example" | ||
// GetResourceName returns the name of the resource. | ||
func (r *EdgeGatewayNATRuleDataSource) GetResourceName() string { | ||
return EdgeGatewayNATRuleDataSourceName.String() | ||
} | ||
|
||
func (r *EdgeGatewayNATRuleDataSource) DependenciesConfig() (resp testsacc.DependenciesConfigResponse) { | ||
resp.Append(GetResourceConfig()[EdgeGatewayNATRuleResourceName]().GetDefaultConfig) | ||
return | ||
} | ||
|
||
func (r *EdgeGatewayNATRuleDataSource) Tests(ctx context.Context) map[testsacc.TestName]func(ctx context.Context, resourceName string) testsacc.Test { | ||
return map[testsacc.TestName]func(ctx context.Context, resourceName string) testsacc.Test{ | ||
// * Test One (with edge_gateway_id) | ||
"example": func(_ context.Context, _ string) testsacc.Test { | ||
return testsacc.Test{ | ||
// ! Create testing | ||
Create: testsacc.TFConfig{ | ||
TFConfig: ` | ||
data "cloudavenue_edgegateway_nat_rule" "example" { | ||
edge_gateway_id = cloudavenue_edgegateway.example.id | ||
name = "example" | ||
}`, | ||
Checks: GetResourceConfig()[EdgeGatewayNATRuleResourceName]().GetDefaultChecks(), | ||
}, | ||
} | ||
}, | ||
// * Test Two (with edge_gateway_name) | ||
"example_with_edge_gateway_name": func(_ context.Context, _ string) testsacc.Test { | ||
return testsacc.Test{ | ||
// ! Create testing | ||
Create: testsacc.TFConfig{ | ||
TFConfig: ` | ||
data "cloudavenue_edgegateway_nat_rule" "example_with_edge_gateway_name" { | ||
edge_gateway_name = cloudavenue_edgegateway.example.name | ||
name = "example" | ||
}`, | ||
Checks: GetResourceConfig()[EdgeGatewayNATRuleResourceName]().GetDefaultChecks(), | ||
}, | ||
} | ||
}, | ||
} | ||
} | ||
|
||
func TestAccEdgeGatewayNATRuleDataSource(t *testing.T) { | ||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { TestAccPreCheck(t) }, | ||
ProtoV6ProviderFactories: TestAccProtoV6ProviderFactories, | ||
Steps: []resource.TestStep{ | ||
// Read testing | ||
{ | ||
// Apply test | ||
Config: ConcatTests(testAccNATRuleResourceConfigSnat, testAccNATRuleDataSourceConfig, testAccEdgeGatewayResourceConfig), | ||
Check: natRuleSnatTestCheck(dataSourceName), | ||
}, | ||
}, | ||
Steps: testsacc.GenerateTests(&EdgeGatewayNATRuleDataSource{}), | ||
}) | ||
} |
Oops, something went wrong.