Merge branch 'sh-strip-github-pat-whitespace' into 'master'
Strip whitespace around GitHub personal access tokens Closes #46588 See merge request gitlab-org/gitlab-ce!22432
This commit is contained in:
commit
8aed9055a7
|
@ -20,7 +20,7 @@ class Import::GithubController < Import::BaseController
|
||||||
end
|
end
|
||||||
|
|
||||||
def personal_access_token
|
def personal_access_token
|
||||||
session[access_token_key] = params[:personal_access_token]
|
session[access_token_key] = params[:personal_access_token]&.strip
|
||||||
redirect_to status_import_url
|
redirect_to status_import_url
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
title: Strip whitespace around GitHub personal access tokens
|
||||||
|
merge_request: 22432
|
||||||
|
author:
|
||||||
|
type: fixed
|
|
@ -22,6 +22,18 @@ shared_examples 'a GitHub-ish import controller: POST personal_access_token' do
|
||||||
expect(session[:"#{provider}_access_token"]).to eq(token)
|
expect(session[:"#{provider}_access_token"]).to eq(token)
|
||||||
expect(controller).to redirect_to(status_import_url)
|
expect(controller).to redirect_to(status_import_url)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "strips access token with spaces" do
|
||||||
|
token = 'asdfasdf9876'
|
||||||
|
|
||||||
|
allow_any_instance_of(Gitlab::LegacyGithubImport::Client)
|
||||||
|
.to receive(:user).and_return(true)
|
||||||
|
|
||||||
|
post :personal_access_token, personal_access_token: " #{token} "
|
||||||
|
|
||||||
|
expect(session[:"#{provider}_access_token"]).to eq(token)
|
||||||
|
expect(controller).to redirect_to(status_import_url)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
shared_examples 'a GitHub-ish import controller: GET new' do
|
shared_examples 'a GitHub-ish import controller: GET new' do
|
||||||
|
|
Loading…
Reference in New Issue