elastic-enterprise-search 7.12.1 → 7.13.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ci/jobs/elastic+enterprise-search-ruby+7.10.0.beta.1.yml +12 -0
- data/.ci/test-matrix.yml +1 -1
- data/docs/guide/connecting.asciidoc +47 -1
- data/docs/guide/release_notes/712.asciidoc +0 -22
- data/docs/guide/workplace-search-api.asciidoc +19 -2
- data/elastic-enterprise-search.gemspec +1 -1
- data/lib/elastic/enterprise-search/api/put_read_only.rb +2 -0
- data/lib/elastic/enterprise-search/client.rb +0 -12
- data/lib/elastic/enterprise-search/request.rb +4 -0
- data/lib/elastic/enterprise-search/version.rb +1 -1
- data/lib/elastic/enterprise_search.rb +11 -0
- data/lib/elastic/workplace-search/api/content_source.rb +49 -0
- data/lib/elastic/workplace-search/api/create_analytics_event.rb +2 -2
- data/lib/elastic/workplace-search/api/create_content_source.rb +52 -0
- data/lib/elastic/workplace-search/api/create_external_identity.rb +2 -0
- data/lib/elastic/workplace-search/api/delete_all_documents.rb +49 -0
- data/lib/elastic/workplace-search/api/delete_content_source.rb +49 -0
- data/lib/elastic/workplace-search/api/delete_documents.rb +1 -1
- data/lib/elastic/workplace-search/api/document.rb +53 -0
- data/lib/elastic/workplace-search/api/list_content_sources.rb +48 -0
- data/lib/elastic/workplace-search/api/put_content_source.rb +55 -0
- data/lib/elastic/workplace-search/api/put_external_identity.rb +2 -0
- data/lib/elastic/workplace-search/workplace_search.rb +6 -1
- data/spec/integration/enterprise_search_api_spec.rb +4 -0
- data/spec/integration/workplace_search_spec.rb +253 -0
- metadata +18 -32
- data/.ci/jobs/elastic+enterprise-search-ruby+7.11.yml +0 -12
- data/spec/fixtures/vcr/workplace_search/add_user_permissions.yml +0 -53
- data/spec/fixtures/vcr/workplace_search/clear_user_permissions.yml +0 -53
- data/spec/fixtures/vcr/workplace_search/create_external_identity.yml +0 -53
- data/spec/fixtures/vcr/workplace_search/delete_documents.yml +0 -53
- data/spec/fixtures/vcr/workplace_search/delete_external_identity.yml +0 -53
- data/spec/fixtures/vcr/workplace_search/index_documents.yml +0 -55
- data/spec/fixtures/vcr/workplace_search/list_external_identities.yml +0 -53
- data/spec/fixtures/vcr/workplace_search/list_permissions.yml +0 -53
- data/spec/fixtures/vcr/workplace_search/put_external_identity.yml +0 -53
- data/spec/fixtures/vcr/workplace_search/put_user_permissions.yml +0 -103
- data/spec/fixtures/vcr/workplace_search/remove_user_permissions.yml +0 -53
- data/spec/fixtures/vcr/workplace_search/retrieve_external_identity.yml +0 -53
- data/spec/fixtures/vcr/workplace_search/user_permissions_empty.yml +0 -53
- data/spec/workplace-search/documents_spec.rb +0 -80
- data/spec/workplace-search/external_identities_spec.rb +0 -84
- data/spec/workplace-search/permissions_spec.rb +0 -136
@@ -29,7 +29,7 @@ module Elastic
|
|
29
29
|
# @option arguments [Array] :document_ids
|
30
30
|
# @option arguments [Hash] :headers optional HTTP headers to send with the request
|
31
31
|
#
|
32
|
-
# @see https://www.elastic.co/guide/en/workplace-search/current/workplace-search-custom-sources-api.html#
|
32
|
+
# @see https://www.elastic.co/guide/en/workplace-search/current/workplace-search-custom-sources-api.html#delete-by-id
|
33
33
|
#
|
34
34
|
def delete_documents(content_source_id, arguments = {})
|
35
35
|
raise ArgumentError, "Required parameter 'content_source_id' missing" unless content_source_id
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
4
|
+
# license agreements. See the NOTICE file distributed with
|
5
|
+
# this work for additional information regarding copyright
|
6
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
7
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
8
|
+
# not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing,
|
14
|
+
# software distributed under the License is distributed on an
|
15
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
16
|
+
# KIND, either express or implied. See the License for the
|
17
|
+
# specific language governing permissions and limitations
|
18
|
+
# under the License.
|
19
|
+
|
20
|
+
module Elastic
|
21
|
+
module EnterpriseSearch
|
22
|
+
module WorkplaceSearch
|
23
|
+
module Actions
|
24
|
+
# Documents - Retrieves a document by ID from the specified content source
|
25
|
+
# Retrieves a document by ID from the specified content source
|
26
|
+
#
|
27
|
+
# @param content_source_id [String] Unique ID for a Custom API source, provided upon creation of a Custom API Source (*Required*)
|
28
|
+
# @param arguments [Hash] endpoint arguments
|
29
|
+
# @option arguments [String] :document_id (*Required*)
|
30
|
+
# @option arguments [Hash] :headers optional HTTP headers to send with the request
|
31
|
+
#
|
32
|
+
# @see https://www.elastic.co/guide/en/workplace-search/current/workplace-search-content-sources-api.html#get-document-by-id-api
|
33
|
+
#
|
34
|
+
def document(content_source_id, arguments = {})
|
35
|
+
raise ArgumentError, "Required parameter 'content_source_id' missing" unless content_source_id
|
36
|
+
raise ArgumentError, "Required parameter 'document_id' missing" unless arguments[:document_id]
|
37
|
+
|
38
|
+
document_id = arguments[:document_id]
|
39
|
+
|
40
|
+
headers = arguments.delete(:headers) || {}
|
41
|
+
|
42
|
+
request(
|
43
|
+
:get,
|
44
|
+
"api/ws/v1/sources/#{content_source_id}/documents/#{document_id}/",
|
45
|
+
arguments,
|
46
|
+
{},
|
47
|
+
headers
|
48
|
+
)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
4
|
+
# license agreements. See the NOTICE file distributed with
|
5
|
+
# this work for additional information regarding copyright
|
6
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
7
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
8
|
+
# not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing,
|
14
|
+
# software distributed under the License is distributed on an
|
15
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
16
|
+
# KIND, either express or implied. See the License for the
|
17
|
+
# specific language governing permissions and limitations
|
18
|
+
# under the License.
|
19
|
+
|
20
|
+
module Elastic
|
21
|
+
module EnterpriseSearch
|
22
|
+
module WorkplaceSearch
|
23
|
+
module Actions
|
24
|
+
# ContentSources - Retrieves all content sources
|
25
|
+
# Retrieves all content sources
|
26
|
+
#
|
27
|
+
# @param arguments [Hash] endpoint arguments
|
28
|
+
# @option arguments [Integer] :current_page Which page of results to request
|
29
|
+
# @option arguments [Integer] :page_size The number of results to return in a page
|
30
|
+
# @option arguments [Hash] :headers optional HTTP headers to send with the request
|
31
|
+
#
|
32
|
+
# @see https://www.elastic.co/guide/en/workplace-search/current/workplace-search-content-sources-api.html#list-content-sources-api
|
33
|
+
#
|
34
|
+
def list_content_sources(arguments = {})
|
35
|
+
headers = arguments.delete(:headers) || {}
|
36
|
+
|
37
|
+
request(
|
38
|
+
:get,
|
39
|
+
'api/ws/v1/sources/',
|
40
|
+
arguments,
|
41
|
+
{},
|
42
|
+
headers
|
43
|
+
)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
4
|
+
# license agreements. See the NOTICE file distributed with
|
5
|
+
# this work for additional information regarding copyright
|
6
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
7
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
8
|
+
# not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing,
|
14
|
+
# software distributed under the License is distributed on an
|
15
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
16
|
+
# KIND, either express or implied. See the License for the
|
17
|
+
# specific language governing permissions and limitations
|
18
|
+
# under the License.
|
19
|
+
|
20
|
+
module Elastic
|
21
|
+
module EnterpriseSearch
|
22
|
+
module WorkplaceSearch
|
23
|
+
module Actions
|
24
|
+
# ContentSources - Update a content source
|
25
|
+
# Update a custom content source
|
26
|
+
#
|
27
|
+
# @param content_source_id [String] Unique ID for a Custom API source, provided upon creation of a Custom API Source (*Required*)
|
28
|
+
# @param arguments [Hash] endpoint arguments
|
29
|
+
# @option arguments [Object] :body Definition to update a Workplace Search Content Source (Required: name, schema, display, is_searchable)
|
30
|
+
# @option body [String] :name The human readable display name for this Content Source.
|
31
|
+
# @option body :schema The schema that each document in this Content Source will adhere to.
|
32
|
+
# @option body :display The display details which governs which fields will be displayed, and in what order, in the search results.
|
33
|
+
# @option body [Boolean] :is_searchable Whether or not this Content Source will be searchable on the search page.
|
34
|
+
# @option arguments [Hash] :headers optional HTTP headers to send with the request
|
35
|
+
#
|
36
|
+
# @see https://www.elastic.co/guide/en/workplace-search/current/workplace-search-content-sources-api.html#update-content-source-api
|
37
|
+
#
|
38
|
+
def put_content_source(content_source_id, arguments = {})
|
39
|
+
raise ArgumentError, "Required parameter 'content_source_id' missing" unless content_source_id
|
40
|
+
|
41
|
+
body = arguments.delete(:body) || {}
|
42
|
+
headers = arguments.delete(:headers) || {}
|
43
|
+
|
44
|
+
request(
|
45
|
+
:put,
|
46
|
+
"api/ws/v1/sources/#{content_source_id}/",
|
47
|
+
arguments,
|
48
|
+
body,
|
49
|
+
headers
|
50
|
+
)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -28,6 +28,8 @@ module Elastic
|
|
28
28
|
# @param arguments [Hash] endpoint arguments
|
29
29
|
# @option arguments [String] :user The username in context (*Required*)
|
30
30
|
# @option arguments [Object] :body (Required: source_user_id, user)
|
31
|
+
# @option body [String] :source_user_id
|
32
|
+
# @option body [String] :user
|
31
33
|
# @option arguments [Hash] :headers optional HTTP headers to send with the request
|
32
34
|
#
|
33
35
|
# @see https://www.elastic.co/guide/en/workplace-search/current/workplace-search-external-identities-api.html#update-external-identity
|
@@ -31,6 +31,10 @@ describe Elastic::EnterpriseSearch::Client do
|
|
31
31
|
Elastic::EnterpriseSearch::Client.new(host: host, http_auth: http_auth)
|
32
32
|
end
|
33
33
|
|
34
|
+
after do
|
35
|
+
client.put_read_only(body: { enabled: false })
|
36
|
+
end
|
37
|
+
|
34
38
|
context 'API' do
|
35
39
|
context 'health' do
|
36
40
|
it 'makes GET request' do
|
@@ -0,0 +1,253 @@
|
|
1
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
2
|
+
# license agreements. See the NOTICE file distributed with
|
3
|
+
# this work for additional information regarding copyright
|
4
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
5
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
6
|
+
# not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing,
|
12
|
+
# software distributed under the License is distributed on an
|
13
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
14
|
+
# KIND, either express or implied. See the License for the
|
15
|
+
# specific language governing permissions and limitations
|
16
|
+
# under the License.
|
17
|
+
|
18
|
+
# frozen_string_literal: true
|
19
|
+
|
20
|
+
require 'spec_helper'
|
21
|
+
|
22
|
+
describe Elastic::EnterpriseSearch::WorkplaceSearch::Client do
|
23
|
+
let(:host) { ENV['ELASTIC_ENTERPRISE_HOST'] || 'http://localhost:3002' }
|
24
|
+
let(:http_auth) do
|
25
|
+
{
|
26
|
+
user: ENV['ELASTIC_ENTERPRISE_USER'] || 'enterprise_search',
|
27
|
+
password: ENV['ELASTIC_ENTERPRISE_PASSWORD'] || 'changeme'
|
28
|
+
}
|
29
|
+
end
|
30
|
+
let(:client) do
|
31
|
+
Elastic::EnterpriseSearch::WorkplaceSearch::Client.new(host: host, http_auth: http_auth)
|
32
|
+
end
|
33
|
+
let(:documents) do
|
34
|
+
[
|
35
|
+
{
|
36
|
+
'id' => '4e696e74656e646f203634',
|
37
|
+
'url' => 'https://www.elastic.co/blog/introducing-quick-start-guides-getting-started-with-elastic-enterprise-search-for-free',
|
38
|
+
'title' => 'Getting started with Elastic Enterprise Search for free',
|
39
|
+
'body' => 'this is a test'
|
40
|
+
},
|
41
|
+
{
|
42
|
+
'id' => '47616d6520426f7920436f6c6f72',
|
43
|
+
'url' => 'https://www.elastic.co/workplace-search',
|
44
|
+
'title' => 'One-stop answer shop for the virtual workplace',
|
45
|
+
'body' => 'this is also a test'
|
46
|
+
}
|
47
|
+
]
|
48
|
+
end
|
49
|
+
|
50
|
+
context 'Content Sources' do
|
51
|
+
it 'creates, retrieves and deletes authenticated with basic auth' do
|
52
|
+
# Create a content source and get its id
|
53
|
+
response = client.create_content_source(name: 'test')
|
54
|
+
expect(response.status).to eq 200
|
55
|
+
expect(response.body['id'])
|
56
|
+
id = response.body['id']
|
57
|
+
|
58
|
+
# Test we get the content source information with get_content_source
|
59
|
+
response = client.content_source(id)
|
60
|
+
expect(response.status).to eq 200
|
61
|
+
|
62
|
+
# List all content sources
|
63
|
+
response = client.list_content_sources
|
64
|
+
expect(response.status).to eq 200
|
65
|
+
expect(response.body['results'].count).to be >= 1
|
66
|
+
|
67
|
+
# Delete content source
|
68
|
+
response = client.delete_content_source(id)
|
69
|
+
expect(response.status).to eq 200
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'creates and updates' do
|
73
|
+
response = client.create_content_source(name: 'ruby_client_app')
|
74
|
+
expect(response.status).to eq 200
|
75
|
+
id = response.body['id']
|
76
|
+
|
77
|
+
documents = [{ title: 'My first Document', body: 'Content', url: 'elastic.co' }]
|
78
|
+
response = client.index_documents(id, documents: documents)
|
79
|
+
expect(response.status).to eq 200
|
80
|
+
|
81
|
+
new_name = 'ruby_client'
|
82
|
+
body = {
|
83
|
+
name: new_name,
|
84
|
+
schema: { title: 'text', body: 'text', url: 'text' },
|
85
|
+
display: { title_field: 'title', url_field: 'url', color: '#f00f00' },
|
86
|
+
is_searchable: true
|
87
|
+
}
|
88
|
+
response = client.put_content_source(id, body: body)
|
89
|
+
expect(response.status).to eq 200
|
90
|
+
|
91
|
+
response = client.content_source(id)
|
92
|
+
expect(response.status).to eq 200
|
93
|
+
expect(response.body['name']) == new_name
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
context 'Documents' do
|
98
|
+
let(:content_source_id) do
|
99
|
+
client.create_content_source(name: 'test').body['id']
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'indexes' do
|
103
|
+
response = client.index_documents(content_source_id, documents: documents)
|
104
|
+
expect(response.status).to eq 200
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'deletes' do
|
108
|
+
response = client.delete_documents(content_source_id, document_ids: documents.map { |doc| doc['id'] })
|
109
|
+
expect(response.status).to eq 200
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
context 'Documents in Content Sources' do
|
114
|
+
let(:content_source_id) { client.create_content_source(name: 'books').body['id'] }
|
115
|
+
let(:document_id) { client.index_documents(content_source_id, documents: documents).body['results'].first['id'] }
|
116
|
+
|
117
|
+
it 'Gets a document in a content source' do
|
118
|
+
response = client.document(content_source_id, document_id: document_id)
|
119
|
+
expect(response.status).to eq 200
|
120
|
+
expect(response.body['id']).to eq document_id
|
121
|
+
end
|
122
|
+
|
123
|
+
it 'Deletes all documents in a content source' do
|
124
|
+
response = client.delete_all_documents(content_source_id)
|
125
|
+
expect(response.status).to eq 200
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
context 'External Identities' do
|
130
|
+
let(:content_source_id) { client.create_content_source(name: 'my_content').body['id'] }
|
131
|
+
let(:user) { 'elastic_user' }
|
132
|
+
let(:source_user_id) { 'example@elastic.co' }
|
133
|
+
let(:body) do
|
134
|
+
{ user: user, source_user_id: source_user_id }
|
135
|
+
end
|
136
|
+
|
137
|
+
context 'Creates' do
|
138
|
+
let(:source_user_id) { 'test@elastic.co' }
|
139
|
+
let(:user) { 'test' }
|
140
|
+
|
141
|
+
it 'creates an external identity' do
|
142
|
+
response = client.create_external_identity(content_source_id, body: body)
|
143
|
+
|
144
|
+
expect(response.status).to eq 200
|
145
|
+
expect(response.body).to eq({ 'source_user_id' => source_user_id, 'user' => user })
|
146
|
+
|
147
|
+
client.delete_external_identity(content_source_id, user: user)
|
148
|
+
end
|
149
|
+
|
150
|
+
it 'creates and retrieves' do
|
151
|
+
client.create_external_identity(content_source_id, body: body)
|
152
|
+
response = client.external_identity(content_source_id, user: user)
|
153
|
+
|
154
|
+
expect(response.status).to eq 200
|
155
|
+
expect(response.body).to eq({ 'source_user_id' => source_user_id, 'user' => user })
|
156
|
+
client.delete_external_identity(content_source_id, user: user)
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
context 'Lists' do
|
161
|
+
let(:user) { 'lists_test' }
|
162
|
+
|
163
|
+
it 'lists external identities' do
|
164
|
+
client.create_external_identity(content_source_id, body: body)
|
165
|
+
response = client.list_external_identities(content_source_id)
|
166
|
+
|
167
|
+
expect(response.status).to eq 200
|
168
|
+
expect(response.body['results']).to eq([{ 'source_user_id' => source_user_id, 'user' => user }])
|
169
|
+
client.delete_external_identity(content_source_id, user: user)
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
context 'Updates' do
|
174
|
+
before do
|
175
|
+
client.create_external_identity(content_source_id, body: body)
|
176
|
+
end
|
177
|
+
|
178
|
+
it 'updates an external identity' do
|
179
|
+
body = { source_user_id: 'example2@elastic.co' }
|
180
|
+
response = client.put_external_identity(content_source_id, user: user, body: body)
|
181
|
+
|
182
|
+
expect(response.status).to eq 200
|
183
|
+
expect(response.body).to eq({ 'source_user_id' => 'example2@elastic.co', 'user' => user })
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
context 'Deletes' do
|
188
|
+
before do
|
189
|
+
client.create_external_identity(content_source_id, body: body)
|
190
|
+
end
|
191
|
+
|
192
|
+
it 'deletes an external identity' do
|
193
|
+
response = client.delete_external_identity(content_source_id, user: user)
|
194
|
+
expect(response.status).to eq 200
|
195
|
+
expect(response.body).to eq 'ok'
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
context 'Permissions' do
|
201
|
+
let(:content_source_id) { client.create_content_source(name: 'my_content').body['id'] }
|
202
|
+
let(:user) { 'enterprise_search' }
|
203
|
+
let(:permissions) { ['permission1', 'permission2'] }
|
204
|
+
|
205
|
+
after do
|
206
|
+
client.put_user_permissions(content_source_id, { permissions: [], user: user })
|
207
|
+
end
|
208
|
+
|
209
|
+
it 'adds permissions to a user' do
|
210
|
+
response = client.add_user_permissions(
|
211
|
+
content_source_id,
|
212
|
+
{ permissions: permissions, user: user }
|
213
|
+
)
|
214
|
+
expect(response.status).to eq 200
|
215
|
+
expect(response.body).to eq({ 'user' => 'enterprise_search', 'permissions' => ['permission1', 'permission2'] })
|
216
|
+
end
|
217
|
+
|
218
|
+
it 'removes permissions from a user' do
|
219
|
+
client.add_user_permissions(content_source_id, { permissions: permissions, user: user })
|
220
|
+
|
221
|
+
# Removes Permissions
|
222
|
+
response = client.remove_user_permissions(
|
223
|
+
content_source_id,
|
224
|
+
{ permissions: permissions, user: user }
|
225
|
+
)
|
226
|
+
expect(response.status).to eq 200
|
227
|
+
expect(response.body).to eq({ 'user' => 'enterprise_search', 'permissions' => [] })
|
228
|
+
end
|
229
|
+
|
230
|
+
it 'lists permissions' do
|
231
|
+
response = client.list_permissions(content_source_id)
|
232
|
+
expect(response.status).to eq 200
|
233
|
+
end
|
234
|
+
|
235
|
+
it 'gets a user\'s permissions' do
|
236
|
+
client.add_user_permissions(content_source_id, { permissions: permissions, user: user })
|
237
|
+
response = client.user_permissions(content_source_id, { user: user })
|
238
|
+
expect(response.status).to eq 200
|
239
|
+
expect(response.body).to eq({ 'user' => 'enterprise_search', 'permissions' => permissions })
|
240
|
+
end
|
241
|
+
|
242
|
+
it 'updates a user\'s permissions' do
|
243
|
+
permissions = ['testing', 'more', 'permissions']
|
244
|
+
response = client.add_user_permissions(content_source_id, { permissions: permissions, user: user })
|
245
|
+
expect(response.status).to eq 200
|
246
|
+
expect(response.body).to eq({ 'user' => 'enterprise_search', 'permissions' => permissions })
|
247
|
+
|
248
|
+
response = client.put_user_permissions(content_source_id, { permissions: [], user: user })
|
249
|
+
expect(response.status).to eq 200
|
250
|
+
expect(response.body).to eq({ 'user' => 'enterprise_search', 'permissions' => [] })
|
251
|
+
end
|
252
|
+
end
|
253
|
+
end
|