78ba0011f9
Configure the arrstack Vault secrets engine (backend config + roles) from terraform-vault, matching the schema declared in terraform-vault #127. - Add terraform-plugin-framework provider (local name arrstack) authenticating to Vault/OpenBao via address + token (VAULT_ADDR/VAULT_TOKEN fallback). - Add arrstack_secret_backend resource: mounts the engine and writes <mount>/config. - Add arrstack_secret_backend_role resource: manages <mount>/roles/<name>. - Add Vault client, conversions, unit tests, Makefile, woodpecker CI + tag release to artifactapi terraform-unkin, examples, and README.
38 lines
1.1 KiB
Go
38 lines
1.1 KiB
Go
package provider
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/hashicorp/terraform-plugin-framework/types"
|
|
)
|
|
|
|
func TestBackendConfigData(t *testing.T) {
|
|
r := &secretBackendResource{}
|
|
|
|
m := secretBackendModel{
|
|
BaseURL: types.StringValue("https://arrstack.example.com"),
|
|
AdminToken: types.StringValue("arrsvc_secret"),
|
|
RequestTimeoutSeconds: types.Int64Value(15),
|
|
CACert: types.StringNull(),
|
|
}
|
|
data := r.configData(m)
|
|
if data["base_url"] != "https://arrstack.example.com" {
|
|
t.Errorf("base_url = %v", data["base_url"])
|
|
}
|
|
if data["admin_token"] != "arrsvc_secret" {
|
|
t.Errorf("admin_token = %v", data["admin_token"])
|
|
}
|
|
if data["request_timeout_seconds"] != int64(15) {
|
|
t.Errorf("request_timeout_seconds = %v, want 15", data["request_timeout_seconds"])
|
|
}
|
|
if _, ok := data["ca_cert"]; ok {
|
|
t.Errorf("ca_cert should be omitted when null")
|
|
}
|
|
|
|
m.CACert = types.StringValue("-----BEGIN CERTIFICATE-----")
|
|
data = r.configData(m)
|
|
if data["ca_cert"] != "-----BEGIN CERTIFICATE-----" {
|
|
t.Errorf("ca_cert = %v", data["ca_cert"])
|
|
}
|
|
}
|