gitlab-org--gitlab-foss/spec/requests/api/doorkeeper_access_spec.rb
blackst0ne b44a2c801a Update specs to rails5 format
Updates specs to use new rails5 format.

The old format:
`get :show, { some: params }, { some: headers }`

The new format:
`get :show, params: { some: params }, headers: { some: headers }`
2018-12-19 10:04:31 +11:00

58 lines
1.7 KiB
Ruby

require 'spec_helper'
describe 'doorkeeper access' do
let!(:user) { create(:user) }
let!(:application) { Doorkeeper::Application.create!(name: "MyApp", redirect_uri: "https://app.com", owner: user) }
let!(:token) { Doorkeeper::AccessToken.create! application_id: application.id, resource_owner_id: user.id, scopes: "api" }
describe "unauthenticated" do
it "returns authentication success" do
get api("/user"), params: { access_token: token.token }
expect(response).to have_gitlab_http_status(200)
end
include_examples 'user login request with unique ip limit' do
def request
get api('/user'), params: { access_token: token.token }
end
end
end
describe "when token invalid" do
it "returns authentication error" do
get api("/user"), params: { access_token: "123a" }
expect(response).to have_gitlab_http_status(401)
end
end
describe "authorization by OAuth token" do
it "returns authentication success" do
get api("/user", user)
expect(response).to have_gitlab_http_status(200)
end
include_examples 'user login request with unique ip limit' do
def request
get api('/user', user)
end
end
end
describe "when user is blocked" do
it "returns authorization error" do
user.block
get api("/user"), params: { access_token: token.token }
expect(response).to have_gitlab_http_status(403)
end
end
describe "when user is ldap_blocked" do
it "returns authorization error" do
user.ldap_block
get api("/user"), params: { access_token: token.token }
expect(response).to have_gitlab_http_status(403)
end
end
end