Merge pull request #5584 from inspec/nm/mssql-port-fix

Remove default port for mssql_session, allowing named connections
This commit is contained in:
Clinton Wolfe 2021-07-08 18:39:33 -05:00 committed by GitHub
commit f22c342704
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 9 deletions

View file

@ -42,11 +42,7 @@ module Inspec::Resources
@local_mode = opts[:local_mode]
unless local_mode?
@host = opts[:host] || "localhost"
if opts.key?(:port)
@port = opts[:port]
else
@port = "1433"
end
@port = opts[:port]
end
@instance = opts[:instance]
@db_name = opts[:db_name]

View file

@ -8,7 +8,6 @@ describe "Inspec::Resources::MssqlSession" do
_(resource.user).must_equal "sa"
_(resource.password).must_equal "yourStrong(!)Password"
_(resource.host).must_equal "localhost"
_(resource.port).must_equal "1433"
end
it "verify mssql_session configuration with custom hostname" do
@ -16,7 +15,6 @@ describe "Inspec::Resources::MssqlSession" do
_(resource.user).must_equal "sa"
_(resource.password).must_equal "yourStrong(!)Password"
_(resource.host).must_equal "inspec.domain.tld"
_(resource.port).must_equal "1433"
end
it "verify mssql_session configuration with custom instance" do
@ -24,7 +22,6 @@ describe "Inspec::Resources::MssqlSession" do
_(resource.user).must_equal "sa"
_(resource.password).must_equal "yourStrong(!)Password"
_(resource.host).must_equal "localhost"
_(resource.port).must_equal "1433"
_(resource.instance).must_equal "SQL2012INSPEC"
end
@ -63,7 +60,7 @@ describe "Inspec::Resources::MssqlSession" do
end
it "run a SQL query" do
resource = load_resource("mssql_session", user: "sa", password: "yourStrong(!)Password", host: "localhost")
resource = load_resource("mssql_session", user: "sa", password: "yourStrong(!)Password", host: "localhost", port: "1433")
query = resource.query("SELECT SERVERPROPERTY('ProductVersion') as result")
_(query.size).must_equal 1
_(query.row(0).column("result").value).must_equal "14.0.600.250"