Skip to content

Commit c44a616

Browse files
committed
fix: stabilize lab-backed CLI tests
1 parent 5e3ffe0 commit c44a616

18 files changed

Lines changed: 220 additions & 413 deletions

.github/config/MODULE.MD

Lines changed: 18 additions & 46 deletions
Large diffs are not rendered by default.

.github/config/README.md

Lines changed: 30 additions & 72 deletions
Large diffs are not rendered by default.

.github/config/environments.tf

Lines changed: 7 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,12 @@
1-
module "keyfactor_github_test_environment_10_5_0" {
1+
module "keyfactor_github_test_environment_ses_2541" {
22
source = "git::ssh://git@github.com/Keyfactor/terraform-module-keyfactor-github-test-environment-ad.git?ref=main"
33

4-
gh_environment_name = "KFC_10_5_0"
5-
gh_repo_name = data.github_repository.repo.name
6-
keyfactor_hostname = var.keyfactor_hostname_10_5_0
7-
keyfactor_username = var.keyfactor_username_AD
8-
keyfactor_password = var.keyfactor_password_AD
9-
keyfactor_config_file = base64encode(file("${path.module}/command_config.json"))
10-
}
11-
12-
module "keyfactor_github_test_environment_10_5_0_CLEAN" {
13-
source = "git::ssh://git@github.com/Keyfactor/terraform-module-keyfactor-github-test-environment-ad.git?ref=main"
14-
15-
gh_environment_name = "KFC_10_5_0_CLEAN"
16-
gh_repo_name = data.github_repository.repo.name
17-
keyfactor_hostname = var.keyfactor_hostname_10_5_0_CLEAN
18-
keyfactor_username = var.keyfactor_username_AD
19-
keyfactor_password = var.keyfactor_password_AD
20-
keyfactor_config_file = base64encode(file("${path.module}/command_config.json"))
21-
}
22-
23-
module "keyfactor_github_test_environment_11_5_0" {
24-
source = "git::ssh://git@github.com/Keyfactor/terraform-module-keyfactor-github-test-environment-ad.git?ref=main"
25-
26-
gh_environment_name = "KFC_11_5_0"
27-
gh_repo_name = data.github_repository.repo.name
28-
keyfactor_hostname = var.keyfactor_hostname_11_5_0
29-
keyfactor_username = var.keyfactor_username_AD
30-
keyfactor_password = var.keyfactor_password_AD
31-
keyfactor_config_file = base64encode(file("${path.module}/command_config.json"))
32-
}
33-
34-
module "keyfactor_github_test_environment_11_5_0_CLEAN" {
35-
source = "git::ssh://git@github.com/Keyfactor/terraform-module-keyfactor-github-test-environment-ad.git?ref=main"
36-
37-
gh_environment_name = "KFC_11_5_0_CLEAN"
38-
gh_repo_name = data.github_repository.repo.name
39-
keyfactor_hostname = var.keyfactor_hostname_11_5_0_CLEAN
40-
keyfactor_username = var.keyfactor_username_AD
41-
keyfactor_password = var.keyfactor_password_AD
42-
keyfactor_config_file = base64encode(file("${path.module}/command_config.json"))
43-
}
44-
45-
module "keyfactor_github_test_environment_11_5_0_OAUTH" {
46-
source = "git::ssh://git@github.com/Keyfactor/terraform-module-keyfactor-github-test-environment-ad.git?ref=main"
47-
48-
gh_environment_name = "KFC_11_5_0_OAUTH"
49-
gh_repo_name = data.github_repository.repo.name
50-
keyfactor_hostname = var.keyfactor_hostname_11_5_0_OAUTH
51-
keyfactor_auth_token_url = var.keyfactor_auth_token_url
52-
keyfactor_client_id = var.keyfactor_client_id
53-
keyfactor_client_secret = var.keyfactor_client_secret
54-
keyfactor_tls_skip_verify = true
55-
keyfactor_config_file = base64encode(file("${path.module}/command_config.json"))
56-
}
57-
58-
module "keyfactor_github_test_environment_11_5_0_OAUTH_CLEAN" {
59-
source = "git::ssh://git@github.com/Keyfactor/terraform-module-keyfactor-github-test-environment-ad.git?ref=main"
60-
61-
gh_environment_name = "KFC_11_5_0_OAUTH_CLEAN"
4+
gh_environment_name = "SES_2541"
625
gh_repo_name = data.github_repository.repo.name
63-
keyfactor_hostname = var.keyfactor_hostname_11_5_0_OAUTH_CLEAN
64-
keyfactor_auth_token_url = var.keyfactor_auth_token_url
65-
keyfactor_client_id = var.keyfactor_client_id
66-
keyfactor_client_secret = var.keyfactor_client_secret
6+
keyfactor_hostname = var.ses_2541_hostname
7+
keyfactor_auth_token_url = var.ses_2541_auth_token_url
8+
keyfactor_client_id = var.ses_2541_client_id
9+
keyfactor_client_secret = var.ses_2541_client_secret
6710
keyfactor_tls_skip_verify = true
68-
keyfactor_config_file = base64encode(file("${path.module}/command_config.json"))
11+
keyfactor_config_file = base64encode(file("${path.module}/ses2541_command_config.json"))
6912
}
70-
71-
module "keyfactor_github_test_environment_12_3_0_AD" {
72-
source = "git::ssh://git@github.com/Keyfactor/terraform-module-keyfactor-github-test-environment-ad.git?ref=main"
73-
gh_environment_name = "KFC_12_3_0_AD"
74-
gh_repo_name = data.github_repository.repo.name
75-
keyfactor_hostname = var.keyfactor_hostname_12_3_0
76-
keyfactor_username = var.keyfactor_username_AD
77-
keyfactor_password = var.keyfactor_password_AD
78-
keyfactor_tls_skip_verify = true
79-
keyfactor_config_file = base64encode(file("${path.module}/command_config.json"))
80-
}
81-
82-
83-

.github/config/int1230_oauth.tf

Lines changed: 0 additions & 35 deletions
This file was deleted.

.github/config/int1230c_ad.tf

Lines changed: 0 additions & 16 deletions
This file was deleted.

.github/config/int1230c_oauth.tf

Lines changed: 0 additions & 33 deletions
This file was deleted.

.github/config/variables.tf

Lines changed: 11 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,22 @@
1-
// Hosts
2-
variable "keyfactor_hostname_10_5_0" {
3-
description = "The hostname of the Keyfactor v10.5.x instance"
1+
variable "ses_2541_hostname" {
2+
description = "The hostname of the SES 25.4.1 Keyfactor Command instance"
43
type = string
5-
default = "integrations1050-lab.kfdelivery.com"
4+
default = "int25-4-1.kftestlab.com"
65
}
76

8-
variable "keyfactor_hostname_10_5_0_CLEAN" {
9-
description = "The hostname of the Keyfactor v10.5.x instance with no stores or orchestrators. This is used for store-type tests."
7+
variable "ses_2541_auth_token_url" {
8+
description = "The OAuth token URL for the SES 25.4.1 Keyfactor Command instance"
109
type = string
11-
default = "int1050-test-clean.kfdelivery.com"
10+
default = "https://auth.kftestlab.com/oauth2/token"
1211
}
1312

14-
15-
variable "keyfactor_hostname_11_5_0" {
16-
description = "The hostname of the Keyfactor v11.5.x instance"
17-
type = string
18-
default = "integrations1150-lab.kfdelivery.com"
19-
}
20-
21-
variable "keyfactor_hostname_11_5_0_CLEAN" {
22-
description = "The hostname of the Keyfactor v11.5.x instance with no stores or orchestrators. This is used for store-type tests."
23-
type = string
24-
default = "int1150-test-clean.kfdelivery.com"
25-
}
26-
27-
variable "keyfactor_hostname_11_5_0_OAUTH" {
28-
description = "The hostname of the Keyfactor instance"
29-
type = string
30-
default = "int-oidc-lab.eastus2.cloudapp.azure.com"
31-
}
32-
33-
variable "keyfactor_hostname_11_5_0_OAUTH_CLEAN" {
34-
description = "The hostname of the Keyfactor instance"
35-
type = string
36-
default = "int1150-oauth-test-clean.eastus2.cloudapp.azure.com"
37-
}
38-
39-
40-
variable "keyfactor_hostname_12_3_0" {
41-
description = "The hostname of the Keyfactor v12.3.x instance"
42-
type = string
43-
default = "integrations1230-lab.kfdelivery.com"
44-
}
45-
46-
variable "keyfactor_hostname_12_3_0_CLEAN" {
47-
description = "The hostname of the Keyfactor v12.3.x instance with no stores or orchestrators. This is used for store-type tests."
13+
variable "ses_2541_client_id" {
14+
description = "The OAuth client ID for the SES 25.4.1 Keyfactor Command instance"
4815
type = string
49-
default = "int1230-test-clean.kfdelivery.com"
5016
}
5117

52-
variable "keyfactor_hostname_12_3_0_OAUTH" {
53-
description = "The hostname of the Keyfactor instance"
18+
variable "ses_2541_client_secret" {
19+
description = "The OAuth client secret for the SES 25.4.1 Keyfactor Command instance"
5420
type = string
55-
default = "int-oidc-lab.eastus2.cloudapp.azure.com"
21+
sensitive = true
5622
}
57-
58-
59-
// Authentication
60-
variable "keyfactor_username_AD" {
61-
description = "The username to authenticate with a Keyfactor instance that uses AD authentication"
62-
type = string
63-
}
64-
65-
variable "keyfactor_password_AD" {
66-
description = "The password to authenticate with Keyfactor instance that uses AD authentication"
67-
type = string
68-
}
69-
70-
variable "keyfactor_client_id" {
71-
description = "The client ID to authenticate with the Keyfactor instance using oauth2 client credentials"
72-
type = string
73-
}
74-
75-
variable "keyfactor_client_secret" {
76-
description = "The client secret to authenticate with the Keyfactor instance using oauth2 client credentials"
77-
type = string
78-
}
79-
80-
variable "keyfactor_auth_token_url" {
81-
description = "The token URL to authenticate with the Keyfactor instance using oauth2 client credentials"
82-
type = string
83-
default = "https://int-oidc-lab.eastus2.cloudapp.azure.com:8444/realms/Keyfactor/protocol/openid-connect/token"
84-
}
85-

cmd/helpers.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,14 @@ func outputResult(result interface{}, format string) {
358358
Str("format", format).
359359
Msg(fmt.Sprintf("%s outputResult", DebugFuncEnter))
360360
if format == "json" {
361-
fmt.Println(result)
361+
switch value := result.(type) {
362+
case []byte:
363+
fmt.Println(string(value))
364+
case string:
365+
fmt.Println(value)
366+
default:
367+
fmt.Println(result)
368+
}
362369
} else {
363370
fmt.Println(fmt.Sprintf("%s", result))
364371
}

cmd/login_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ import (
2929
)
3030

3131
func Test_LoginHelpCmd(t *testing.T) {
32+
defer resetRootCommandState()
33+
3234
// Test root help
3335
testCmd := RootCmd
3436
testCmd.SetArgs([]string{"login", "--help"})

cmd/pamTypes_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ func hasIntegrationTestEnvironment() bool {
7474

7575
// Test_PAMTypesHelpCmd tests the help command for pam-types
7676
func Test_PAMTypesHelpCmd(t *testing.T) {
77+
defer resetRootCommandState()
78+
7779
tests := []struct {
7880
name string
7981
args []string

0 commit comments

Comments
 (0)