Skip to content

Commit 7824ff4

Browse files
Dylan RatcliffeRandomNoun7
Dylan Ratcliffe
authored andcommitted
(MODULES-8685) Fixed erb Template For Login Test
The login_exists.sql erb template generates a dynamic sql statement that has a syntax error. The template completes without error, but when run against the server the syntax error that results in the T-SQL statement causes the defined type to believe that a login exists even if it does not. This change fixes the syntax error so that the sql statement runs as expected. It also adds an acceptance test to ensure regressions are not introduced.
1 parent 38a4ee0 commit 7824ff4

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
99
### Fixed
1010

1111
- Cannot manage a role with the same name on two instances or two databases ([MODULES-8677](https://tickets.puppetlabs.com/browse/MODULES-8677)) (Thanks [Dylan Ratcliffe](https://github.com/dylanratcliffe))
12+
- Removing a SQL Login via `ensure => absent` in a sqlserver::login resource is not idempotent. ([MODULES-8685](https://tickets.puppetlabs.com/browse/MODULES-8685)) (Thanks [Dylan Ratcliffe](https://github.com/dylanratcliffe))
1213

1314
## [2.3.0] - 2019-01-22
1415

spec/acceptance/sqlserver_login_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,12 @@ def create_login_manifest (testcase,login_name,login_password,options = {})
352352
ensure_manifest_execute(pp)
353353
end
354354

355+
it "remove a #{testcase} should be idempotent", :tier_low => true do
356+
options = { 'ensure' => 'absent' }
357+
pp = create_login_manifest(testcase,@login_under_test,@login_passwd,options)
358+
execute_manifest(pp, :catch_changes => true)
359+
end
360+
355361
it "should not exist in the principals table after deletion", :tier_low => true do
356362
query = "SELECT principal_id FROM SYS.server_principals WHERE name = '#{@login_under_test}' AND [type] = '#{@sql_principal_type}'";
357363
run_sql_query(host, run_sql_query_opts_as_sa(query, expected_row_count = 0))

templates/query/login_exists.sql.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,6 @@ END
6161
THROW 51000, 'ERROR: a role is not correct for <%= role %>', 10
6262
<% end %>
6363

64-
<% end %>
6564
END
65+
<% end %>
6666

0 commit comments

Comments
 (0)