986aecd28f
Model the provider on terraform-provider-giteavaultsecret, adjusting the schemas to the ghp engine (vault-plugin-secrets-ghp) so its mount, config, and roles can be managed declaratively. - Add provider (local name ghpvaultsecret, source git.unkin.net/unkin/ghpvaultsecret) with VAULT_ADDR/VAULT_TOKEN fallback. - Add ghpvaultsecret_secret_backend: mounts the engine and writes config (base_url, write-only admin_token, write-only ca_cert, tls_skip_verify, request_timeout_seconds); read never returns the sensitive fields. - Add ghpvaultsecret_secret_role: token_type, installation_id, app_record_id, repositories, scopes, session_prefix, ttl, max_ttl; validate that agent roles set installation_id. - Add unit tests for the value conversions and the role/backend field mapping. - Mirror the woodpecker pre-commit/build/test (PR) and tag release (package + PUT zip to the artifactapi terraform registry) pipelines, Makefile version bump/package targets, examples, README, and a Docker e2e harness.
42 lines
1.2 KiB
Go
42 lines
1.2 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://ghp.example.com"),
|
|
AdminToken: types.StringValue("ghpsvc_secret"),
|
|
TLSSkipVerify: types.BoolValue(true),
|
|
RequestTimeoutSeconds: types.Int64Value(15),
|
|
CACert: types.StringNull(),
|
|
}
|
|
data := r.configData(m)
|
|
if data["base_url"] != "https://ghp.example.com" {
|
|
t.Errorf("base_url = %v", data["base_url"])
|
|
}
|
|
if data["admin_token"] != "ghpsvc_secret" {
|
|
t.Errorf("admin_token = %v", data["admin_token"])
|
|
}
|
|
if data["tls_skip_verify"] != true {
|
|
t.Errorf("tls_skip_verify = %v, want true", data["tls_skip_verify"])
|
|
}
|
|
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"])
|
|
}
|
|
}
|