Context
I am trying to use the TestCoreUnsealed API to unit test my application’s integration with Vault. My application is using the approle auth method and needs to be configured with a role-id and secret-id
I am trying to unit test it with a test in-memory vault server setup with approle enabled, policy, role, secret so that it will spit out the role-id and secret-id after which I can UT my application.
Test Snippet
I am stuck at the part where I enable the approle in the UT.
func startVaultServer(t *testing.T) (net.Listener, *api.Client) {
core, _, rootToken := vault.TestCoreUnsealed(t)
ln, addr := http.TestServer(t, core)
t.Logf("addr = %v", addr)
conf := api.DefaultConfig()
conf.Address = addr
client, err := api.NewClient(conf)
if err != nil {
t.Fatal(err)
}
client.SetToken(rootToken)
err = client.Sys().EnableAuthWithOptions("approle/", &api.EnableAuthOptions{
Type : "approle",
})
if err != nil {
t.Fatal(err)
}
t.Logf("approle enabled")
// TODO: Setup policy, create role, write secret-id, get role-id / secret-id
return ln, client
}
I get this error when running this:
Error making API request.
URL: POST http://127.0.0.1:46559/v1/sys/auth/approle
Code: 400. Errors:
* plugin not found in the catalog: approle
Am I missing something?