Skip to content

Commit 46f916f

Browse files
committed
test: improve test isolation with mock providers
- Added mock providers for AWS and TLS in test files - Enhanced custom provider test coverage - Added tags to test resources for better organization
1 parent 94df752 commit 46f916f

2 files changed

Lines changed: 34 additions & 5 deletions

File tree

tests/provider.tftest.hcl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
mock_provider "aws" {}
2+
3+
mock_provider "tls" {
4+
mock_data "tls_certificate" {
5+
defaults = {
6+
certificates = [
7+
{
8+
sha1_fingerprint = "1234567890abcdef1234567890abcdef12345678"
9+
}
10+
]
11+
}
12+
}
13+
}
14+
115
run "common_providers" {
216
command = plan
317

tests/role.tftest.hcl

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
provider "aws" {
2-
1+
mock_provider "aws" {
2+
mock_data "aws_iam_policy_document" {
3+
defaults = {
4+
json = "{\"Version\":\"2012-10-17\",\"Statement\":[]}"
5+
}
6+
}
37
}
48

59
run "github_providers" {
@@ -48,6 +52,10 @@ run "gitlab_providers" {
4852
repository = "appvia/something"
4953
common_provider = "gitlab"
5054

55+
tags = {
56+
Name = "GitLab"
57+
}
58+
5159
permission_boundary_arn = "arn:aws:iam::aws:policy/AdministratorAccess"
5260

5361
read_only_policy_arns = [
@@ -68,15 +76,18 @@ run "custom_providers" {
6876
}
6977

7078
variables {
71-
name = "custom"
72-
description = "Test role using custom OIDC provider"
73-
repository = "appvia/something"
79+
name = "custom"
80+
description = "Test role using custom OIDC provider"
81+
repository = "appvia/something"
82+
common_provider = ""
7483

7584
custom_provider = {
7685
url = "https://token.actions.githubusercontent.com"
7786
audiences = ["test"]
7887
subject_branch_mapping = "repo={repo},branch={ref}"
7988
subject_tag_mapping = "repo={repo},tag={ref}"
89+
subject_reader_mapping = "repo={repo}"
90+
subject_env_mapping = "repo={repo},environment={environment}"
8091
}
8192

8293
permission_boundary_arn = "arn:aws:iam::aws:policy/AdministratorAccess"
@@ -117,5 +128,9 @@ run "custom_providers" {
117128
]
118129
})
119130
}
131+
132+
tags = {
133+
Name = "Custom"
134+
}
120135
}
121136
}

0 commit comments

Comments
 (0)