diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-25 00:09:08 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-25 00:09:08 +0300 |
commit | 7671216b60e2796a050358ff808b4a0c2de3d22f (patch) | |
tree | 605dfc1339a3cd7dc7353ac6d725191086a9acca /spec/requests | |
parent | c2367afbf57ebc65d5b78a743b5d6a91f0aece9f (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/requests')
-rw-r--r-- | spec/requests/api/version_spec.rb | 46 |
1 files changed, 42 insertions, 4 deletions
diff --git a/spec/requests/api/version_spec.rb b/spec/requests/api/version_spec.rb index e2117ca45ee..7d81170687a 100644 --- a/spec/requests/api/version_spec.rb +++ b/spec/requests/api/version_spec.rb @@ -12,17 +12,55 @@ describe API::Version do end end - context 'when authenticated' do + context 'when authenticated as user' do let(:user) { create(:user) } it 'returns the version information' do get api('/version', user) - expect(response).to have_gitlab_http_status(200) - expect(json_response['version']).to eq(Gitlab::VERSION) - expect(json_response['revision']).to eq(Gitlab.revision) + expect_version end end + + context 'when authenticated with token' do + let(:personal_access_token) { create(:personal_access_token, scopes: scopes) } + + context 'with api scope' do + let(:scopes) { %i(api) } + + it 'returns the version information' do + get api('/version', personal_access_token: personal_access_token) + + expect_version + end + end + + context 'with read_user scope' do + let(:scopes) { %i(read_user) } + + it 'returns the version information' do + get api('/version', personal_access_token: personal_access_token) + + expect_version + end + end + + context 'with neither api nor read_user scope' do + let(:scopes) { %i(read_repository) } + + it 'returns authorization error' do + get api('/version', personal_access_token: personal_access_token) + + expect(response).to have_gitlab_http_status(403) + end + end + end + + def expect_version + expect(response).to have_gitlab_http_status(200) + expect(json_response['version']).to eq(Gitlab::VERSION) + expect(json_response['revision']).to eq(Gitlab.revision) + end end context 'with graphql enabled' do |