diff options
author | Douwe Maan <douwe@gitlab.com> | 2018-10-05 08:41:04 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2018-10-05 08:41:04 +0000 |
commit | 9fcd903b60d88b3df303628b09a15ef09689a002 (patch) | |
tree | 2644ab09cdf5b0b9dc5975ebda9c8b672fa44eee /spec/requests | |
parent | 81641e592a954e98c29d862148c1104b87f30745 (diff) | |
parent | 7d55c1353d6402f33a9fef734148fb776da076d3 (diff) | |
download | gitlab-ce-9fcd903b60d88b3df303628b09a15ef09689a002.tar.gz |
Merge branch 'features/unauth-access-ssh-keys' into 'master'
List public ssh keys by id or username without authentication
See merge request gitlab-org/gitlab-ce!20118
Diffstat (limited to 'spec/requests')
-rw-r--r-- | spec/requests/api/users_spec.rb | 38 |
1 files changed, 14 insertions, 24 deletions
diff --git a/spec/requests/api/users_spec.rb b/spec/requests/api/users_spec.rb index b7d62df0663..09c1d016081 100644 --- a/spec/requests/api/users_spec.rb +++ b/spec/requests/api/users_spec.rb @@ -785,35 +785,25 @@ describe API::Users do end describe 'GET /user/:id/keys' do - before do - admin - end + it 'returns 404 for non-existing user' do + user_id = not_existing_user_id - context 'when unauthenticated' do - it 'returns authentication error' do - get api("/users/#{user.id}/keys") - expect(response).to have_gitlab_http_status(401) - end - end + get api("/users/#{user_id}/keys") - context 'when authenticated' do - it 'returns 404 for non-existing user' do - get api('/users/999999/keys', admin) - expect(response).to have_gitlab_http_status(404) - expect(json_response['message']).to eq('404 User Not Found') - end + expect(response).to have_gitlab_http_status(404) + expect(json_response['message']).to eq('404 User Not Found') + end - it 'returns array of ssh keys' do - user.keys << key - user.save + it 'returns array of ssh keys' do + user.keys << key + user.save - get api("/users/#{user.id}/keys", admin) + get api("/users/#{user.id}/keys") - expect(response).to have_gitlab_http_status(200) - expect(response).to include_pagination_headers - expect(json_response).to be_an Array - expect(json_response.first['title']).to eq(key.title) - end + expect(response).to have_gitlab_http_status(200) + expect(response).to include_pagination_headers + expect(json_response).to be_an Array + expect(json_response.first['title']).to eq(key.title) end end |