From 46328b48125472f97e0d2346fe9b4cd225ab2a17 Mon Sep 17 00:00:00 2001 From: Nikita Mathur Date: Wed, 30 Jun 2021 17:19:18 +0530 Subject: [PATCH] Removed default port option to enable using named instances with no port option Signed-off-by: Nikita Mathur --- lib/inspec/resources/mssql_session.rb | 6 +----- test/unit/resources/mssql_session_test.rb | 5 +---- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/lib/inspec/resources/mssql_session.rb b/lib/inspec/resources/mssql_session.rb index 14abf4e86..d5fe502d7 100644 --- a/lib/inspec/resources/mssql_session.rb +++ b/lib/inspec/resources/mssql_session.rb @@ -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] diff --git a/test/unit/resources/mssql_session_test.rb b/test/unit/resources/mssql_session_test.rb index f3e0d1d16..9059184ab 100644 --- a/test/unit/resources/mssql_session_test.rb +++ b/test/unit/resources/mssql_session_test.rb @@ -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"