Commit 8aed9055 authored by Rémy Coutable's avatar Rémy Coutable

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
parents 4ef9bb6a 3d82f20d
......@@ -20,7 +20,7 @@ class Import::GithubController < Import::BaseController
end
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
end
......
---
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(controller).to redirect_to(status_import_url)
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
shared_examples 'a GitHub-ish import controller: GET new' do
......
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