2014-01-17 02:03:38 +00:00
|
|
|
require_relative "../../../../base"
|
|
|
|
|
|
|
|
require Vagrant.source_root.join("plugins/provisioners/chef/provisioner/base")
|
|
|
|
|
|
|
|
describe VagrantPlugins::Chef::Provisioner::Base do
|
|
|
|
include_context "unit"
|
|
|
|
|
|
|
|
let(:machine) { double("machine") }
|
|
|
|
let(:config) { double("config") }
|
|
|
|
|
|
|
|
subject { described_class.new(machine, config) }
|
|
|
|
|
|
|
|
describe "#encrypted_data_bag_secret_key_path" do
|
|
|
|
let(:env) { double("env") }
|
|
|
|
let(:root_path) { "/my/root" }
|
|
|
|
|
|
|
|
before do
|
2014-03-14 15:02:07 +00:00
|
|
|
allow(machine).to receive(:env).and_return(env)
|
|
|
|
allow(env).to receive(:root_path).and_return(root_path)
|
2014-01-17 02:03:38 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it "returns absolute path as is" do
|
2014-03-14 15:02:07 +00:00
|
|
|
expect(config).to receive(:encrypted_data_bag_secret_key_path).
|
2014-01-17 02:03:38 +00:00
|
|
|
and_return("/foo/bar")
|
|
|
|
expect(subject.encrypted_data_bag_secret_key_path).to eq "/foo/bar"
|
|
|
|
end
|
|
|
|
|
|
|
|
it "returns relative path joined to root_path" do
|
2014-03-14 15:02:07 +00:00
|
|
|
expect(config).to receive(:encrypted_data_bag_secret_key_path).
|
2014-01-17 02:03:38 +00:00
|
|
|
and_return("secret")
|
|
|
|
expect(subject.encrypted_data_bag_secret_key_path).to eq "/my/root/secret"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "#guest_encrypted_data_bag_secret_key_path" do
|
2014-02-16 21:14:56 +00:00
|
|
|
it "returns nil if host path is not configured" do
|
2014-03-14 15:02:07 +00:00
|
|
|
allow(config).to receive(:encrypted_data_bag_secret_key_path).and_return(nil)
|
|
|
|
allow(config).to receive(:provisioning_path).and_return("/tmp/foo")
|
2014-02-16 21:14:56 +00:00
|
|
|
expect(subject.guest_encrypted_data_bag_secret_key_path).to be_nil
|
|
|
|
end
|
|
|
|
|
2014-01-17 02:03:38 +00:00
|
|
|
it "returns path under config.provisioning_path" do
|
2014-03-14 15:02:07 +00:00
|
|
|
allow(config).to receive(:encrypted_data_bag_secret_key_path).and_return("secret")
|
|
|
|
allow(config).to receive(:provisioning_path).and_return("/tmp/foo")
|
2014-01-17 02:03:38 +00:00
|
|
|
expect(File.dirname(subject.guest_encrypted_data_bag_secret_key_path)).
|
|
|
|
to eq "/tmp/foo"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|