Skip to content

Commit

Permalink
Actually actually fix the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tomhjp committed Mar 1, 2024
1 parent 748793c commit e7fe248
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,17 @@ jobs:
VAULT_DEV_ROOT_TOKEN_ID: root
VAULT_LICENSE: ${{ secrets.VAULT_LICENSE }}
VAULT_AUTH_CONFIG_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VAULT_LOCAL_CONFIG: |
{"plugin_directory": "/vault/plugins"}
options: >-
--health-cmd "VAULT_ADDR=http://127.0.0.1:8200 vault status"
--health-interval 1s
--health-timeout 5s
--health-retries 5
ports:
- 8200:8200
volumes:
- ${{ github.workspace }}:/vault/plugins
mysql:
image: docker.mirror.hashicorp.services/mysql:latest
env:
Expand Down Expand Up @@ -165,6 +169,18 @@ jobs:
terraform_wrapper: false
- name: Check Terraform CLI version
run: terraform --version
- name: Download external plugin
id: plugin
env:
PLUGIN: "vault-plugin-auth-jwt"
VERSION: "0.17.0"
run: |
ZIP="${PLUGIN}_${VERSION}_linux_amd64.zip"
SHA256SUMS="${PLUGIN}_${VERSION}_SHA256SUMS"
curl -sO "https://releases.hashicorp.com/${PLUGIN}/${VERSION}/{${ZIP},${SHA256SUMS}}"
shasum -a 256 -c "${PLUGIN}_${VERSION}_SHA256SUMS" --ignore-missing
unzip "${ZIP}"; rm "${ZIP}" "${SHA256SUMS}"
echo "command=${PLUGIN}" >> "${GITHUB_OUTPUT}"
- name: Cache go build
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
Expand Down Expand Up @@ -198,6 +214,7 @@ jobs:
LDAP_BINDDN: "cn=admin,dc=example,dc=org"
LDAP_BINDPASS: "adminpassword"
LDAP_URL: "ldap://openldap:1389"
VAULT_PLUGIN_COMMAND: ${{ steps.plugin.outputs.command }}
run: |
if [[ ${{ matrix.image }} =~ "-ent" ]]; then
target="testacc-ent"
Expand Down
4 changes: 3 additions & 1 deletion vault/resource_plugin_pinned_version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package vault

import (
"fmt"
"os"
"strings"
"testing"

Expand All @@ -30,6 +31,7 @@ func TestPluginPinnedVersion(t *testing.T) {
ProviderFactories: providerFactories,
PreCheck: func() {
testutil.TestAccPreCheck(t)
testutil.SkipTestEnvUnset(t, envPluginCommand)
SkipIfAPIVersionLT(t, testProvider.Meta(), provider.VaultVersion116)
},
Steps: []resource.TestStep{
Expand Down Expand Up @@ -58,7 +60,7 @@ resource "vault_plugin_pinned_version" "test" {
name = vault_plugin.test.name
version = vault_plugin.test.version
}
`, testPluginConfig(pluginType, name, version, sha256, "command", `["--arg"]`, `["foo=bar"]`))
`, testPluginConfig(pluginType, name, version, sha256, os.Getenv(envPluginCommand), `["--arg"]`, `["foo=bar"]`))

return ret
}
6 changes: 5 additions & 1 deletion vault/resource_plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package vault

import (
"fmt"
"os"
"strconv"
"strings"
"testing"
Expand All @@ -17,11 +18,12 @@ import (
"github.com/hashicorp/terraform-provider-vault/testutil"
)

const envPluginCommand = "VAULT_PLUGIN_COMMAND"

func TestPlugin(t *testing.T) {
const (
typ = "auth"
version = "v1.0.0"
cmd = "command"
args = `["--foo"]`
env = `["FOO=BAR"]`
)
Expand All @@ -30,11 +32,13 @@ func TestPlugin(t *testing.T) {

resourceName := "vault_plugin.test"
sha256 := strings.Repeat("01234567", 8)
cmd := os.Getenv(envPluginCommand)

resource.Test(t, resource.TestCase{
ProviderFactories: providerFactories,
PreCheck: func() {
testutil.TestAccPreCheck(t)
testutil.SkipTestEnvUnset(t, envPluginCommand)
},
Steps: []resource.TestStep{
{
Expand Down

0 comments on commit e7fe248

Please sign in to comment.