2016-02-01 07:43:26 -05:00
|
|
|
# frozen_string_literal: true
|
2021-06-01 23:32:47 -04:00
|
|
|
require_relative 'helper'
|
2013-10-15 20:14:16 -04:00
|
|
|
|
|
|
|
class TestGemSourceFetchProblem < Gem::TestCase
|
|
|
|
def test_exception
|
|
|
|
source = Gem::Source.new @gem_repo
|
|
|
|
error = RuntimeError.new 'test'
|
|
|
|
|
|
|
|
sf = Gem::SourceFetchProblem.new source, error
|
|
|
|
|
2021-05-10 23:25:46 -04:00
|
|
|
e = assert_raise RuntimeError do
|
2013-10-15 20:14:16 -04:00
|
|
|
raise sf
|
|
|
|
end
|
|
|
|
|
|
|
|
assert_equal 'test', e.message
|
|
|
|
end
|
|
|
|
|
2016-04-27 20:33:08 -04:00
|
|
|
def test_password_redacted
|
|
|
|
source = Gem::Source.new 'https://username:secret@gemsource.com'
|
|
|
|
error = RuntimeError.new 'test'
|
|
|
|
|
|
|
|
sf = Gem::SourceFetchProblem.new source, error
|
|
|
|
|
|
|
|
refute_match sf.wordy, 'secret'
|
|
|
|
end
|
2021-09-09 03:24:41 -04:00
|
|
|
|
|
|
|
def test_source_password_no_redacted
|
|
|
|
source = Gem::Source.new 'https://username:secret@gemsource.com'
|
|
|
|
error = RuntimeError.new 'test'
|
|
|
|
|
|
|
|
sf = Gem::SourceFetchProblem.new source, error
|
|
|
|
sf.wordy
|
|
|
|
|
|
|
|
assert_match 'secret', source.uri.to_s
|
|
|
|
end
|
2013-10-15 20:14:16 -04:00
|
|
|
end
|