-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d323696
commit 0e691fb
Showing
2 changed files
with
108 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
92 changes: 92 additions & 0 deletions
92
consul/resource_consul_config_entry_service_intentions_ee_test.go
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,92 @@ | ||
// Copyright (c) HashiCorp, Inc. | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
package consul | ||
|
||
import ( | ||
"github.com/hashicorp/terraform-plugin-sdk/helper/resource" | ||
"testing" | ||
) | ||
|
||
func TestAccConsulConfigEntryServiceIntentionsEETest(t *testing.T) { | ||
providers, _ := startTestServer(t) | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { skipTestOnConsulCommunityEdition(t) }, | ||
Providers: providers, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testConsulConfigEntryServiceIntentionsEE, | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttr("consul_config_entry_service_intentions.foo", "name", "service-intention"), | ||
resource.TestCheckResourceAttr("consul_config_entry_service_intentions.foo", "namespace", "ns1"), | ||
resource.TestCheckResourceAttr("consul_config_entry_service_intentions.foo", "partition", "pr1"), | ||
resource.TestCheckResourceAttr("consul_config_entry_service_intentions.foo", "meta.key", "value"), | ||
resource.TestCheckResourceAttr("consul_config_entry_service_intentions.foo", "sources.0.name", "frontend-webapp"), | ||
resource.TestCheckResourceAttr("consul_config_entry_service_intentions.foo", "sources.0.type", "consul"), | ||
resource.TestCheckResourceAttr("consul_config_entry_service_intentions.foo", "sources.0.action", "allow"), | ||
resource.TestCheckResourceAttr("consul_config_entry_service_intentions.foo", "sources.0.precedence", "9"), | ||
resource.TestCheckResourceAttr("consul_config_entry_service_intentions.foo", "sources.1.name", "nightly-cronjob"), | ||
resource.TestCheckResourceAttr("consul_config_entry_service_intentions.foo", "sources.1.type", "consul"), | ||
resource.TestCheckResourceAttr("consul_config_entry_service_intentions.foo", "sources.1.action", "deny"), | ||
resource.TestCheckResourceAttr("consul_config_entry_service_intentions.foo", "sources.1.precedence", "9"), | ||
resource.TestCheckResourceAttr("consul_config_entry_service_intentions.foo", "jwt.2394986741.providers.0.name", "okta"), | ||
resource.TestCheckResourceAttr("consul_config_entry_service_intentions.foo", "jwt.2394986741.providers.0.verify_claims.0.path.0", "/"), | ||
resource.TestCheckResourceAttr("consul_config_entry_service_intentions.foo", "jwt.2394986741.providers.0.verify_claims.0.path.1", "path1"), | ||
resource.TestCheckResourceAttr("consul_config_entry_service_intentions.foo", "jwt.2394986741.providers.0.verify_claims.1.path.0", "/path"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
const testConsulConfigEntryServiceIntentionsEE = ` | ||
resource "consul_config_entry" "jwt_provider" { | ||
name = "okta" | ||
kind = "jwt-provider" | ||
config_json = jsonencode({ | ||
ClockSkewSeconds = 30 | ||
Issuer = "test-issuer" | ||
JSONWebKeySet = { | ||
Remote = { | ||
URI = "https://127.0.0.1:9091" | ||
FetchAsynchronously = true | ||
} | ||
} | ||
}) | ||
} | ||
resource "consul_config_entry_service_intentions" "foo" { | ||
name = "service-intention" | ||
namespace = "ns1" | ||
partition = "pr1" | ||
meta = { | ||
key = "value" | ||
} | ||
jwt { | ||
providers { | ||
name = consul_config_entry.jwt_provider.name | ||
verify_claims { | ||
path = ["/", "path1"] | ||
value = "" | ||
} | ||
verify_claims { | ||
path = ["/path"] | ||
value = "value" | ||
} | ||
} | ||
} | ||
sources { | ||
action = "allow" | ||
name = "frontend-webapp" | ||
precedence = 9 | ||
type = "consul" | ||
} | ||
sources { | ||
name = "nightly-cronjob" | ||
precedence = 9 | ||
type = "consul" | ||
action = "deny" | ||
} | ||
} | ||
` |