Skip to content

Commit f97a035

Browse files
committed
add more tests
1 parent 2d8f40b commit f97a035

4 files changed

Lines changed: 64 additions & 40 deletions

File tree

akeyless/tests/gateway/certificate_discovery_test.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ func TestCertificateDiscoveryResource(t *testing.T) {
1616

1717
config := fmt.Sprintf(`
1818
resource "akeyless_certificate_discovery" "%v" {
19-
hosts = "127.0.0.1"
20-
port_ranges = "443"
21-
target_location = "%v"
22-
debug = true
19+
hosts = "127.0.0.1"
20+
port_ranges = "443"
21+
target_location = "%v"
22+
expiration_event_in = ["30", "10"]
23+
debug = true
2324
}
2425
`, name, folder)
2526

@@ -33,6 +34,7 @@ func TestCertificateDiscoveryResource(t *testing.T) {
3334
resource.TestCheckResourceAttr(fmt.Sprintf("akeyless_certificate_discovery.%v", name), "hosts", "127.0.0.1"),
3435
resource.TestCheckResourceAttr(fmt.Sprintf("akeyless_certificate_discovery.%v", name), "port_ranges", "443"),
3536
resource.TestCheckResourceAttr(fmt.Sprintf("akeyless_certificate_discovery.%v", name), "target_location", folder),
37+
resource.TestCheckResourceAttr(fmt.Sprintf("akeyless_certificate_discovery.%v", name), "expiration_event_in.#", "2"),
3638
),
3739
},
3840
},

akeyless/tests/gateway/migration_test.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,37 @@ func TestGatewayMigrationAws(t *testing.T) {
1515
name := "migration_aws"
1616
migrationName := fmt.Sprintf("tf-test-%s-%s", testRunID, name)
1717

18+
awsTargetName := testPath("aws-migration-target")
19+
testutils.CreateAwsTarget(t, awsTargetName, map[string]any{
20+
"access_key_id": "test",
21+
"access_key": "test",
22+
"region": "us-east-1",
23+
})
24+
t.Cleanup(func() {
25+
testutils.DeleteTarget(t, awsTargetName)
26+
})
27+
1828
config := fmt.Sprintf(`
1929
resource "akeyless_gateway_migration_aws" "%v" {
2030
name = "%v"
2131
target_location = "terraform-tests/migrations/aws"
32+
target_name = "%v"
2233
aws_key_id = "test"
2334
aws_key = "test"
2435
aws_region = "us-east-1"
2536
}
26-
`, name, migrationName)
37+
`, name, migrationName, awsTargetName)
2738

2839
configUpdate := fmt.Sprintf(`
2940
resource "akeyless_gateway_migration_aws" "%v" {
3041
name = "%v"
3142
target_location = "terraform-tests/migrations/aws-updated"
43+
target_name = "%v"
3244
aws_key_id = "test"
3345
aws_key = "test"
3446
aws_region = "eu-west-1"
3547
}
36-
`, name, migrationName)
48+
`, name, migrationName, awsTargetName)
3749

3850
testMigrationResource(t, config, configUpdate)
3951
}

akeyless/tests/no_gateway/resource_auth_methods_test.go

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,7 @@ func TestAuthMethodSAMLResource(t *testing.T) {
689689
force_sub_claims = true
690690
allowed_redirect_uri = ["https://localhost/callback"]
691691
subclaims_delimiters = [","]
692+
use_dedicated_saml_urls = true
692693
}
693694
`, name, path)
694695

@@ -705,6 +706,7 @@ func TestAuthMethodSAMLResource(t *testing.T) {
705706
force_sub_claims = false
706707
allowed_redirect_uri = ["https://localhost/callback", "https://localhost/callback2"]
707708
subclaims_delimiters = [",", ";"]
709+
use_dedicated_saml_urls = false
708710
}
709711
`, name, path)
710712

@@ -723,6 +725,7 @@ func TestAuthMethodSAMLResource(t *testing.T) {
723725
resource.TestCheckResourceAttr("akeyless_auth_method_saml."+name, "force_sub_claims", "true"),
724726
resource.TestCheckResourceAttr("akeyless_auth_method_saml."+name, "allowed_redirect_uri.0", "https://localhost/callback"),
725727
resource.TestCheckResourceAttr("akeyless_auth_method_saml."+name, "subclaims_delimiters.0", ","),
728+
resource.TestCheckResourceAttr("akeyless_auth_method_saml."+name, "use_dedicated_saml_urls", "true"),
726729
resource.TestCheckResourceAttrSet("akeyless_auth_method_saml."+name, "access_id"),
727730
),
728731
},
@@ -736,6 +739,7 @@ func TestAuthMethodSAMLResource(t *testing.T) {
736739
resource.TestCheckResourceAttr("akeyless_auth_method_saml."+name, "force_sub_claims", "false"),
737740
resource.TestCheckResourceAttr("akeyless_auth_method_saml."+name, "allowed_redirect_uri.#", "2"),
738741
resource.TestCheckResourceAttr("akeyless_auth_method_saml."+name, "subclaims_delimiters.#", "2"),
742+
resource.TestCheckResourceAttr("akeyless_auth_method_saml."+name, "use_dedicated_saml_urls", "false"),
739743
resource.TestCheckResourceAttrSet("akeyless_auth_method_saml."+name, "access_id"),
740744
),
741745
},
@@ -798,29 +802,31 @@ func TestAuthMethodUIDResource(t *testing.T) {
798802

799803
config := fmt.Sprintf(`
800804
resource "akeyless_auth_method_universal_identity" "%v" {
801-
name = "%v"
802-
description = "test uid auth method"
803-
jwt_ttl = 42
804-
deny_inheritance = true
805-
ttl = 120
806-
audit_logs_claims = ["eee","kk"]
807-
delete_protection = "true"
808-
access_expires = 1638741817
809-
force_sub_claims = true
810-
deny_rotate = true
805+
name = "%v"
806+
description = "test uid auth method"
807+
jwt_ttl = 42
808+
deny_inheritance = true
809+
ttl = 120
810+
audit_logs_claims = ["eee","kk"]
811+
delete_protection = "true"
812+
access_expires = 1638741817
813+
force_sub_claims = true
814+
deny_rotate = true
815+
uid_expiration_event_at = ["10", "50"]
811816
}
812817
`, name, path)
813818
configUpdate := fmt.Sprintf(`
814819
resource "akeyless_auth_method_universal_identity" "%v" {
815-
name = "%v"
816-
description = "updated uid auth method"
817-
deny_inheritance = false
818-
bound_ips = ["1.1.1.0/32"]
819-
audit_logs_claims = ["eee","kk"]
820-
delete_protection = "false"
821-
access_expires = 1638741817
822-
force_sub_claims = false
823-
deny_rotate = false
820+
name = "%v"
821+
description = "updated uid auth method"
822+
deny_inheritance = false
823+
bound_ips = ["1.1.1.0/32"]
824+
audit_logs_claims = ["eee","kk"]
825+
delete_protection = "false"
826+
access_expires = 1638741817
827+
force_sub_claims = false
828+
deny_rotate = false
829+
uid_expiration_event_at = ["20"]
824830
}
825831
`, name, path)
826832

@@ -837,6 +843,7 @@ func TestAuthMethodUIDResource(t *testing.T) {
837843
resource.TestCheckResourceAttr("akeyless_auth_method_universal_identity."+name, "access_expires", "1638741817"),
838844
resource.TestCheckResourceAttr("akeyless_auth_method_universal_identity."+name, "force_sub_claims", "true"),
839845
resource.TestCheckResourceAttr("akeyless_auth_method_universal_identity."+name, "deny_rotate", "true"),
846+
resource.TestCheckResourceAttr("akeyless_auth_method_universal_identity."+name, "uid_expiration_event_at.#", "2"),
840847
resource.TestCheckResourceAttrSet("akeyless_auth_method_universal_identity."+name, "access_id"),
841848
),
842849
},
@@ -848,6 +855,7 @@ func TestAuthMethodUIDResource(t *testing.T) {
848855
resource.TestCheckResourceAttr("akeyless_auth_method_universal_identity."+name, "description", "updated uid auth method"),
849856
resource.TestCheckResourceAttr("akeyless_auth_method_universal_identity."+name, "force_sub_claims", "false"),
850857
resource.TestCheckResourceAttr("akeyless_auth_method_universal_identity."+name, "deny_rotate", "false"),
858+
resource.TestCheckResourceAttr("akeyless_auth_method_universal_identity."+name, "uid_expiration_event_at.#", "1"),
851859
resource.TestCheckResourceAttrSet("akeyless_auth_method_universal_identity."+name, "access_id"),
852860
),
853861
},

akeyless/tests/no_gateway/resource_target_test.go

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -122,26 +122,28 @@ func TestTargetDbResource(t *testing.T) {
122122

123123
config := fmt.Sprintf(`
124124
resource "akeyless_target_db" "%v" {
125-
name = "%v"
126-
db_type = "mysql"
127-
user_name = "user1"
128-
pwd = "pwd1"
129-
host = "host1"
130-
port = "1231"
131-
db_name = "db1"
132-
description = "aaa"
125+
name = "%v"
126+
db_type = "mysql"
127+
user_name = "user1"
128+
pwd = "pwd1"
129+
host = "host1"
130+
port = "1231"
131+
db_name = "db1"
132+
description = "aaa"
133+
skip_server_name_validation = "true"
133134
}
134135
`, secretName, secretPath)
135136

136137
configUpdate := fmt.Sprintf(`
137138
resource "akeyless_target_db" "%v" {
138-
name = "%v"
139-
db_type = "mysql"
140-
user_name = "user2"
141-
pwd = "pwd2"
142-
host = "host2"
143-
port = "1231"
144-
db_name = "db2"
139+
name = "%v"
140+
db_type = "mysql"
141+
user_name = "user2"
142+
pwd = "pwd2"
143+
host = "host2"
144+
port = "1231"
145+
db_name = "db2"
146+
skip_server_name_validation = "false"
145147
}
146148
`, secretName, secretPath)
147149

0 commit comments

Comments
 (0)