diff options
Diffstat (limited to 'spec/requests/api/internal/base_spec.rb')
-rw-r--r-- | spec/requests/api/internal/base_spec.rb | 94 |
1 files changed, 47 insertions, 47 deletions
diff --git a/spec/requests/api/internal/base_spec.rb b/spec/requests/api/internal/base_spec.rb index 733f0446cf4..02dc2229769 100644 --- a/spec/requests/api/internal/base_spec.rb +++ b/spec/requests/api/internal/base_spec.rb @@ -16,7 +16,7 @@ describe API::Internal::Base do get api("/internal/check"), params: { secret_token: secret_token } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['api_version']).to eq(API::API.version) expect(json_response['redis']).to be(true) end @@ -34,13 +34,13 @@ describe API::Internal::Base do get api("/internal/check"), headers: { API::Helpers::GITLAB_SHARED_SECRET_HEADER => Base64.encode64(secret_token) } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it 'returns 401 when no credentials provided' do get(api("/internal/check")) - expect(response).to have_gitlab_http_status(401) + expect(response).to have_gitlab_http_status(:unauthorized) end end end @@ -126,7 +126,7 @@ describe API::Internal::Base do it 'returns the correct information about the key' do lfs_auth_key(key.id, project) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['username']).to eq(user.username) expect(json_response['repository_http_path']).to eq(project.http_url_to_repo) expect(json_response['expires_in']).to eq(Gitlab::LfsToken::DEFAULT_EXPIRE_TIME) @@ -136,7 +136,7 @@ describe API::Internal::Base do it 'returns the correct information about the user' do lfs_auth_user(user.id, project) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['username']).to eq(user.username) expect(json_response['repository_http_path']).to eq(project.http_url_to_repo) expect(Gitlab::LfsToken.new(user).token_valid?(json_response['lfs_token'])).to be_truthy @@ -145,19 +145,19 @@ describe API::Internal::Base do it 'returns a 404 when no key or user is provided' do lfs_auth_project(project) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end it 'returns a 404 when the wrong key is provided' do lfs_auth_key(key.id + 12345, project) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end it 'returns a 404 when the wrong user is provided' do lfs_auth_user(user.id + 12345, project) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -167,7 +167,7 @@ describe API::Internal::Base do it 'returns the correct information about the key' do lfs_auth_key(key.id, project) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['username']).to eq("lfs+deploy-key-#{key.id}") expect(json_response['repository_http_path']).to eq(project.http_url_to_repo) expect(Gitlab::LfsToken.new(key).token_valid?(json_response['lfs_token'])).to be_truthy @@ -179,7 +179,7 @@ describe API::Internal::Base do it "finds a user by key id" do get(api("/internal/discover"), params: { key_id: key.id, secret_token: secret_token }) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['name']).to eq(user.name) end @@ -187,7 +187,7 @@ describe API::Internal::Base do it "finds a user by username" do get(api("/internal/discover"), params: { username: user.username, secret_token: secret_token }) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['name']).to eq(user.name) end @@ -195,7 +195,7 @@ describe API::Internal::Base do it 'responds successfully when a user is not found' do get(api('/internal/discover'), params: { username: 'noone', secret_token: secret_token }) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response.body).to eq('null') end @@ -203,7 +203,7 @@ describe API::Internal::Base do it 'response successfully when passing invalid params' do get(api('/internal/discover'), params: { nothing: 'to find a user', secret_token: secret_token }) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response.body).to eq('null') end @@ -284,7 +284,7 @@ describe API::Internal::Base do GIT_ALTERNATE_OBJECT_DIRECTORIES_RELATIVE: alt_obj_dirs_relative }.to_json) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end @@ -292,7 +292,7 @@ describe API::Internal::Base do it 'responds with success' do push(key, project.wiki) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response["status"]).to be_truthy expect(json_response["gl_project_path"]).to eq(project.wiki.full_path) expect(json_response["gl_repository"]).to eq("wiki-#{project.id}") @@ -304,7 +304,7 @@ describe API::Internal::Base do it 'responds with success' do pull(key, project.wiki) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response["status"]).to be_truthy expect(json_response["gl_project_path"]).to eq(project.wiki.full_path) expect(json_response["gl_repository"]).to eq("wiki-#{project.id}") @@ -320,7 +320,7 @@ describe API::Internal::Base do it "has the correct payload" do pull(key, project) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response["status"]).to be_truthy expect(json_response["gl_repository"]).to eq("project-#{project.id}") expect(json_response["gl_project_path"]).to eq(project.full_path) @@ -340,7 +340,7 @@ describe API::Internal::Base do it do push(key, project) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response["status"]).to be_truthy expect(json_response["gl_repository"]).to eq("project-#{project.id}") expect(json_response["gl_project_path"]).to eq(project.full_path) @@ -409,7 +409,7 @@ describe API::Internal::Base do it do pull(key, project) - expect(response).to have_gitlab_http_status(401) + expect(response).to have_gitlab_http_status(:unauthorized) expect(json_response["status"]).to be_falsey expect(user.reload.last_activity_on).to be_nil end @@ -419,7 +419,7 @@ describe API::Internal::Base do it do push(key, project) - expect(response).to have_gitlab_http_status(401) + expect(response).to have_gitlab_http_status(:unauthorized) expect(json_response["status"]).to be_falsey expect(user.reload.last_activity_on).to be_nil end @@ -464,7 +464,7 @@ describe API::Internal::Base do it do push(key, project) - expect(response).to have_gitlab_http_status(300) + expect(response).to have_gitlab_http_status(:multiple_choices) expect(json_response['status']).to be_truthy expect(json_response['payload']).to eql(payload) expect(json_response['gl_console_messages']).to eql(console_messages) @@ -483,7 +483,7 @@ describe API::Internal::Base do it "has the correct payload" do pull(key, project) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['gl_console_messages']).to eq([]) end end @@ -500,7 +500,7 @@ describe API::Internal::Base do pull(key, project) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['gl_console_messages']).to eq(console_messages) end end @@ -518,7 +518,7 @@ describe API::Internal::Base do it do pull(key, personal_project) - expect(response).to have_gitlab_http_status(401) + expect(response).to have_gitlab_http_status(:unauthorized) expect(json_response["status"]).to be_falsey expect(user.reload.last_activity_on).to be_nil end @@ -528,7 +528,7 @@ describe API::Internal::Base do it do push(key, personal_project) - expect(response).to have_gitlab_http_status(401) + expect(response).to have_gitlab_http_status(:unauthorized) expect(json_response["status"]).to be_falsey expect(user.reload.last_activity_on).to be_nil end @@ -545,7 +545,7 @@ describe API::Internal::Base do end push(key, personal_project) - expect(response).to have_gitlab_http_status(503) + expect(response).to have_gitlab_http_status(:service_unavailable) expect(json_response['status']).to be_falsey expect(json_response['message']).to eq("Foo") expect(user.reload.last_activity_on).to be_nil @@ -563,7 +563,7 @@ describe API::Internal::Base do it do pull(key, project) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response["status"]).to be_truthy end end @@ -572,7 +572,7 @@ describe API::Internal::Base do it do push(key, project) - expect(response).to have_gitlab_http_status(401) + expect(response).to have_gitlab_http_status(:unauthorized) expect(json_response["status"]).to be_falsey end end @@ -589,7 +589,7 @@ describe API::Internal::Base do it do archive(key, project) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response["status"]).to be_truthy expect(json_response["gitaly"]).not_to be_nil expect(json_response["gitaly"]["repository"]).not_to be_nil @@ -604,7 +604,7 @@ describe API::Internal::Base do it do archive(key, project) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) expect(json_response["status"]).to be_falsey end end @@ -616,7 +616,7 @@ describe API::Internal::Base do pull(key, project) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) expect(json_response["status"]).to be_falsey end @@ -632,7 +632,7 @@ describe API::Internal::Base do } ) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) expect(json_response["status"]).to be_falsey end end @@ -641,7 +641,7 @@ describe API::Internal::Base do it do pull(OpenStruct.new(id: 0), project) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) expect(json_response["status"]).to be_falsey end end @@ -714,14 +714,14 @@ describe API::Internal::Base do it 'rejects the push' do push(key, project) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) expect(json_response['status']).to be_falsy end it 'rejects the SSH pull' do pull(key, project) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) expect(json_response['status']).to be_falsy end end @@ -750,7 +750,7 @@ describe API::Internal::Base do # # post api("/internal/notify_post_receive"), valid_params # - # expect(response).to have_gitlab_http_status(200) + # expect(response).to have_gitlab_http_status(:ok) # end # # it "calls the Gitaly client with the wiki's repository if it's a wiki" do @@ -762,7 +762,7 @@ describe API::Internal::Base do # # post api("/internal/notify_post_receive"), valid_wiki_params # - # expect(response).to have_gitlab_http_status(200) + # expect(response).to have_gitlab_http_status(:ok) # end # # it "returns 500 if the gitaly call fails" do @@ -771,7 +771,7 @@ describe API::Internal::Base do # # post api("/internal/notify_post_receive"), valid_params # - # expect(response).to have_gitlab_http_status(500) + # expect(response).to have_gitlab_http_status(:internal_server_error) # end # # context 'with a gl_repository parameter' do @@ -792,7 +792,7 @@ describe API::Internal::Base do # # post api("/internal/notify_post_receive"), valid_params # - # expect(response).to have_gitlab_http_status(200) + # expect(response).to have_gitlab_http_status(:ok) # end # # it "calls the Gitaly client with the wiki's repository if it's a wiki" do @@ -804,7 +804,7 @@ describe API::Internal::Base do # # post api("/internal/notify_post_receive"), valid_wiki_params # - # expect(response).to have_gitlab_http_status(200) + # expect(response).to have_gitlab_http_status(:ok) # end # end # end @@ -961,7 +961,7 @@ describe API::Internal::Base do it 'outputs a broadcast message' do post api('/internal/post_receive'), params: valid_params - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['messages']).to include(build_alert_message(broadcast_message.message)) end end @@ -970,7 +970,7 @@ describe API::Internal::Base do it 'does not output a broadcast message' do post api('/internal/post_receive'), params: valid_params - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(has_alert_messages?(json_response['messages'])).to be_falsey end end @@ -981,7 +981,7 @@ describe API::Internal::Base do post api('/internal/post_receive'), params: valid_params - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(has_alert_messages?(json_response['messages'])).to be_falsey end end @@ -993,7 +993,7 @@ describe API::Internal::Base do post api('/internal/post_receive'), params: valid_params - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['messages']).to include(build_basic_message(project_moved.message)) end end @@ -1005,7 +1005,7 @@ describe API::Internal::Base do post api('/internal/post_receive'), params: valid_params - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['messages']).to include(build_basic_message(project_created.message)) end end @@ -1018,7 +1018,7 @@ describe API::Internal::Base do post api('/internal/post_receive'), params: valid_params - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end @@ -1032,7 +1032,7 @@ describe API::Internal::Base do post api('/internal/post_receive'), params: valid_params - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end end |