Welcome to mirror list, hosted at ThFree Co, Russian Federation.

doorkeeper_access_spec.rb « api « requests « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 39949a9042286cafc791a6554d79b5dadbf9223f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
require 'spec_helper'

describe API::API, api: true  do
  include ApiHelpers

  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 }

  
  describe "when unauthenticated" do
    it "returns authentication success" do
      get api("/user"), :access_token => token.token
      expect(response.status).to eq(200)
    end
  end

  describe "when token invalid" do
    it "returns authentication error" do
      get api("/user"), :access_token => "123a"
      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