<commit_before>require 'spec_helper_acceptance'
require 'spec_helper_faraday'
require 'json'

describe 'elasticsearch x-pack security', :with_certificates, :then_purge do

  # Template manifest
  let :base_manifest do <<-EOF
    class { 'elasticsearch' :
      java_install => true,
      manage_repo  => true,
      repo_version => '#{test_settings['repo_version5x']}',
      config => {
        'cluster.name' => '#{test_settings['cluster_name']}',
        'http.port' => #{test_settings['port_a']},
      },
      restart_on_change => true,
      security_plugin => 'x-pack',
    }

    elasticsearch::plugin { 'x-pack' :  }
    EOF
  end

  describe 'user authentication' do

    describe 'single instance manifest' do

      let :single_manifest do
        base_manifest + <<-EOF
          elasticsearch::instance { ['es-01'] :  }

          Elasticsearch::Plugin { instances => ['es-01'],  }

          elasticsearch::user { '#{test_settings['security_user']}':
            password => '#{<PASSWORD>_settings['security_password']}',
            roles    => ['superuser'],<commit_msg>testing: fix 5.x x-pack network bind host tests<commit_after>require 'spec_helper_acceptance'
require 'spec_helper_faraday'
require 'json'

describe 'elasticsearch x-pack security', :with_certificates, :then_purge do

  # Template manifest
  let :base_manifest do <<-EOF
    class { 'elasticsearch' :
      java_install => true,
      manage_repo  => true,
      repo_version => '#{test_settings['repo_version5x']}',
      config => {
        'cluster.name' => '#{test_settings['cluster_name']}',
        'http.port' => #{test_settings['port_a']},
        'network.host' => '0.0.0.0',
      },
      restart_on_change => true,
      security_plugin => 'x-pack',
    }

    elasticsearch::plugin { 'x-pack' :  }
    EOF
  end

  describe 'user authentication' do

    describe 'single instance manifest' do

      let :single_manifest do
        base_manifest + <<-EOF
          elasticsearch::instance { ['es-01'] :  }

          Elasticsearch::Plugin { instances => ['es-01'],  }

          elasticsearch::user { '#{test_settings['security_user']}':
            password => '#{test_settings['security_password']}',
            roles    => ['superuser'],
{'fraction_non_alphanumeric': 0.14712438698172092, 'fraction_numerical': 0.006687472135532769, 'mean_word_length': 2.9857904085257547, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, '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': '3942810', 'n_tokens_mistral': 688, 'n_tokens_neox': 672, 'n_words': 138}