debian-mirror-gitlab/spec/requests/api/doorkeeper_access_spec.rb

32 lines
881 B
Ruby
Raw Normal View History

2015-04-26 12:48:37 +05:30
require 'spec_helper'
describe API::API, api: true do
include ApiHelpers
let!(:user) { create(:user) }
2015-09-11 14:41:01 +05:30
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 }
2015-04-26 12:48:37 +05:30
describe "when unauthenticated" do
it "returns authentication success" do
2015-09-11 14:41:01 +05:30
get api("/user"), access_token: token.token
2015-04-26 12:48:37 +05:30
expect(response.status).to eq(200)
end
end
describe "when token invalid" do
it "returns authentication error" do
2015-09-11 14:41:01 +05:30
get api("/user"), access_token: "123a"
2015-04-26 12:48:37 +05:30
expect(response.status).to eq(401)
end
end
describe "authorization by private token" do
it "returns authentication success" do
get api("/user", user)
expect(response.status).to eq(200)
end
end
end