Commit 5b90f894 authored by Gabriel Mazetto's avatar Gabriel Mazetto

specs for RemoteNode

parent c4bf8a88
FactoryGirl.define do
factory :doorkeeper_access_grant, class: Doorkeeper::AccessGrant do
sequence(:resource_owner_id) { |n| n }
application
association :application, factory: :doorkeeper_application
redirect_uri 'https://app.com/callback'
expires_in 100
scopes 'public write'
......@@ -9,7 +9,7 @@ FactoryGirl.define do
factory :doorkeeper_access_token, class: Doorkeeper::AccessToken do
sequence(:resource_owner_id) { |n| n }
application
association :application, factory: :doorkeeper_application
expires_in 2.hours
factory :clientless_access_token do
......
require 'spec_helper'
describe Gitlab::Geo::RemoteNode do
subject { described_class.new }
let(:access_token) { FactoryGirl.create(:doorkeeper_access_token).token }
let(:user) { FactoryGirl.build(:user) }
before(:each) do
allow(subject).to receive(:primary_node_url) { 'http://localhost:3001/' }
allow(described_class).to receive(:get) { response }
end
describe '#authenticate' do
let(:response) { double }
context 'on success' do
it 'returns hashed user data' do
allow(response).to receive(:code) { 200 }
allow(response).to receive(:parsed_response) { user.to_json }
subject.authenticate(access_token)
end
end
context 'on invalid token' do
it 'raises exception' do
allow(response).to receive(:code) { 401 }
expect { subject.authenticate(access_token) }.to raise_error(Gitlab::Geo::RemoteNode::InvalidCredentialsError)
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment