diff --git a/features/fork.feature b/features/fork.feature index 6e6b8570049cb9f5224c4140a46b86abc099ce80..4b992f3074a3a9ae5cc1354293d902f5236094d9 100644 --- a/features/fork.feature +++ b/features/fork.feature @@ -7,7 +7,10 @@ Feature: hub fork Scenario: Fork the repository Given the GitHub API server: """ - before { halt 401 unless request.env['HTTP_AUTHORIZATION'] == 'token OTOKEN' } + before { + halt 400 unless request.env['HTTP_X_ORIGINAL_SCHEME'] == 'https' + halt 401 unless request.env['HTTP_AUTHORIZATION'] == 'token OTOKEN' + } get('/repos/mislav/dotfiles', :host_name => 'api.github.com') { 404 } post('/repos/evilchelu/dotfiles/forks', :host_name => 'api.github.com') { '' } """ @@ -121,7 +124,10 @@ Scenario: Related fork already exists Scenario: Enterprise fork Given the GitHub API server: """ - before { halt 401 unless request.env['HTTP_AUTHORIZATION'] == 'token FITOKEN' } + before { + halt 400 unless request.env['HTTP_X_ORIGINAL_SCHEME'] == 'https' + halt 401 unless request.env['HTTP_AUTHORIZATION'] == 'token FITOKEN' + } post('/api/v3/repos/evilchelu/dotfiles/forks', :host_name => 'git.my.org') { '' } """ And the "origin" remote has url "git@git.my.org:evilchelu/dotfiles.git" diff --git a/lib/hub/github_api.rb b/lib/hub/github_api.rb index 488d9a0c9f163e4de8d7d8f6a934a5a6fa06cc6c..26b4918c5de647ba16ef6880362f7d438085c723 100644 --- a/lib/hub/github_api.rb +++ b/lib/hub/github_api.rb @@ -248,6 +248,7 @@ module Hub def configure_connection req, url if ENV['HUB_TEST_HOST'] req['Host'] = url.host + req['X-Original-Scheme'] = url.scheme url = url.dup url.scheme = 'http' url.host, test_port = ENV['HUB_TEST_HOST'].split(':')