Commit 3270644f authored by Douwe Maan's avatar Douwe Maan

Merge branch 'fix-importing-projects-ghe'

parents 4d3896eb 7e1f86ed
......@@ -18,6 +18,8 @@ v 8.5.3
v 8.5.2
- Update LDAP groups asynchronously
- Fix an issue when weight text was displayed in Issuable collapsed sidebar
v 8.5.2
- Fix importing projects from GitHub Enterprise Edition.
v 8.5.1
- Fix adding pages domain to projects in groups
......
......@@ -42,11 +42,11 @@ module Gitlab
private
def config
Gitlab.config.omniauth.providers.find { |provider| provider.name == "github"}
Gitlab.config.omniauth.providers.find { |provider| provider.name == "github" }
end
def github_options
OmniAuth::Strategies::GitHub.default_options[:client_options].to_h.symbolize_keys
config["args"]["client_options"].deep_symbolize_keys
end
end
end
......
......@@ -2,16 +2,34 @@ require 'spec_helper'
describe Gitlab::GithubImport::Client, lib: true do
let(:token) { '123456' }
let(:client) { Gitlab::GithubImport::Client.new(token) }
let(:github_provider) { OpenStruct.new(app_id: 'asd123', app_secret: 'asd123', name: 'github', args: { 'client_options' => {} }) }
subject(:client) { described_class.new(token) }
before do
github_provider = OpenStruct.new(app_id: "asd123", app_secret: "asd123", name: "github", args: { "client_options" => {} })
allow(Gitlab.config.omniauth).to receive(:providers).and_return([github_provider])
end
it 'all OAuth2 client options are symbols' do
it 'convert OAuth2 client options to symbols' do
client.client.options.keys.each do |key|
expect(key).to be_kind_of(Symbol)
end
end
context 'when provider does not specity an API endpoint' do
it 'uses GitHub root API endpoint' do
expect(client.api.api_endpoint).to eq 'https://api.github.com/'
end
end
context 'when provider specify a custom API endpoint' do
before do
github_provider['args']['client_options']['site'] = 'https://github.company.com/'
end
it 'uses the custom API endpoint' do
expect(OmniAuth::Strategies::GitHub).not_to receive(:default_options)
expect(client.api.api_endpoint).to eq 'https://github.company.com/'
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