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 d8238d4
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
21 changes: 21 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 }}/plugins:/vault/plugins
mysql:
image: docker.mirror.hashicorp.services/mysql:latest
env:
Expand Down Expand Up @@ -153,6 +157,8 @@ jobs:
LDAP_PASSWORDS: "password1,password2,password3"
steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
with:
path: "terraform-provider-vault"
- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version-file: '.go-version'
Expand All @@ -165,6 +171,19 @@ jobs:
terraform_wrapper: false
- name: Check Terraform CLI version
run: terraform --version
- name: Download external plugin
env:
PLUGIN: "vault-plugin-auth-jwt"
VERSION: "0.17.0"
run: |
mkdir plugins && cd plugins
ZIP="${PLUGIN}_${VERSION}_linux_amd64.zip"
SHA256SUMS="${PLUGIN}_${VERSION}_SHA256SUMS"
wget --quiet https://releases.hashicorp.com/${PLUGIN}/${VERSION}/{${ZIP},${SHA256SUMS}}
shasum -a 256 -c "${PLUGIN}_${VERSION}_SHA256SUMS" --ignore-missing
unzip "${ZIP}"; rm "${ZIP}" "${SHA256SUMS}"
export VAULT_PLUGIN_SHA256="$(shasum -a256 "$PLUGIN" | awk '{print $1}')"
export VAULT_PLUGIN_COMMAND="vault-plugin-auth-jwt"
- name: Cache go build
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
Expand All @@ -178,6 +197,7 @@ jobs:
${{ runner.os }}-golang-
- name: Acceptance Tests
working-directory: terraform-provider-vault
env:
VAULT_TOKEN: "root"
VAULT_ADDR: "http://localhost:8200"
Expand Down Expand Up @@ -206,5 +226,6 @@ jobs:
fi
make $target TESTARGS='-test.v' SKIP_MSSQL_MULTI_CI=true SKIP_RAFT_TESTS=true SKIP_VAULT_NEXT_TESTS=true TF_ACC_K8S_SKIP_IN_CLUSTER=true
- name: "Generate Vault API Path Coverage Report"
working-directory: terraform-provider-vault
run: |
go run cmd/coverage/main.go -openapi-doc=./testdata/openapi.json
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 d8238d4

Please sign in to comment.