2019-06-11 22:24:35 +00:00
|
|
|
require "helper"
|
|
|
|
require "inspec/resource"
|
|
|
|
require "inspec/resources/ssh_config"
|
2015-09-05 15:05:07 +00:00
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
describe "Inspec::Resources::SshConfig" do
|
2015-09-05 15:05:07 +00:00
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
describe "ssh_config" do
|
|
|
|
it "check ssh config parsing" do
|
|
|
|
resource = load_resource("ssh_config")
|
|
|
|
_(resource.Host).must_equal "*"
|
2017-06-11 10:16:10 +00:00
|
|
|
_(resource.Tunnel).must_be_nil
|
2019-06-11 22:24:35 +00:00
|
|
|
_(resource.SendEnv).must_equal "LANG LC_*"
|
|
|
|
_(resource.HashKnownHosts).must_equal "yes"
|
2016-08-15 20:03:44 +00:00
|
|
|
end
|
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
it "is case insensitive" do
|
|
|
|
resource = load_resource("ssh_config")
|
|
|
|
_(resource.gssapiauthentication).must_equal "no"
|
|
|
|
_(resource.GSSAPIAuthentication).must_equal "no"
|
2015-09-05 15:05:07 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
describe "sshd_config" do
|
|
|
|
it "check protocol version" do
|
|
|
|
resource = load_resource("sshd_config")
|
|
|
|
_(resource.Port).must_equal "22"
|
|
|
|
_(resource.UsePAM).must_equal "yes"
|
2017-06-11 10:16:10 +00:00
|
|
|
_(resource.ListenAddress).must_be_nil
|
2015-09-05 15:05:07 +00:00
|
|
|
_(resource.HostKey).must_equal [
|
2019-06-11 22:24:35 +00:00
|
|
|
"/etc/ssh/ssh_host_rsa_key",
|
|
|
|
"/etc/ssh/ssh_host_dsa_key",
|
|
|
|
"/etc/ssh/ssh_host_ecdsa_key",
|
2015-09-05 15:05:07 +00:00
|
|
|
]
|
|
|
|
end
|
2017-10-06 13:41:48 +00:00
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
it "check bad path" do
|
|
|
|
resource = load_resource("sshd_config", "/etc/ssh/sshd_config_does_not_exist")
|
2018-03-22 12:25:45 +00:00
|
|
|
_(resource.resource_exception_message).must_equal "Can't find file: /etc/ssh/sshd_config_does_not_exist"
|
2017-10-06 13:41:48 +00:00
|
|
|
end
|
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
it "check cannot read" do
|
|
|
|
resource = load_resource("sshd_config", "/etc/ssh/sshd_config_empty")
|
2018-03-22 12:25:45 +00:00
|
|
|
_(resource.resource_exception_message).must_equal "File is empty: /etc/ssh/sshd_config_empty"
|
2017-10-06 13:41:48 +00:00
|
|
|
end
|
2015-09-05 15:05:07 +00:00
|
|
|
end
|
|
|
|
end
|