Skip to content

Commit

Permalink
Clean up the no_proxy value: not all clients ignore spaces (bsc#1089796)
Browse files Browse the repository at this point in the history
  • Loading branch information
mvidner committed May 16, 2018
1 parent 9da500c commit 73462d4
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 5 deletions.
34 changes: 29 additions & 5 deletions src/modules/Proxy.rb
Expand Up @@ -29,17 +29,34 @@ def main
@pass = ""
end

# no-proxy domains; reader
# domains that should not be proxied; reader
# @return [String]
def no
@no
def no_proxy_domains
clean_up_no_proxy(@no)
end

# no-proxy domains; writer
# domains that should not be proxied; writer
# @param value [String]
def no_proxy_domains=(value)
@no = clean_up_no_proxy(value)
end

# Compatibility:
publish :variable => :no, :type => "string"

# we need "publish :variable" but it defines an attr_accessor
# so let's undefine it
remove_method :no
remove_method :"no="

def no
no_proxy_domains
end

def no=(value)
@no = value
self.no_proxy_domains = value
end

# Display popup at the end of the proxy configuration
# @param [Boolean] modified true if proxy settings have been modified
def ProxyFinishPopup(modified)
Expand Down Expand Up @@ -512,6 +529,13 @@ def GetEnvironment
publish :function => :GetModified, :type => "boolean ()"
publish :function => :SetModified, :type => "void ()"
publish :function => :GetEnvironment, :type => "map <string, string> ()"

private

# Clean up the no_proxy value: not all clients ignore spaces (bsc#1089796)
def clean_up_no_proxy(v)
v.gsub(" ", "")
end
end

Proxy = ProxyClass.new
Expand Down
16 changes: 16 additions & 0 deletions test/write_test.rb
Expand Up @@ -93,6 +93,22 @@
expect(subject.WriteCurlrc).to be true
end

it "writes a no-proxy setting without spaces" do
subject.Import({ "enabled" => true,
"http_proxy" => "proxy.example.org:3128",
"no_proxy" => "example.org, example.com, localhost" })
expect(Yast::SCR).to receive(:Write).
with(path(".root.curlrc.\"--noproxy\""),
"example.org,example.com,localhost").
once.and_return true

allow(Yast::SCR).to receive(:Write).
with(path_matching(/^\.root\.curlrc/), anything).
and_return true

expect(subject.WriteCurlrc).to be true
end

it "escapes user name" do
subject.Import({ "enabled" => true,
"http_proxy" => "proxy.example.org:3128",
Expand Down

0 comments on commit 73462d4

Please sign in to comment.