From eec6f10ca7d4bf9ed3ef770245f819110124e222 Mon Sep 17 00:00:00 2001 From: cruelsmith <92088441+cruelsmith@users.noreply.github.com> Date: Wed, 10 May 2023 16:14:25 +0200 Subject: [PATCH 1/2] Fix broken sensitive parameter for mysql::password Revert broken change of #1557 and fixes the spec test for it by removing the skip. --- lib/puppet/functions/mysql/password.rb | 2 +- lib/puppet/functions/mysql_password.rb | 2 +- spec/functions/mysql_password_spec.rb | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/puppet/functions/mysql/password.rb b/lib/puppet/functions/mysql/password.rb index 98012c35a..5fb5941d3 100644 --- a/lib/puppet/functions/mysql/password.rb +++ b/lib/puppet/functions/mysql/password.rb @@ -19,7 +19,7 @@ return_type 'Variant[String, Sensitive[String]]' end - def password(password, sensitive: false) + def password(password, sensitive = false) password = password.unwrap if password.is_a?(Puppet::Pops::Types::PSensitiveType::Sensitive) result_string = if %r{\*[A-F0-9]{40}$}.match?(password) diff --git a/lib/puppet/functions/mysql_password.rb b/lib/puppet/functions/mysql_password.rb index 987b7e3fe..cf14f07fa 100644 --- a/lib/puppet/functions/mysql_password.rb +++ b/lib/puppet/functions/mysql_password.rb @@ -15,7 +15,7 @@ return_type 'Variant[String, Sensitive[String]]' end - def mysql_password(password, sensitive: false) + def mysql_password(password, sensitive = false) call_function('deprecation', 'mysql_password', "This method has been deprecated, please use the namespaced version 'mysql::password' instead.") call_function('mysql::password', password, sensitive) end diff --git a/spec/functions/mysql_password_spec.rb b/spec/functions/mysql_password_spec.rb index 9ec5bc9f8..993930469 100644 --- a/spec/functions/mysql_password_spec.rb +++ b/spec/functions/mysql_password_spec.rb @@ -25,7 +25,6 @@ # Test of a Returnvalue of Datatype Sensitive does not work it 'returns Sensitive with sensitive=true' do - skip 'should have a Returnvalue of Datatype Sensitive' expect(subject).to run.with_params('password', true).and_return(sensitive('*2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19')) end From 3f54b577fa32c2c975666562a6f6865217af2c9c Mon Sep 17 00:00:00 2001 From: cruelsmith <92088441+cruelsmith@users.noreply.github.com> Date: Wed, 10 May 2023 16:38:39 +0200 Subject: [PATCH 2/2] Add RuboCop ignore rule in mysql::password Keyword arguments are not posible for puppet functions on that place. --- lib/puppet/functions/mysql/password.rb | 2 +- lib/puppet/functions/mysql_password.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/puppet/functions/mysql/password.rb b/lib/puppet/functions/mysql/password.rb index 5fb5941d3..ab541219f 100644 --- a/lib/puppet/functions/mysql/password.rb +++ b/lib/puppet/functions/mysql/password.rb @@ -19,7 +19,7 @@ return_type 'Variant[String, Sensitive[String]]' end - def password(password, sensitive = false) + def password(password, sensitive = false) # rubocop:disable Style/OptionalBooleanParameter password = password.unwrap if password.is_a?(Puppet::Pops::Types::PSensitiveType::Sensitive) result_string = if %r{\*[A-F0-9]{40}$}.match?(password) diff --git a/lib/puppet/functions/mysql_password.rb b/lib/puppet/functions/mysql_password.rb index cf14f07fa..35d7af2b0 100644 --- a/lib/puppet/functions/mysql_password.rb +++ b/lib/puppet/functions/mysql_password.rb @@ -15,7 +15,7 @@ return_type 'Variant[String, Sensitive[String]]' end - def mysql_password(password, sensitive = false) + def mysql_password(password, sensitive = false) # rubocop:disable Style/OptionalBooleanParameter call_function('deprecation', 'mysql_password', "This method has been deprecated, please use the namespaced version 'mysql::password' instead.") call_function('mysql::password', password, sensitive) end