diff --git a/lib/puppet/provider/elasticsearch_license/ruby.rb b/lib/puppet/provider/elasticsearch_license/ruby.rb index 27f1fdb..d7dda2c 100644 --- a/lib/puppet/provider/elasticsearch_license/ruby.rb +++ b/lib/puppet/provider/elasticsearch_license/ruby.rb @@ -1,33 +1,31 @@ -# rubocop:disable Style/FileName -# rubocop:enable Style/FileName require 'puppet/provider/elastic_rest' Puppet::Type.type(:elasticsearch_license).provide( :xpack, :api_resource_style => :bare, :parent => Puppet::Provider::ElasticREST, :metadata => :content, :metadata_pipeline => [ lambda { |data| Puppet_X::Elastic.deep_to_s data }, lambda { |data| Puppet_X::Elastic.deep_to_i data } ], :api_uri => '_xpack/license', :query_string => { 'acknowledge' => 'true' } ) do desc 'A REST API based provider to manage Elasticsearch X-Pack licenses.' mk_resource_methods def self.process_body(body) JSON.parse(body).map do |_object_name, api_object| { :name => name.to_s, :ensure => :present, metadata => { 'license' => process_metadata(api_object) }, :provider => name } end end end diff --git a/spec/classes/006_elasticsearch_license_spec.rb b/spec/classes/006_elasticsearch_license_spec.rb index c5df878..0c2579d 100644 --- a/spec/classes/006_elasticsearch_license_spec.rb +++ b/spec/classes/006_elasticsearch_license_spec.rb @@ -1,85 +1,85 @@ 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 should contain_class('elasticsearch::license') end it do should contain_es_instance_conn_validator( 'license-conn-validator' - ).that_comes_before("elasticsearch_license[xpack]") + ).that_comes_before('elasticsearch_license[xpack]') end it do should 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 diff --git a/spec/unit/provider/elasticsearch_license/x-pack_spec.rb b/spec/unit/provider/elasticsearch_license/ruby_spec.rb similarity index 100% rename from spec/unit/provider/elasticsearch_license/x-pack_spec.rb rename to spec/unit/provider/elasticsearch_license/ruby_spec.rb