elasticsearch-api 8.5.0 → 8.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a93e7def7192582d7c79489a2ad2953b23d41fa75c49f81e93ad717d951e6d2a
4
- data.tar.gz: 8ecf595ae67b718028e6da5792b708a1439dc5e0522dab7d4da3f4b251541d83
3
+ metadata.gz: 83bd8be41d9f67d39e9cdb030e2ea2286c08bc4fbcdcf23db15a85a533e4f954
4
+ data.tar.gz: d4185c7fca5cb11fce5da43e36ebc44ab27086eb4c62a26541baa5414478fed0
5
5
  SHA512:
6
- metadata.gz: b6bb3945019969e536124a24ecee54e3eea42b1a6b7bfd24e3d49fb9f8fa8b58753224361e24560802eef8713fefb565553d9959e171898d8c9f737eb3b0941f
7
- data.tar.gz: 361a85f3cba1eaa248947475a53531070916567669365306feaaee88274c8c52d49c21f36b91a28447837a6dfd1a20c1bad55af08e493533ff07baa02cd17269
6
+ metadata.gz: 4dda71b331ae5d4b5aa01a4871cb0495961117332a7f72c8dc96143922402fbaef942c921f950ff373ca5e2a82e2a8ad2a86dc6a27db49ee10be73982ce1cc0a
7
+ data.tar.gz: 3c72b61e3baaacee6abffc54b50da5c0bcda47e3ffd1669f9c0623343294b1025f63de6f13b815a73ccf30a842098b80f9756b2efd0c96ba5fc090f920cd800d
@@ -42,6 +42,14 @@ end
42
42
  # Validate that a field is `true`.
43
43
  RSpec::Matchers.define :match_true_field do |field, test|
44
44
  match do |response|
45
+ # TODO: Refactor! split_key for is_true
46
+ if (match = field.match(/(^\$[a-z]+)/))
47
+ keys = field.split('.')
48
+ keys.delete(match[1])
49
+ dynamic_key = test.cached_values[match[1].gsub('$', '')]
50
+ return !!dynamic_key.dig(*keys)
51
+ end
52
+
45
53
  # Handle is_true: ''
46
54
  return !!response if field == ''
47
55
 
@@ -190,10 +198,24 @@ RSpec::Matchers.define :match_response do |pairs, test|
190
198
 
191
199
  def compare_hash(expected_pairs, actual_hash, test)
192
200
  expected_pairs.each do |expected_key, expected_value|
193
- # Find the value to compare in the response
194
- split_key = TestFile::Test.split_and_parse_key(expected_key).collect do |k|
195
- # Sometimes the expected *key* is a cached value from a previous request.
196
- test.get_cached_value(k)
201
+ # TODO: Refactor! split_key
202
+ if (match = expected_key.match(/(^\$[a-z]+)/))
203
+ keys = expected_key.split('.')
204
+ keys.delete(match[1])
205
+ dynamic_key = test.cached_values[match[1].gsub('$', '')]
206
+ value = dynamic_key.dig(*keys)
207
+
208
+ if expected_pairs.values.first.is_a?(String) && expected_pairs.values.first.match?(/^\$/)
209
+ return test.cached_values[expected_pairs.values.first.gsub('$','')] == value
210
+ else
211
+ return expected_pairs.values.first == value
212
+ end
213
+
214
+ else
215
+ split_key = TestFile::Test.split_and_parse_key(expected_key).collect do |k|
216
+ # Sometimes the expected *key* is a cached value from a previous request.
217
+ test.get_cached_value(k)
218
+ end
197
219
  end
198
220
  # We now accept 'nested.keys' so let's try the previous implementation and if that doesn't
199
221
  # work, try with the nested key, otherwise, raise exception.
@@ -122,6 +122,12 @@ module Elasticsearch
122
122
  @response = client.send(_method, prepare_arguments(args, test))
123
123
  end
124
124
  client
125
+ when 'update_user_profile_data', 'get_user_profile', 'enable_user_profile', 'disable_user_profile'
126
+ args.each do |key, value|
127
+ args[key] = value.gsub(value, test.cached_values[value.gsub('$', '')]) if value.match?(/^\$/)
128
+ end
129
+ @response = client.send(_method, prepare_arguments(args, test))
130
+ client
125
131
  else
126
132
  @response = client.send(_method, prepare_arguments(args, test))
127
133
  client
@@ -47,7 +47,7 @@ module Elasticsearch
47
47
 
48
48
  _name = arguments.delete(:name)
49
49
 
50
- method = Elasticsearch::API::HTTP_PUT
50
+ method = _name ? Elasticsearch::API::HTTP_PUT : Elasticsearch::API::HTTP_POST
51
51
  path = if _namespace && _service && _name
52
52
  "_security/service/#{Utils.__listify(_namespace)}/#{Utils.__listify(_service)}/credential/token/#{Utils.__listify(_name)}"
53
53
  else
@@ -17,6 +17,6 @@
17
17
 
18
18
  module Elasticsearch
19
19
  module API
20
- VERSION = '8.5.0'.freeze
20
+ VERSION = '8.5.2'.freeze
21
21
  end
22
22
  end
@@ -18,16 +18,31 @@
18
18
  require 'spec_helper'
19
19
 
20
20
  describe 'client#security#create_service_token' do
21
+ let(:expected_path) { '_security/service/foo/bar/credential/token' }
22
+ let(:expected_request_method) { 'POST' }
21
23
  let(:expected_args) do
22
24
  [
23
- 'PUT',
24
- '_security/service/foo/bar/credential/token',
25
+ expected_request_method,
26
+ expected_path,
25
27
  {},
26
28
  nil,
27
29
  {}
28
30
  ]
29
31
  end
30
32
 
33
+ context 'with token name' do
34
+ let(:expected_request_method) { 'PUT' }
35
+ let(:token_name) { 'test-token' }
36
+ let(:expected_path) { "#{super()}/#{token_name}" }
37
+ it 'performs the request' do
38
+ expect(
39
+ client_double.security.create_service_token(
40
+ namespace: 'foo', service: 'bar', name: token_name
41
+ )
42
+ ).to be_a Elasticsearch::API::Response
43
+ end
44
+ end
45
+
31
46
  it 'performs the request' do
32
47
  expect(
33
48
  client_double.security.create_service_token(
@@ -171,6 +171,7 @@ module Elasticsearch
171
171
 
172
172
  def __http_method
173
173
  return '_id ? Elasticsearch::API::HTTP_PUT : Elasticsearch::API::HTTP_POST' if @endpoint_name == 'index'
174
+ return '_name ? Elasticsearch::API::HTTP_PUT : Elasticsearch::API::HTTP_POST' if @method_name == 'create_service_token'
174
175
  return post_and_get if @endpoint_name == 'count'
175
176
 
176
177
  default_method = @spec['url']['paths'].map { |a| a['methods'] }.flatten.first
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elasticsearch-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.5.0
4
+ version: 8.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karel Minarik
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-01 00:00:00.000000000 Z
11
+ date: 2022-11-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json