File: 006_elasticsearch_license_spec.rb

package info (click to toggle)
puppet-module-voxpupuli-elasticsearch 9.0.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,496 kB
  • sloc: ruby: 9,906; sh: 392; makefile: 4
file content (89 lines) | stat: -rw-r--r-- 2,863 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# frozen_string_literal: true

require 'spec_helper'

describe 'elasticsearch::license', type: 'class' do
  # First, randomly select one of our supported OSes to run tests that apply
  # to any distro
  on_supported_os.to_a.sample(1).to_h.each do |os, facts|
    context "on #{os}" do
      let(:facts) do
        facts.merge('scenario' => '', 'common' => '')
      end

      context 'when managing x-pack license' do
        let(:params) do
          {
            content: {
              'license' => {
                'uid' => 'cbff45e7-c553-41f7-ae4f-9205eabd80xx',
                'type' => 'trial',
                'issue_date_in_millis' => 1_519_341_125_550,
                'expiry_date_in_millis' => 1_521_933_125_550,
                'max_nodes' => 1000,
                'issued_to' => 'test',
                'issuer' => 'elasticsearch',
                'signature' => 'secretvalue',
                'start_date_in_millis' => 1_513_814_400_000
              }
            }
          }
        end

        let(:pre_condition) do
          <<-EOS
            class { 'elasticsearch' :
              api_protocol            => 'https',
              api_host                => '127.0.0.1',
              api_port                => 9201,
              api_timeout             => 11,
              api_basic_auth_username => 'elastic',
              api_basic_auth_password => 'password',
              api_ca_file             => '/foo/bar.pem',
              api_ca_path             => '/foo/',
              validate_tls            => false,
            }
          EOS
        end

        it do
          expect(subject).to contain_class('elasticsearch::license')
        end

        it do
          expect(subject).to contain_es_instance_conn_validator(
            'license-conn-validator'
          ).that_comes_before('elasticsearch_license[xpack]')
        end

        it do
          expect(subject).to contain_elasticsearch_license('xpack').with(
            ensure: 'present',
            content: {
              'license' => {
                'uid' => 'cbff45e7-c553-41f7-ae4f-9205eabd80xx',
                'type' => 'trial',
                'issue_date_in_millis' => 1_519_341_125_550,
                'expiry_date_in_millis' => 1_521_933_125_550,
                'max_nodes' => 1000,
                'issued_to' => 'test',
                'issuer' => 'elasticsearch',
                'signature' => 'secretvalue',
                'start_date_in_millis' => 1_513_814_400_000
              }
            },
            protocol: 'https',
            host: '127.0.0.1',
            port: 9201,
            timeout: 11,
            username: 'elastic',
            password: 'password',
            ca_file: '/foo/bar.pem',
            ca_path: '/foo/',
            validate_tls: false
          )
        end
      end
    end
  end
end