Clean up some of the SSH key tests
This commit is contained in:
parent
ca405b29f6
commit
9b20173dfb
|
@ -2,24 +2,30 @@ require File.expand_path("../../base", __FILE__)
|
||||||
|
|
||||||
describe Vagrant::SSH do
|
describe Vagrant::SSH do
|
||||||
context "check_key_permissions" do
|
context "check_key_permissions" do
|
||||||
let(:key_path) { File.expand_path("../id_rsa", __FILE__) }
|
let(:key_path) do
|
||||||
|
# We create a tempfile to guarantee some level of uniqueness
|
||||||
|
# then explicitly close/unlink but save the path so we can re-use
|
||||||
|
temp = Tempfile.new("vagrant")
|
||||||
|
result = Pathname.new(temp.path)
|
||||||
|
temp.close
|
||||||
|
temp.unlink
|
||||||
|
|
||||||
|
result
|
||||||
|
end
|
||||||
|
|
||||||
let(:ssh_instance) { Vagrant::SSH.new(double) }
|
let(:ssh_instance) { Vagrant::SSH.new(double) }
|
||||||
|
|
||||||
before(:each) do
|
before(:each) do
|
||||||
File.open(key_path, 'w') do |file|
|
key_path.open("w") do |f|
|
||||||
file.write("hello!")
|
f.write("hello!")
|
||||||
end
|
end
|
||||||
File.chmod(644, key_path)
|
|
||||||
end
|
|
||||||
|
|
||||||
after(:each) do
|
key_path.chmod(0644)
|
||||||
FileUtils.rm(key_path)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should not raise an exception if we set a keyfile permission correctly" do
|
it "should not raise an exception if we set a keyfile permission correctly" do
|
||||||
ssh_instance.check_key_permissions(key_path)
|
ssh_instance.check_key_permissions(key_path)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue