-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pulumi/pulumi-terraform-bridge#1849 This PR adds tests for the following resources: index_grouproles index_role index_user authentication_executionconfig index_realmevents index_group authentication_execution index_realm
- Loading branch information
1 parent
10941e1
commit 2ad0622
Showing
24 changed files
with
376 additions
and
1 deletion.
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
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
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
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
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
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
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
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,125 @@ | ||
//go:build !go && !nodejs && !python && !dotnet | ||
// +build !go,!nodejs,!python,!dotnet | ||
|
||
package keycloak | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/pulumi/providertest" | ||
"github.com/pulumi/providertest/optproviderupgrade" | ||
"github.com/pulumi/providertest/pulumitest" | ||
"github.com/pulumi/providertest/pulumitest/assertpreview" | ||
"github.com/pulumi/providertest/pulumitest/opttest" | ||
"github.com/pulumi/pulumi/sdk/v3/go/auto" | ||
) | ||
|
||
const providerName = "keycloak" | ||
const defaultBaselineVersion = "5.3.1" | ||
|
||
var programs = []string{ | ||
"test-programs/index_grouproles", | ||
"test-programs/index_role", | ||
"test-programs/index_user", | ||
"test-programs/authentication_executionconfig", | ||
"test-programs/index_realmevents", | ||
"test-programs/index_group", | ||
"test-programs/authentication_execution", | ||
"test-programs/index_realm", | ||
} | ||
|
||
func TestUpgradeCoverage(t *testing.T) { | ||
providertest.ReportUpgradeCoverage(t) | ||
} | ||
|
||
type UpgradeTestOpts struct { | ||
baselineVersion string | ||
assertFunc func(*testing.T, auto.PreviewResult) | ||
config map[string]string | ||
} | ||
|
||
func WithBaselineVersion(baselineVersion string) func(opts *UpgradeTestOpts) { | ||
return func(opts *UpgradeTestOpts) { | ||
opts.baselineVersion = baselineVersion | ||
} | ||
} | ||
|
||
func WithAssertFunc(assertFunc func(*testing.T, auto.PreviewResult)) func(opts *UpgradeTestOpts) { | ||
return func(opts *UpgradeTestOpts) { | ||
opts.assertFunc = assertFunc | ||
} | ||
} | ||
|
||
func WithConfig(config map[string]string) func(opts *UpgradeTestOpts) { | ||
return func(opts *UpgradeTestOpts) { | ||
opts.config = config | ||
} | ||
} | ||
func testProviderUpgrade(t *testing.T, dir string, opts ...func(*UpgradeTestOpts)) { | ||
options := &UpgradeTestOpts{} | ||
for _, o := range opts { | ||
o(options) | ||
} | ||
testProviderUpgradeWithOpts(t, dir, options.baselineVersion, options.config, options.assertFunc) | ||
} | ||
|
||
func testProviderUpgradeWithOpts( | ||
t *testing.T, dir, baselineVersion string, config map[string]string, | ||
assertFunction func(*testing.T, auto.PreviewResult), | ||
) { | ||
if testing.Short() { | ||
t.Skipf("Skipping in testing.Short() mode, assuming this is a CI run without credentials") | ||
} | ||
cwd, err := os.Getwd() | ||
require.NoError(t, err) | ||
if baselineVersion == "" { | ||
baselineVersion = defaultBaselineVersion | ||
} | ||
test := pulumitest.NewPulumiTest(t, dir, | ||
opttest.DownloadProviderVersion(providerName, baselineVersion), | ||
opttest.LocalProviderPath(providerName, filepath.Join(cwd, "..", "bin")), | ||
) | ||
for k, v := range config { | ||
test.SetConfig(k, v) | ||
} | ||
result := providertest.PreviewProviderUpgrade(test, providerName, baselineVersion, optproviderupgrade.DisableAttach()) | ||
if assertFunction != nil { | ||
assertFunction(t, result) | ||
} else { | ||
assertpreview.HasNoReplacements(t, result) | ||
} | ||
} | ||
|
||
func testProgram(t *testing.T, dir string) { | ||
if testing.Short() { | ||
t.Skipf("Skipping in testing.Short() mode, assuming this is a CI run without credentials") | ||
} | ||
cwd, err := os.Getwd() | ||
require.NoError(t, err) | ||
test := pulumitest.NewPulumiTest(t, dir, | ||
opttest.LocalProviderPath(providerName, filepath.Join(cwd, "..", "bin")), | ||
opttest.SkipInstall(), | ||
) | ||
test.Up() | ||
} | ||
|
||
func TestPrograms(t *testing.T) { | ||
for _, p := range programs { | ||
t.Run(p, func(t *testing.T) { | ||
testProgram(t, p) | ||
}) | ||
} | ||
} | ||
|
||
func TestProgramsUpgrade(t *testing.T) { | ||
t.Skipf("skip upgrade tests for now as we have not recorded them.") | ||
for _, p := range programs { | ||
t.Run(p, func(t *testing.T) { | ||
testProviderUpgrade(t, p) | ||
}) | ||
} | ||
} |
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,2 @@ | ||
|
||
/Pulumi.*.yaml |
26 changes: 26 additions & 0 deletions
26
provider/test-programs/authentication_execution/Pulumi.yaml
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,26 @@ | ||
name: authentication_executionh1UGP0Fkk0eT | ||
runtime: yaml | ||
description: "" | ||
config: | ||
pulumi:tags: | ||
value: | ||
pulumi:template: https://www.pulumi.com/ai/api/project/78b9933c-6dd9-4b72-946e-68edc38eae64.zip | ||
resources: | ||
keycloakAuthExecution: | ||
properties: | ||
authenticator: auth-cookie | ||
parentFlowAlias: ${keycloakAuthFlow.alias} | ||
realmId: ${keycloakRealm.realm} | ||
requirement: REQUIRED | ||
type: keycloak:authentication:Execution | ||
keycloakAuthFlow: | ||
properties: | ||
alias: custom-auth-flow | ||
description: A custom authentication flow | ||
realmId: ${keycloakRealm.realm} | ||
type: keycloak:authentication:Flow | ||
keycloakRealm: | ||
properties: | ||
enabled: true | ||
realm: example-realm | ||
type: keycloak:Realm |
2 changes: 2 additions & 0 deletions
2
provider/test-programs/authentication_executionconfig/.gitignore
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,2 @@ | ||
|
||
/Pulumi.*.yaml |
35 changes: 35 additions & 0 deletions
35
provider/test-programs/authentication_executionconfig/Pulumi.yaml
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,35 @@ | ||
name: authentication_executionconfige7oBrvJ1p51V | ||
runtime: yaml | ||
description: "" | ||
config: | ||
pulumi:tags: | ||
value: | ||
pulumi:template: https://www.pulumi.com/ai/api/project/f5185d25-5cc4-482d-b8f9-9b7f0db546e5.zip | ||
resources: | ||
keycloakAuthenticationExecution: | ||
properties: | ||
authenticator: auth-cookie | ||
parentFlowAlias: ${keycloakAuthenticationFlow.alias} | ||
realmId: ${keycloakRealm.realm} | ||
type: keycloak:authentication:Execution | ||
keycloakAuthenticationExecutionConfig: | ||
properties: | ||
alias: execution-config | ||
config: | ||
user_attribute: username | ||
executionId: ${keycloakAuthenticationExecution.id} | ||
realmId: ${keycloakRealm.realm} | ||
type: keycloak:authentication:ExecutionConfig | ||
keycloakAuthenticationFlow: | ||
properties: | ||
alias: myflow | ||
description: My Authentication Flow | ||
providerId: basic-flow | ||
realmId: ${keycloakRealm.realm} | ||
type: keycloak:authentication:Flow | ||
keycloakRealm: | ||
properties: | ||
displayName: My Realm | ||
enabled: true | ||
realm: myrealm | ||
type: keycloak:Realm |
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,2 @@ | ||
|
||
/Pulumi.*.yaml |
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,18 @@ | ||
name: index_groupcghckcNmry6y | ||
runtime: yaml | ||
description: A minimal Pulumi program that creates a Keycloak group with its dependencies | ||
config: | ||
pulumi:tags: | ||
value: | ||
pulumi:template: https://www.pulumi.com/ai/api/project/19fcc853-1bd3-4b46-b9fd-d1969fb095dc.zip | ||
resources: | ||
keycloakGroup: | ||
properties: | ||
|
||
realmId: ${keycloakRealm.id} | ||
type: keycloak:Group | ||
keycloakRealm: | ||
properties: | ||
enabled: true | ||
realm: example-realm | ||
type: keycloak:Realm |
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,2 @@ | ||
|
||
/Pulumi.*.yaml |
Oops, something went wrong.