Fix unauthorized user tests and add non-authenticated user tests

This commit is contained in:
JB Vasseur 2018-10-11 22:35:17 +09:00
parent 33c88f5e51
commit f1645bf7e7
1 changed files with 19 additions and 3 deletions

View File

@ -95,6 +95,14 @@ describe API::Applications, :api do
end
end
context 'authorized user without authorization' do
it 'cannot list application' do
get api('/applications', user)
expect(response).to have_http_status 403
end
end
context 'non-authenticated user' do
it 'cannot list application' do
get api('/applications', user)
@ -109,15 +117,23 @@ describe API::Applications, :api do
it 'can delete an application' do
expect do
delete api("/applications/#{application.id}", admin_user)
end.to change { Doorkeeper::Application.count }.by -1
end.to change { Doorkeeper::Application.count }.by(-1)
expect(response).to have_gitlab_http_status(204)
end
end
context 'authorized user without authorization' do
it 'cannot delete an application' do
delete api("/applications/#{application.id}", user)
expect(response).to have_http_status 403
end
end
context 'non-authenticated user' do
it 'cannot delete an application' do
delete api("/applications/#{application.id}", user)
delete api("/applications/#{application.id}")
expect(response).to have_http_status 401
end