Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed HttpCodec Check #781

Merged
merged 10 commits into from
Apr 4, 2024
3 changes: 3 additions & 0 deletions .changelog/781.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
Fixed an issue that caused a HTTP audit-log streaming config to fail with allowed values for http_codec are only "JSON" or "NDJSON"
```
2 changes: 1 addition & 1 deletion internal/providersdkv2/resource_vault_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -1587,7 +1587,7 @@ func getValidObservabilityConfig(config map[string]interface{}) (*vaultmodels.Ha
invalidProviderConfigError = diag.Errorf("http configuration is invalid: allowed values for http_method are only \"POST\", \"PUT\", or \"PATCH\"")
}

if strings.ToUpper(httpMethod) != "JSON" && strings.ToUpper(httpMethod) != "NDJSON" {
if strings.ToUpper(httpCodec) != "JSON" && strings.ToUpper(httpCodec) != "NDJSON" {
invalidProviderConfigError = diag.Errorf("http configuration is invalid: allowed values for http_codec are only \"JSON\" or \"NDJSON\"")
jaireddjawed marked this conversation as resolved.
Show resolved Hide resolved
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,80 @@ func performanceReplicationSteps(t *testing.T, in *inputT) []resource.TestStep {
resource.TestCheckResourceAttrSet(primaryVaultResourceName, "created_at"),
),
},
{
// add an http audit log provider
Config: testConfig(setTestAccPerformanceReplicationE2E(t, `
resource "hcp_vault_cluster" "c1" {
cluster_id = "{{ .VaultClusterName }}"
hvn_id = hcp_hvn.hvn1.hvn_id
tier = "{{ .Tier }}"
public_endpoint = true
audit_log_config {
http_endpoint = "https://http-input-splunkcloud.com"
http_codec = "INVALID"
http_method = "POST"
}
}
`, in)),
Check: resource.ComposeTestCheckFunc(
testAccCheckVaultClusterExists(primaryVaultResourceName),
resource.TestCheckResourceAttr(primaryVaultResourceName, "cluster_id", in.VaultClusterName),
resource.TestCheckResourceAttr(primaryVaultResourceName, "hvn_id", in.HvnName),
resource.TestCheckResourceAttr(primaryVaultResourceName, "tier", in.Tier),
resource.TestCheckResourceAttr(primaryVaultResourceName, "cloud_provider", in.CloudProvider),
resource.TestCheckResourceAttr(primaryVaultResourceName, "region", in.Region),
resource.TestCheckResourceAttr(primaryVaultResourceName, "public_endpoint", "true"),
resource.TestCheckResourceAttr(primaryVaultResourceName, "namespace", "admin"),
resource.TestCheckResourceAttrSet(primaryVaultResourceName, "vault_version"),
resource.TestCheckResourceAttrSet(primaryVaultResourceName, "organization_id"),
resource.TestCheckResourceAttrSet(primaryVaultResourceName, "project_id"),
resource.TestCheckResourceAttrSet(primaryVaultResourceName, "vault_public_endpoint_url"),
resource.TestCheckResourceAttrSet(primaryVaultResourceName, "self_link"),
resource.TestCheckResourceAttrSet(primaryVaultResourceName, "vault_private_endpoint_url"),
testAccCheckFullURL(primaryVaultResourceName, "vault_private_endpoint_url", ""),
resource.TestCheckResourceAttrSet(primaryVaultResourceName, "created_at"),
resource.TestCheckResourceAttrSet(primaryVaultResourceName, "audit_log_config.0.http_endpoint"),
resource.TestCheckResourceAttr(primaryVaultResourceName, "audit_log_config.0.http_method", "POST"),
),
ExpectError: regexp.MustCompile(`http configuration is invalid: allowed values for http_codec are only \"JSON\" or \"NDJSON\"`),
},
{
// add an http audit log provider
Config: testConfig(setTestAccPerformanceReplicationE2E(t, `
resource "hcp_vault_cluster" "c1" {
cluster_id = "{{ .VaultClusterName }}"
hvn_id = hcp_hvn.hvn1.hvn_id
tier = "{{ .Tier }}"
public_endpoint = true
audit_log_config {
http_endpoint = "https://http-input-splunkcloud.com"
http_codec = "JSON"
http_method = "POST"
}
}
`, in)),
Check: resource.ComposeTestCheckFunc(
testAccCheckVaultClusterExists(primaryVaultResourceName),
resource.TestCheckResourceAttr(primaryVaultResourceName, "cluster_id", in.VaultClusterName),
resource.TestCheckResourceAttr(primaryVaultResourceName, "hvn_id", in.HvnName),
resource.TestCheckResourceAttr(primaryVaultResourceName, "tier", in.Tier),
resource.TestCheckResourceAttr(primaryVaultResourceName, "cloud_provider", in.CloudProvider),
resource.TestCheckResourceAttr(primaryVaultResourceName, "region", in.Region),
resource.TestCheckResourceAttr(primaryVaultResourceName, "public_endpoint", "true"),
resource.TestCheckResourceAttr(primaryVaultResourceName, "namespace", "admin"),
resource.TestCheckResourceAttrSet(primaryVaultResourceName, "vault_version"),
resource.TestCheckResourceAttrSet(primaryVaultResourceName, "organization_id"),
resource.TestCheckResourceAttrSet(primaryVaultResourceName, "project_id"),
resource.TestCheckResourceAttrSet(primaryVaultResourceName, "vault_public_endpoint_url"),
resource.TestCheckResourceAttrSet(primaryVaultResourceName, "self_link"),
resource.TestCheckResourceAttrSet(primaryVaultResourceName, "vault_private_endpoint_url"),
testAccCheckFullURL(primaryVaultResourceName, "vault_private_endpoint_url", ""),
resource.TestCheckResourceAttrSet(primaryVaultResourceName, "created_at"),
resource.TestCheckResourceAttrSet(primaryVaultResourceName, "audit_log_config.0.http_endpoint"),
resource.TestCheckResourceAttr(primaryVaultResourceName, "audit_log_config.0.http_codec", "JSON"),
resource.TestCheckResourceAttr(primaryVaultResourceName, "audit_log_config.0.http_method", "POST"),
),
},
{
// secondary cluster creation failed as tier doesn't match the tier of primary
Config: testConfig(setTestAccPerformanceReplicationE2E(t, `
Expand Down