vault_addr = 'https://vault.dev.theorchard.io:8200'

describe json({ command: "vault status -address=#{vault_addr} -format=json" }) do
  its('initialized') { should eq true }
  its('sealed') { should eq false }
end

describe json({ command: "vault operator members -address=#{vault_addr} -format=json" }) do
  its(['Nodes', 0, 'active_node']) { should eq true }
end

describe json({ command: "vault operator raft list-peers -address=#{vault_addr} -format=json" }) do
  its(['data', 'config', 'servers', 0, 'leader']) { should eq true }
end

describe file('/etc/vault.d/vault.hcl') do
  it { should exist }
  its('content') { should include('unauthenticated_metrics_access = true') }
  its('content') { should include('prometheus_retention_time = "30s"') }
  its('content') { should include('disable_hostname = true') }
end
