yast / yast-yast2

YaST module yast2
http://en.opensuse.org/Portal:YaST
GNU General Public License v2.0
54 stars 44 forks source link

Fixed RelURL to work properly with the FTP URLs #1220

Closed lslezak closed 2 years ago

lslezak commented 2 years ago

FTP URL Fix

It turned out that the URI class processes FTP URL paths a bit differently. Normally you have to use an absolute path otherwise you get an exception:

irb(main):001:0> u = URI("http://example.com")
=> #<URI::HTTP http://example.com>
irb(main):002:0> u.path = "path"
Traceback (most recent call last):
        4: from /usr/bin/irb:11:in `<main>'
        3: from (irb):2
        2: from /usr/lib64/ruby/2.5.0/uri/generic.rb:819:in `path='
        1: from /usr/lib64/ruby/2.5.0/uri/generic.rb:771:in `check_path'
URI::InvalidComponentError (bad component(expected absolute path component): path)
irb(main):003:0> u.path = "/path"
=> "/path"

But FTP URL is escaped when the path starts with /:

irb(main):001:0> u = URI("ftp://example.com")
=> #<URI::FTP ftp://example.com/>
irb(main):002:0> u.path = "/path"
=> "/path"
irb(main):003:0> u.to_s
=> "ftp://example.com/%2Fpath"

And it is allowed to use a relative path:

irb(main):004:0> u.path = "path"
=> "path"
irb(main):005:0> u.to_s
=> "ftp://example.com/path"

So there is an exception in the code for the FTP URLs to process them correctly.

Note: that's because FTP really allows using absolute paths for files!

Improve Mocking Yast::InstURL Module

Originally the module was always mocked but then the problem is that the RSpec verifying doubles will not work as expected. There might be an inconsistency between the mocked InstURL and the real InstURL.

But when running the tests locally or in GitHub Actions the real module is actually present and we do no need to reimplement it completely. Then the verifying doubles would use the real module and provide more reliable testing.

coveralls commented 2 years ago

Coverage Status

Coverage increased (+0.004%) to 41.459% when pulling 4e3c7058ed8f895fdbc10e76736460857cbee18c on relurl_ftp_fix into dcc5ed8eb9730963ac654fcbecae55dc0db31b23 on master.

yast-bot commented 2 years ago

:heavy_check_mark: Public Jenkins job #338 successfully finished :heavy_check_mark: Created OBS submit request #940886

yast-bot commented 2 years ago

:x: Internal Jenkins job #175 failed

yast-bot commented 2 years ago

:heavy_check_mark: Internal Jenkins job #176 successfully finished :heavy_check_mark: Created IBS submit request #260548