generated from terraform-linters/tflint-ruleset-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from pregress/azurerm_storage_account_tls_versi…
…on_test azurerm_storage_account_tls_version_test
- Loading branch information
Showing
2 changed files
with
57 additions
and
2 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 |
---|---|---|
@@ -1,5 +1,3 @@ | ||
// This file generated by `tools/apispec-rule-gen/main.go`. DO NOT EDIT | ||
|
||
package rules | ||
|
||
import ( | ||
|
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,57 @@ | ||
package rules | ||
|
||
import ( | ||
"testing" | ||
|
||
hcl "github.com/hashicorp/hcl/v2" | ||
"github.com/terraform-linters/tflint-plugin-sdk/helper" | ||
) | ||
|
||
func Test_AzurermStorageAccountUnsecureTls(t *testing.T) { | ||
tests := []struct { | ||
Name string | ||
Content string | ||
Expected helper.Issues | ||
}{ | ||
{ | ||
Name: "insecure TLS version found", | ||
Content: ` | ||
resource "azurerm_storage_account" "example" { | ||
min_tls_version = "TLS1_0" | ||
}`, | ||
Expected: helper.Issues{ | ||
{ | ||
Rule: NewAzurermStorageAccountUnsecureTls(), | ||
Message: `"TLS1_0" is an insecure value as min_tls_version`, | ||
Range: hcl.Range{ | ||
Filename: "resource.tf", | ||
Start: hcl.Pos{Line: 3, Column: 23}, | ||
End: hcl.Pos{Line: 3, Column: 31}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
Name: "secure TLS version", | ||
Content: ` | ||
resource "azurerm_storage_account" "example" { | ||
min_tls_version = "TLS1_2" | ||
}`, | ||
Expected: helper.Issues{}, | ||
}, | ||
} | ||
|
||
rule := NewAzurermStorageAccountUnsecureTls() | ||
|
||
for _, test := range tests { | ||
t.Run(test.Name, func(t *testing.T) { | ||
runner := helper.TestRunner(t, map[string]string{"resource.tf": test.Content}) | ||
|
||
if err := rule.Check(runner); err != nil { | ||
t.Fatalf("Unexpected error occurred: %s", err) | ||
} | ||
|
||
helper.AssertIssues(t, test.Expected, runner.Issues) | ||
}) | ||
} | ||
} |