Sha256: da590e7f870e3275a3137113e5f39dd4b4968bfe9693d6e8498b135b21a5f24b

Contents?: true

Size: 1.71 KB

Versions: 13

Compression:

Stored size: 1.71 KB

Contents

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
      allow(machine).to receive(:env).and_return(env)
      allow(env).to receive(:root_path).and_return(root_path)
    end

    it "returns absolute path as is" do
      expect(config).to receive(:encrypted_data_bag_secret_key_path).
        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
      expect(config).to receive(:encrypted_data_bag_secret_key_path).
        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
    it "returns nil if host path is not configured" do
      allow(config).to receive(:encrypted_data_bag_secret_key_path).and_return(nil)
      allow(config).to receive(:provisioning_path).and_return("/tmp/foo")
      expect(subject.guest_encrypted_data_bag_secret_key_path).to be_nil
    end

    it "returns path under config.provisioning_path" do
      allow(config).to receive(:encrypted_data_bag_secret_key_path).and_return("secret")
      allow(config).to receive(:provisioning_path).and_return("/tmp/foo")
      expect(File.dirname(subject.guest_encrypted_data_bag_secret_key_path)).
        to eq "/tmp/foo"
    end
  end
end

Version data entries

13 entries across 10 versions & 3 rubygems

Version Path
vagrant-cloudstack-1.1.0 vendor/bundle/bundler/gems/vagrant-b421af58e8b3/test/unit/plugins/provisioners/chef/provisioner/base_test.rb
vagrant-cloudstack-1.1.0 vendor/bundle/bundler/gems/vagrant-309e896975d1/test/unit/plugins/provisioners/chef/provisioner/base_test.rb
vagrant-cloudstack-1.1.0 vendor/bundle/bundler/gems/vagrant-272fb27e0536/test/unit/plugins/provisioners/chef/provisioner/base_test.rb
vagrant-cloudstack-1.1.0 vendor/bundle/bundler/gems/vagrant-1cf2a8db4ccb/test/unit/plugins/provisioners/chef/provisioner/base_test.rb
vagrant-dsc-1.0.5 spec/provisioner/base_test.rb.bak
vagrant-dsc-1.0.4 spec/provisioner/base_test.rb.bak
vagrant-dsc-1.0.3 spec/provisioner/base_test.rb.bak
vagrant-dsc-1.0.2 spec/provisioner/base_test.rb.bak
vagrant-dsc-1.0.1 spec/provisioner/base_test.rb.bak
vagrant-dsc-1.0.0 spec/provisioner/base_test.rb.bak
vagrant-dsc-0.0.1.beta spec/provisioner/base_test.rb.bak
vagrant-dsc-0.0.1 spec/provisioner/base_test.rb.bak
vagrant-tiktalik-0.0.3 vendor/bundle/ruby/2.0.0/bundler/gems/vagrant-1e28f1ac31e7/test/unit/plugins/provisioners/chef/provisioner/base_test.rb