-
Notifications
You must be signed in to change notification settings - Fork 5
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
94d4361
commit 02ed31f
Showing
22 changed files
with
309 additions
and
9 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
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,124 @@ | ||
//go:build !go && !nodejs && !python && !dotnet | ||
// +build !go,!nodejs,!python,!dotnet | ||
|
||
package provider | ||
|
||
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 = "vault" | ||
const defaultBaselineVersion = "6.1.0" | ||
|
||
var programs = []string{ | ||
"test-programs/index_authbackend", | ||
"test-programs/.DS_Store", | ||
"test-programs/index_policy", | ||
"test-programs/index_token", | ||
"test-programs/identity_group", | ||
"test-programs/generic_secret", | ||
"test-programs/github_team", | ||
"test-programs/github_authbackend", | ||
} | ||
|
||
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")), | ||
) | ||
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 |
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,16 @@ | ||
name: generic_secretu9D5NnHN3wn0 | ||
runtime: yaml | ||
description: A minimal Pulumi program that creates a Vault generic secret. | ||
config: | ||
pulumi:tags: | ||
value: | ||
pulumi:template: https://www.pulumi.com/ai/api/project/a5eac62a-60d0-4da3-8157-8d257e502a99.zip | ||
resources: | ||
mySecret: | ||
properties: | ||
dataJson: | | ||
{ | ||
"key": "value" | ||
} | ||
path: secret/data/my-secret | ||
type: vault:generic:Secret |
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,19 @@ | ||
name: github_authbackendObKLW8YdG3Df | ||
runtime: yaml | ||
description: A minimal Pulumi YAML program to configure a Vault GitHub Auth backend | ||
config: | ||
pulumi:tags: | ||
value: | ||
pulumi:template: https://www.pulumi.com/ai/api/project/52e3092f-ac07-4f8d-8928-88422784bafd.zip | ||
configuration: | ||
organization: | ||
default: my-organization | ||
description: The GitHub organization to authenticate against. | ||
outputs: | ||
githubAuthBackendPath: ${github_auth_backend.path} | ||
resources: | ||
github_auth_backend: | ||
properties: | ||
description: GitHub auth backend configured for ${organization} | ||
organization: ${organization} | ||
type: vault:github:AuthBackend |
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: github_teambefCvo0Ik4WA | ||
runtime: yaml | ||
description: "" | ||
config: | ||
pulumi:tags: | ||
value: | ||
pulumi:template: https://www.pulumi.com/ai/api/project/7ef548e7-1f8c-4eba-9a5b-ee6036b7b4bb.zip | ||
resources: | ||
example_auth_backend: | ||
properties: | ||
path: github | ||
type: github | ||
type: vault:AuthBackend | ||
example_team: | ||
properties: | ||
backend: ${example_auth_backend.path} | ||
team: team-name | ||
type: vault:github:Team |
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,13 @@ | ||
name: identity_grouphsdWTrSxme8t | ||
runtime: yaml | ||
description: "" | ||
config: | ||
pulumi:tags: | ||
value: | ||
pulumi:template: https://www.pulumi.com/ai/api/project/eb4ff383-9b4f-47ca-af31-b0e0385469ee.zip | ||
resources: | ||
my-vault-group: | ||
properties: | ||
policies: | ||
- default | ||
type: vault:identity:Group |
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.