File tree 2 files changed +24
-8
lines changed
lib/elasticsearch/api/actions/security
spec/elasticsearch/api/actions/security
2 files changed +24
-8
lines changed Original file line number Diff line number Diff line change @@ -47,12 +47,13 @@ def create_service_token(arguments = {})
47
47
48
48
_name = arguments . delete ( :name )
49
49
50
- method = Elasticsearch ::API ::HTTP_PUT
51
- path = if _namespace && _service && _name
52
- "_security/service/#{ Utils . __listify ( _namespace ) } /#{ Utils . __listify ( _service ) } /credential/token/#{ Utils . __listify ( _name ) } "
53
- else
54
- "_security/service/#{ Utils . __listify ( _namespace ) } /#{ Utils . __listify ( _service ) } /credential/token"
55
- end
50
+ if _namespace && _service && _name
51
+ method = Elasticsearch ::API ::HTTP_PUT
52
+ path = "_security/service/#{ Utils . __listify ( _namespace ) } /#{ Utils . __listify ( _service ) } /credential/token/#{ Utils . __listify ( _name ) } "
53
+ else
54
+ method = Elasticsearch ::API ::HTTP_POST
55
+ path = "_security/service/#{ Utils . __listify ( _namespace ) } /#{ Utils . __listify ( _service ) } /credential/token"
56
+ end
56
57
params = Utils . process_params ( arguments )
57
58
58
59
Elasticsearch ::API ::Response . new (
Original file line number Diff line number Diff line change 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 (
You can’t perform that action at this time.
0 commit comments