<commit_before>require 'spec_helper_acceptance'

describe 'openldap::server::database' do

  it 'creates a database' do
    tmpdir = default.tmpdir('openldap')
    pp = <<-EOS
      class { 'openldap::server': }
      openldap::server::database { 'dc=foo,dc=com':
        directory => '#{tmpdir}',
      }
    EOS

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

  it 'can connect with ldapsearch' do
    pending 'Database need initialization?'
    ldapsearch('-LLL -x -b dc=foo,dc=com') do |r|
      expect(r.stdout).to match(/dn: dc=foo,dc=com/)
    end
  end

  it 'removes a database' do
    pp = <<-EOS
      class { 'openldap::server': }
      openldap::server::database { 'dc=foo,dc=com':
        ensure    => absent,
      }
    EOS

    apply_manifest(pp, :expect_changes => true)
    apply_manifest(pp, :catch_changes => true)
  end

end
<commit_msg>Update acceptance tests<commit_after>require 'spec_helper_acceptance'

describe 'openldap::server::database' do
  before :all do
    pp = <<-EOS
      class { 'openldap::server': }
      openldap::server::database { 'dc=foo,dc=com':
        ensure => absent,
      }
    EOS

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

  after :all do
    pp = <<-EOS
      class { 'openldap::server': }
      openldap::server::database { ['dc=foo,dc=com', 'dc=bar,dc=com']:
        ensure => absent,
      }
    EOS

    apply_manifest(pp, :expect_changes => true)
    apply_manifest(pp, :catch_changes => true)
  end

  context 'without parameters' do
    it 'creates a database' do
      pp = <<-EOS
      class { 'openldap::server': }
      openldap::server::database { 'dc=foo,dc=com': }
      EOS

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

    it 'can connect with ldapsearch' do
      ldapsearch('-LLL -x -b dc=foo,dc=com') do |r|
        expect(r.stdout).to match(/dn: dc=foo,dc=com/)
      end
    end
  end

  context 'with a directory' do
    it 'creates a database' do
      tmpdir = default.tmpdir('openldap')
      pp = <<-EOS
      class { 'openldap::server': }
      openldap::server::database { 'dc=bar,dc=com':
        directory => '#{tmpdir}',
      }
      EOS

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

    it 'can connect with ldapsearch' do
      ldapsearch('-LLL -x -b dc=foo,dc=com') do |r|
        expect(r.stdout).to match(/dn: dc=foo,dc=com/)
      end
    end
  end

end

{'fraction_non_alphanumeric': 0.1437403400309119, 'fraction_numerical': 0.0, 'mean_word_length': 2.7685589519650655, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 20, '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': '5599777', 'n_tokens_mistral': 925, 'n_tokens_neox': 898, 'n_words': 205}