Skip to content

Commit c05d663

Browse files
committed
[API] Adds unit tests for user profile endpoints
1 parent b604e65 commit c05d663

File tree

8 files changed

+254
-11
lines changed

8 files changed

+254
-11
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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+
require 'spec_helper'
19+
20+
describe 'client#security#activate_user_profile' do
21+
let(:expected_args) do
22+
[
23+
'POST',
24+
'_security/profile/_activate',
25+
{},
26+
{},
27+
{},
28+
{ endpoint: 'security.activate_user_profile' }
29+
]
30+
end
31+
32+
it 'performs the request' do
33+
expect(client_double.security.activate_user_profile(body: {})).to be_a Elasticsearch::API::Response
34+
end
35+
end
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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+
require 'spec_helper'
19+
20+
describe 'client#security#disable_user_profile' do
21+
let(:expected_args) do
22+
[
23+
'PUT',
24+
'_security/profile/foo/_disable',
25+
{},
26+
nil,
27+
{},
28+
{ endpoint: 'security.disable_user_profile', defined_params: { uid: 'foo' } }
29+
]
30+
end
31+
32+
it 'performs the request' do
33+
expect(client_double.security.disable_user_profile(uid: 'foo')).to be_a Elasticsearch::API::Response
34+
end
35+
end
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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+
require 'spec_helper'
19+
20+
describe 'client#security#enable_user_profile' do
21+
let(:expected_args) do
22+
[
23+
'PUT',
24+
'_security/profile/foo/_enable',
25+
{},
26+
nil,
27+
{},
28+
{ endpoint: 'security.enable_user_profile', defined_params: { uid: 'foo' } }
29+
]
30+
end
31+
32+
it 'performs the request' do
33+
expect(client_double.security.enable_user_profile(uid: 'foo')).to be_a Elasticsearch::API::Response
34+
end
35+
end

elasticsearch-api/spec/unit/actions/security/get_api_key_spec.rb

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,14 @@
1818
require 'spec_helper'
1919

2020
describe 'client#security#get_api_key' do
21-
2221
let(:expected_args) do
2322
[
24-
'GET',
25-
'_security/api_key',
26-
params,
27-
nil,
28-
{},
29-
{ endpoint: 'security.get_api_key' }
23+
'GET',
24+
'_security/api_key',
25+
params,
26+
nil,
27+
{},
28+
{ endpoint: 'security.get_api_key' }
3029
]
3130
end
3231

@@ -39,7 +38,6 @@
3938
end
4039

4140
context 'when params are specified' do
42-
4341
let(:params) do
4442
{ id: '1',
4543
username: 'user',
@@ -49,9 +47,9 @@
4947

5048
it 'performs the request' do
5149
expect(client_double.security.get_api_key(id: '1',
52-
username: 'user',
53-
name: 'my-api-key',
54-
realm_name: '_es_api_key')).to be_a Elasticsearch::API::Response
50+
username: 'user',
51+
name: 'my-api-key',
52+
realm_name: '_es_api_key')).to be_a Elasticsearch::API::Response
5553
end
5654
end
5755
end
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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+
require 'spec_helper'
19+
20+
describe 'client#security#get_user_profile' do
21+
let(:expected_args) do
22+
[
23+
'GET',
24+
'_security/profile/foo',
25+
{},
26+
nil,
27+
{},
28+
{ endpoint: 'security.get_user_profile', defined_params: { uid: 'foo' } }
29+
]
30+
end
31+
32+
it 'performs the request' do
33+
expect(client_double.security.get_user_profile(uid: 'foo')).to be_a Elasticsearch::API::Response
34+
end
35+
end
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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+
require 'spec_helper'
19+
20+
describe 'client#security#has_privileges_user_profile' do
21+
let(:expected_args) do
22+
[
23+
'POST',
24+
'_security/profile/_has_privileges',
25+
{},
26+
{},
27+
{},
28+
{ endpoint: 'security.has_privileges_user_profile' }
29+
]
30+
end
31+
32+
it 'performs the request' do
33+
expect(client_double.security.has_privileges_user_profile(body: {})).to be_a Elasticsearch::API::Response
34+
end
35+
end
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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+
require 'spec_helper'
19+
20+
describe 'client#security#suggest_user_profiles' do
21+
let(:expected_args) do
22+
[
23+
'POST',
24+
'_security/profile/_suggest',
25+
{},
26+
{},
27+
{},
28+
{ endpoint: 'security.suggest_user_profiles' }
29+
]
30+
end
31+
32+
it 'performs the request' do
33+
expect(client_double.security.suggest_user_profiles(body: {})).to be_a Elasticsearch::API::Response
34+
end
35+
end
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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+
require 'spec_helper'
19+
20+
describe 'client#security#update_user_profile_data' do
21+
let(:expected_args) do
22+
[
23+
'PUT',
24+
'_security/profile/foo/_data',
25+
{},
26+
{},
27+
{},
28+
{ endpoint: 'security.update_user_profile_data', defined_params: { uid: 'foo' } }
29+
]
30+
end
31+
32+
it 'performs the request' do
33+
expect(client_double.security.update_user_profile_data(uid: 'foo', body: {})).to be_a Elasticsearch::API::Response
34+
end
35+
end

0 commit comments

Comments
 (0)