Skip to content

Commit 76a235f

Browse files
authored
Merge pull request #393 from david22swan/MODULES-5472/main/sensitive_passwords
(MODULES-5472) Login values can now be passed as sensitive strings
2 parents 6898fcc + 6334ef2 commit 76a235f

File tree

5 files changed

+17
-14
lines changed

5 files changed

+17
-14
lines changed

manifests/config.pp

+4-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
# The instance name you want to manage. Defaults to the $title when not defined explicitly.
77
# @param admin_user
88
# Only required for SQL_LOGIN type. A user/login who has sysadmin rights on the server
9+
# Can be passed as a sensitive value
910
# @param admin_pass
1011
# Only required for SQL_LOGIN type. The password in order to access the server to be managed.
12+
# Can be passed as a sensitive value
1113
# @param admin_login_type
1214
# The type of account use to configure the server. Valid values are SQL_LOGIN and WINDOWS_LOGIN, with a default of SQL_LOGIN
1315
# The SQL_LOGIN requires the admin_user and admin_pass to be set
@@ -20,8 +22,8 @@
2022
# }
2123
#
2224
define sqlserver::config (
23-
Optional[String] $admin_user = '',
24-
Optional[String] $admin_pass = '',
25+
Optional[Variant[Sensitive[String], String]] $admin_user = '',
26+
Optional[Variant[Sensitive[String], String]] $admin_pass = '',
2527
Enum['SQL_LOGIN', 'WINDOWS_LOGIN'] $admin_login_type = 'SQL_LOGIN',
2628
String[1,16] $instance_name = $title,
2729
) {

manifests/login.pp

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#
1818
# @param password
1919
# Plain text password. Only applicable when Login_Type = 'SQL_LOGIN'.
20+
# Can be passed through as a sensitive value.
2021
#
2122
# @param svrroles
2223
# A hash of preinstalled server roles that you want assigned to this login.
@@ -55,7 +56,7 @@
5556
String[1,16] $instance = 'MSSQLSERVER',
5657
Enum['SQL_LOGIN', 'WINDOWS_LOGIN'] $login_type = 'SQL_LOGIN',
5758
Enum['present', 'absent'] $ensure = 'present',
58-
Optional[String] $password = undef,
59+
Optional[Variant[Sensitive[String], String]] $password = undef,
5960
Optional[Hash] $svrroles = { },
6061
String $default_database = 'master',
6162
String $default_language = 'us_english',

spec/acceptance/sqlserver_config_spec.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,14 @@ def ensure_sqlserver_instance(inst_name, ensure_val = 'present')
4848
pp = <<-MANIFEST
4949
sqlserver::config{'#{inst_name}':
5050
instance_name => '#{inst_name}',
51-
admin_user => 'sa',
51+
admin_user => Sensitive('sa'),
5252
admin_pass => 'Pupp3t1@',
5353
}
5454
sqlserver::login{'#{@admin_user}':
5555
instance => '#{inst_name}',
5656
login_type => 'SQL_LOGIN',
5757
login => '#{@admin_user}',
58-
password => '#{@admin_pass}',
58+
password => Sensitive('#{@admin_pass}'),
5959
svrroles => {'sysadmin' => 1},
6060
}
6161
MANIFEST
@@ -65,8 +65,8 @@ def ensure_sqlserver_instance(inst_name, ensure_val = 'present')
6565
it 'Validate New Config WITH using instance_name in sqlserver::config' do
6666
pp = <<-MANIFEST
6767
sqlserver::config{'#{inst_name}':
68-
admin_user => '#{@admin_user}',
69-
admin_pass => '#{@admin_pass}',
68+
admin_user => Sensitive('#{@admin_user}'),
69+
admin_pass => Sensitive('#{@admin_pass}'),
7070
instance_name => '#{inst_name}',
7171
}
7272
sqlserver::database{'#{db_name}':

spec/acceptance/sqlserver_database_spec.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ def run_sql_query_opts(query, expected_row_count)
2424
# delete created database:
2525
pp = <<-MANIFEST
2626
sqlserver::config{'MSSQLSERVER':
27-
admin_user => 'sa',
28-
admin_pass => 'Pupp3t1@',
27+
admin_user => Sensitive('sa'),
28+
admin_pass => Sensitive('Pupp3t1@'),
2929
}
3030
sqlserver::database{'#{@db_name}':
3131
ensure => 'absent',
@@ -40,8 +40,8 @@ def run_sql_query_opts(query, expected_row_count)
4040
it 'Test Case C89019: Create a database' do
4141
pp = <<-MANIFEST
4242
sqlserver::config{'MSSQLSERVER':
43-
admin_user => 'sa',
44-
admin_pass => 'Pupp3t1@',
43+
admin_user => Sensitive('sa'),
44+
admin_pass => Sensitive('Pupp3t1@'),
4545
}
4646
sqlserver::database{'#{@db_name}':
4747
}

spec/acceptance/sqlserver_login_spec.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ def create_login_manifest(testcase, login_name, login_password, options = {})
8989
# Create a database, a simple table and windows accounts fixtures
9090
pp = <<-MANIFEST
9191
sqlserver::config{'MSSQLSERVER':
92-
admin_user => 'sa',
93-
admin_pass => 'Pupp3t1@',
92+
admin_user => Sensitive('sa'),
93+
admin_pass => Sensitive('Pupp3t1@'),
9494
}
9595
sqlserver::database{'#{db_name}':
9696
}
@@ -102,7 +102,7 @@ def create_login_manifest(testcase, login_name, login_password, options = {})
102102
}
103103
104104
user {'#{@windows_user}':
105-
password => '#{@login_passwd}',
105+
password => Sensitive('#{@login_passwd}'),
106106
ensure => 'present',
107107
}
108108
group {'#{@windows_group}':

0 commit comments

Comments
 (0)