Skip to content

mysql_grant: Output missmatching data during validation #1666

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/puppet/type/mysql_grant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ def initialize(*args)
raise(_('mysql_grant: `table` `parameter` is required.')) if self[:ensure] == :present && self[:table].nil?
raise(_('mysql_grant: `user` `parameter` is required.')) if self[:ensure] == :present && self[:user].nil?

raise(_('mysql_grant: `name` `parameter` must match user@host/table format.')) if self[:user] && self[:table] && (self[:name] != "#{self[:user]}/#{self[:table]}")
if self[:user] && self[:table] && (self[:name] != "#{self[:user]}/#{self[:table]}")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following spec tests are failing, can you please check on this

Failures:

  1) Facter::Util::Fact mysql_server_id igalic's laptop 
     Failure/Error: Facter.fact(:macaddress).stubs(:value).returns('3c:97:0e:69:fb:e1')
     
     Mocha::StubbingError:
       can't stub method on frozen object: nil
     # ./spec/unit/facter/mysql_server_id_spec.rb:11:in `block (4 levels) in <top (required)>'

  2) Facter::Util::Fact mysql_server_id node with lo only 
     Failure/Error: Facter.fact(:macaddress).stubs(:value).returns('00:00:00:00:00:00')
     
     Mocha::StubbingError:
       can't stub method on frozen object: nil
     # ./spec/unit/facter/mysql_server_id_spec.rb:20:in `block (4 levels) in <top (required)>'

  3) function_mysql_deepmerge when calling mysql_deepmerge from puppet should not compile when no arguments are passed
     Failure/Error:
       expect {
         scope.compiler.compile
       }.to raise_error(Puppet::ParseError, /wrong number of arguments/)
     
       expected Puppet::ParseError with message matching /wrong number of arguments/, got #<NoMethodError: undefined method `scope' for PuppetlabsSpec::PuppetInternals:Module
     
         let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
                                                      ^^^^^^> with backtrace:
         # ./spec/unit/puppet/functions/mysql_deepmerge_spec.rb:6:in `block (2 levels) in <top (required)>'
         # ./spec/unit/puppet/functions/mysql_deepmerge_spec.rb:13:in `block (4 levels) in <top (required)>'
         # ./spec/unit/puppet/functions/mysql_deepmerge_spec.rb:12:in `block (3 levels) in <top (required)>'
     # ./spec/unit/puppet/functions/mysql_deepmerge_spec.rb:12:in `block (3 levels) in <top (required)>'

  4) function_mysql_deepmerge when calling mysql_deepmerge from puppet should not compile when 1 argument is passed
     Failure/Error:
       expect {
         scope.compiler.compile
       }.to raise_error(Puppet::ParseError, /wrong number of arguments/)
     
       expected Puppet::ParseError with message matching /wrong number of arguments/, got #<NoMethodError: undefined method `scope' for PuppetlabsSpec::PuppetInternals:Module
     
         let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
                                                      ^^^^^^> with backtrace:
         # ./spec/unit/puppet/functions/mysql_deepmerge_spec.rb:6:in `block (2 levels) in <top (required)>'
         # ./spec/unit/puppet/functions/mysql_deepmerge_spec.rb:21:in `block (4 levels) in <top (required)>'
         # ./spec/unit/puppet/functions/mysql_deepmerge_spec.rb:20:in `block (3 levels) in <top (required)>'
     # ./spec/unit/puppet/functions/mysql_deepmerge_spec.rb:20:in `block (3 levels) in <top (required)>'

  5) function_mysql_deepmerge when calling mysql_deepmerge on the scope instance should require all parameters are hashes
     Failure/Error: expect { new_hash = scope.function_mysql_deepmerge([{}, '2'])}.to raise_error(Puppet::ParseError, /unexpected argument type String/)
     
       expected Puppet::ParseError with message matching /unexpected argument type String/, got #<NoMethodError: undefined method `scope' for PuppetlabsSpec::PuppetInternals:Module
     
         let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
                                                      ^^^^^^> with backtrace:
         # ./spec/unit/puppet/functions/mysql_deepmerge_spec.rb:6:in `block (2 levels) in <top (required)>'
         # ./spec/unit/puppet/functions/mysql_deepmerge_spec.rb:28:in `block (4 levels) in <top (required)>'
         # ./spec/unit/puppet/functions/mysql_deepmerge_spec.rb:28:in `block (3 levels) in <top (required)>'
     # ./spec/unit/puppet/functions/mysql_deepmerge_spec.rb:28:in `block (3 levels) in <top (required)>'

  6) function_mysql_deepmerge when calling mysql_deepmerge on the scope instance should accept empty strings as puppet undef
     Failure/Error: expect { new_hash = scope.function_mysql_deepmerge([{}, ''])}.not_to raise_error
     
       expected no Exception, got #<NoMethodError: undefined method `scope' for PuppetlabsSpec::PuppetInternals:Module
     
         let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
                                                      ^^^^^^> with backtrace:
         # ./spec/unit/puppet/functions/mysql_deepmerge_spec.rb:6:in `block (2 levels) in <top (required)>'
         # ./spec/unit/puppet/functions/mysql_deepmerge_spec.rb:33:in `block (4 levels) in <top (required)>'
         # ./spec/unit/puppet/functions/mysql_deepmerge_spec.rb:33:in `block (3 levels) in <top (required)>'
     # ./spec/unit/puppet/functions/mysql_deepmerge_spec.rb:33:in `block (3 levels) in <top (required)>'

  7) function_mysql_deepmerge when calling mysql_deepmerge on the scope instance should be able to mysql_deepmerge two hashes
     Failure/Error: let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
     
     NoMethodError:
       undefined method `scope' for PuppetlabsSpec::PuppetInternals:Module
     
         let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
                                                      ^^^^^^
     # ./spec/unit/puppet/functions/mysql_deepmerge_spec.rb:6:in `block (2 levels) in <top (required)>'
     # ./spec/unit/puppet/functions/mysql_deepmerge_spec.rb:37:in `block (3 levels) in <top (required)>'

  8) function_mysql_deepmerge when calling mysql_deepmerge on the scope instance should mysql_deepmerge multiple hashes
     Failure/Error: let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
     
     NoMethodError:
       undefined method `scope' for PuppetlabsSpec::PuppetInternals:Module
     
         let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
                                                      ^^^^^^
     # ./spec/unit/puppet/functions/mysql_deepmerge_spec.rb:6:in `block (2 levels) in <top (required)>'
     # ./spec/unit/puppet/functions/mysql_deepmerge_spec.rb:44:in `block (3 levels) in <top (required)>'

  9) function_mysql_deepmerge when calling mysql_deepmerge on the scope instance should accept empty hashes
     Failure/Error: let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
     
     NoMethodError:
       undefined method `scope' for PuppetlabsSpec::PuppetInternals:Module
     
         let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
                                                      ^^^^^^
     # ./spec/unit/puppet/functions/mysql_deepmerge_spec.rb:6:in `block (2 levels) in <top (required)>'
     # ./spec/unit/puppet/functions/mysql_deepmerge_spec.rb:49:in `block (3 levels) in <top (required)>'

  10) function_mysql_deepmerge when calling mysql_deepmerge on the scope instance should mysql_deepmerge subhashes
      Failure/Error: let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
      
      NoMethodError:
        undefined method `scope' for PuppetlabsSpec::PuppetInternals:Module
      
          let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
                                                       ^^^^^^
      # ./spec/unit/puppet/functions/mysql_deepmerge_spec.rb:6:in `block (2 levels) in <top (required)>'
      # ./spec/unit/puppet/functions/mysql_deepmerge_spec.rb:53:in `block (3 levels) in <top (required)>'

  11) function_mysql_deepmerge when calling mysql_deepmerge on the scope instance should append to subhashes
      Failure/Error: let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
      
      NoMethodError:
        undefined method `scope' for PuppetlabsSpec::PuppetInternals:Module
      
          let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
                                                       ^^^^^^
      # ./spec/unit/puppet/functions/mysql_deepmerge_spec.rb:6:in `block (2 levels) in <top (required)>'
      # ./spec/unit/puppet/functions/mysql_deepmerge_spec.rb:60:in `block (3 levels) in <top (required)>'

  12) function_mysql_deepmerge when calling mysql_deepmerge on the scope instance should append to subhashes 2
      Failure/Error: let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
      
      NoMethodError:
        undefined method `scope' for PuppetlabsSpec::PuppetInternals:Module
      
          let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
                                                       ^^^^^^
      # ./spec/unit/puppet/functions/mysql_deepmerge_spec.rb:6:in `block (2 levels) in <top (required)>'
      # ./spec/unit/puppet/functions/mysql_deepmerge_spec.rb:65:in `block (3 levels) in <top (required)>'

  13) function_mysql_deepmerge when calling mysql_deepmerge on the scope instance should append to subhashes 3
      Failure/Error: let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
      
      NoMethodError:
        undefined method `scope' for PuppetlabsSpec::PuppetInternals:Module
      
          let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
                                                       ^^^^^^
      # ./spec/unit/puppet/functions/mysql_deepmerge_spec.rb:6:in `block (2 levels) in <top (required)>'
      # ./spec/unit/puppet/functions/mysql_deepmerge_spec.rb:72:in `block (3 levels) in <top (required)>'

  14) function_mysql_deepmerge when calling mysql_deepmerge on the scope instance should equate keys mod dash and underscore
      Failure/Error: let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
      
      NoMethodError:
        undefined method `scope' for PuppetlabsSpec::PuppetInternals:Module
      
          let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
                                                       ^^^^^^
      # ./spec/unit/puppet/functions/mysql_deepmerge_spec.rb:6:in `block (2 levels) in <top (required)>'
      # ./spec/unit/puppet/functions/mysql_deepmerge_spec.rb:78:in `block (3 levels) in <top (required)>'

  15) function_mysql_deepmerge when calling mysql_deepmerge on the scope instance should keep style of the last when keys are euqal mod dash and underscore
      Failure/Error: let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
      
      NoMethodError:
        undefined method `scope' for PuppetlabsSpec::PuppetInternals:Module
      
          let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
                                                       ^^^^^^
      # ./spec/unit/puppet/functions/mysql_deepmerge_spec.rb:6:in `block (2 levels) in <top (required)>'
      # ./spec/unit/puppet/functions/mysql_deepmerge_spec.rb:84:in `block (3 levels) in <top (required)>'

  16) the mysql_password function should raise a ParseError if there is less than 1 arguments
      Failure/Error: expect { scope.function_mysql_password([]) }.to( raise_error(Puppet::ParseError))
      
        expected Puppet::ParseError, got #<NoMethodError: undefined method `scope' for PuppetlabsSpec::PuppetInternals:Module
      
          let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
                                                       ^^^^^^> with backtrace:
          # ./spec/unit/puppet/functions/mysql_password_spec.rb:8:in `block (2 levels) in <top (required)>'
          # ./spec/unit/puppet/functions/mysql_password_spec.rb:15:in `block (3 levels) in <top (required)>'
          # ./spec/unit/puppet/functions/mysql_password_spec.rb:15:in `block (2 levels) in <top (required)>'
      # ./spec/unit/puppet/functions/mysql_password_spec.rb:15:in `block (2 levels) in <top (required)>'

  17) the mysql_password function should raise a ParseError if there is more than 1 arguments
      Failure/Error: expect { scope.function_mysql_password(%w(foo bar)) }.to( raise_error(Puppet::ParseError))
      
        expected Puppet::ParseError, got #<NoMethodError: undefined method `scope' for PuppetlabsSpec::PuppetInternals:Module
      
          let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
                                                       ^^^^^^> with backtrace:
          # ./spec/unit/puppet/functions/mysql_password_spec.rb:8:in `block (2 levels) in <top (required)>'
          # ./spec/unit/puppet/functions/mysql_password_spec.rb:19:in `block (3 levels) in <top (required)>'
          # ./spec/unit/puppet/functions/mysql_password_spec.rb:19:in `block (2 levels) in <top (required)>'
      # ./spec/unit/puppet/functions/mysql_password_spec.rb:19:in `block (2 levels) in <top (required)>'

  18) the mysql_password function should convert password into a hash
      Failure/Error: let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
      
      NoMethodError:
        undefined method `scope' for PuppetlabsSpec::PuppetInternals:Module
      
          let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
                                                       ^^^^^^
      # ./spec/unit/puppet/functions/mysql_password_spec.rb:8:in `block (2 levels) in <top (required)>'
      # ./spec/unit/puppet/functions/mysql_password_spec.rb:23:in `block (2 levels) in <top (required)>'

  19) the mysql_password function should convert an empty password into a empty string
      Failure/Error: let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
      
      NoMethodError:
        undefined method `scope' for PuppetlabsSpec::PuppetInternals:Module
      
          let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
                                                       ^^^^^^
      # ./spec/unit/puppet/functions/mysql_password_spec.rb:8:in `block (2 levels) in <top (required)>'
      # ./spec/unit/puppet/functions/mysql_password_spec.rb:28:in `block (2 levels) in <top (required)>'

  20) the mysql_password function should not convert a password that is already a hash
      Failure/Error: let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
      
      NoMethodError:
        undefined method `scope' for PuppetlabsSpec::PuppetInternals:Module
      
          let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
                                                       ^^^^^^
      # ./spec/unit/puppet/functions/mysql_password_spec.rb:8:in `block (2 levels) in <top (required)>'
      # ./spec/unit/puppet/functions/mysql_password_spec.rb:33:in `block (2 levels) in <top (required)>'

Finished in 0.85942 seconds (files took 1.04 seconds to load)
117 examples, 20 failures

raise(_("mysql_grant: `name` `parameter` must match user@host/table format. Got `name` #{self[:name]}, and user/table #{self[:user]}/#{self[:table]}"))
end
end

newparam(:name, namevar: true) do
Expand Down
Loading