Skip to content

Commit

Permalink
Merge pull request #464 from adrianiurca/svn_not_support_nonASCII_cha…
Browse files Browse the repository at this point in the history
…rs_in_credentials

check if pass containes non-ASCII chars before provider is created
  • Loading branch information
sheenaajay committed Jul 1, 2020
2 parents f3c7068 + 5a67915 commit a36ee18
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/puppet/provider/vcsrepo/svn.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ def create
raise('You must specify the HTTP basic authentication username')
end

if @resource.value(:basic_auth_username) && @resource.value(:basic_auth_password)
if @resource.value(:basic_auth_password).to_s =~ %r{[\u007B-\u00BF\u02B0-\u037F\u2000-\u2BFF]}
raise('The password can not contain non-ASCII characters')
end
end

checkout_repository(@resource.value(:source),
@resource.value(:path),
@resource.value(:revision),
Expand Down
16 changes: 16 additions & 0 deletions spec/unit/puppet/provider/vcsrepo/svn_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,22 @@
provider.create
end
end
context 'when basic_auth_password contains non-ASCII characters' do
it 'fails' do
resource[:source] = 'an-important-value'
resource[:basic_auth_username] = 'dummy_user'
resource[:basic_auth_password] = 'ÙöØÓqþBÐh¦¹XH8«'
expect { provider.create }.to raise_error RuntimeError, %r{The password can not contain non-ASCII characters}
end
end
context 'when basic_auth_password contains only ASCII characters' do
it 'works' do
resource[:source] = 'an-important-value'
resource[:basic_auth_username] = 'dummy_user'
resource[:basic_auth_password] = 'dummy_pass'
provider.create
end
end
end

describe 'setting the source property' do
Expand Down

0 comments on commit a36ee18

Please sign in to comment.