<commit_before>require 'spec_helper_acceptance'

describe 'mysql_user' do
  describe 'setup' do
    it 'should work with no errors' do
      pp = <<-EOS
        class { 'mysql::server': }
      EOS

      apply_manifest(pp, :catch_failures => true)
    end
  end

  context 'using ashp@localhost' do
    describe 'adding user' do
      it 'should work without errors' do
        pp = <<-EOS
          mysql_user { 'ashp@localhost':
            password_hash => '<PASSWORD>',
          }
        EOS

        apply_manifest(pp, :catch_failures => true)
      end

      it 'should find the user' do
        shell("mysql -NBe \"select '1' from mysql.user where CONCAT(user, '@', host) = 'ashp@localhost'\"") do |r|
          expect(r.stdout).to match(/^1$/)
          expect(r.stderr).to be_empty
        end
      end
    end
  end

  context 'using ashp@LocalHost' do
    describe 'adding user' do
      it 'should work without errors' do
        pp = <<-EOS
          mysql_user { 'ashp@LocalHost':
            password_hash => '<PASSWORD>',
          }
        EOS

        apply_manifest(pp, :catch_failures => true)
      end

      it 'should find the user' do
        shell("mysql -NBe \"select '1' from mysql.user where CONCAT(user, '@', host) = 'ashp@localhost'\"") do |r|
          expect(r.stdout).to match(/^1$/)
          expect(r.stderr).to be_empty
        end
      end
    end
  end
end<commit_msg>MODULES-1520 add test to assert it does not break<commit_after>require 'spec_helper_acceptance'

describe 'mysql_user' do
  describe 'setup' do
    it 'should work with no errors' do
      pp = <<-EOS
        class { 'mysql::server': }
      EOS

      apply_manifest(pp, :catch_failures => true)
    end
  end

  context 'using ashp@localhost' do
    describe 'adding user' do
      it 'should work without errors' do
        pp = <<-EOS
          mysql_user { 'ashp@localhost':
            password_hash => '<PASSWORD>',
          }
        EOS

        apply_manifest(pp, :catch_failures => true)
      end

      it 'should find the user' do
        shell("mysql -NBe \"select '1' from mysql.user where CONCAT(user, '@', host) = 'ashp@localhost'\"") do |r|
          expect(r.stdout).to match(/^1$/)
          expect(r.stderr).to be_empty
        end
      end
    end
  end

  context 'using ashp@LocalHost' do
    describe 'adding user' do
      it 'should work without errors' do
        pp = <<-EOS
          mysql_user { 'ashp@LocalHost':
            password_hash => '<PASSWORD>',
          }
        EOS

        apply_manifest(pp, :catch_failures => true)
      end

      it 'should find the user' do
        shell("mysql -NBe \"select '1' from mysql.user where CONCAT(user, '@', host) = 'ashp@localhost'\"") do |r|
          expect(r.stdout).to match(/^1$/)
          expect(r.stderr).to be_empty
        end
      end
    end
  end
  context 'using resource should throw no errors' do
    describe 'find users' do
      it {
        on default, puppet('resource mysql_user'), {:catch_failures => true} do |r|
          expect(r.stdout).to_not match(/Error:/)
          expect(r.stdout).to_not match(/must be properly quoted, invalid character:/)
        end
      }
    end
  end
end
{'fraction_non_alphanumeric': 0.11799501867995019, 'fraction_numerical': 0.0037359900373599006, 'mean_word_length': 2.0483870967741935, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4139694', 'n_tokens_mistral': 1021, 'n_tokens_neox': 995, 'n_words': 296}