Skip to content

Commit

Permalink
Merge e035a1d into df3bc49
Browse files Browse the repository at this point in the history
  • Loading branch information
mvidner committed May 16, 2018
2 parents df3bc49 + e035a1d commit d12a4b7
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 36 deletions.
29 changes: 2 additions & 27 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,30 +1,5 @@
Makefile
/Makefile.am
Makefile.in
aclocal.m4
autom4te.cache
config.cache
config.guess
config.h
config.h.in
config.log
config.status
config.sub
configure
configure.ac
/coverage/
depcomp
install-sh
/doc/
*.pot
libtool
ltconfig
ltmain.sh
missing
mkinstalldirs
stamp-h*
Makefile.am.common
*.ami
*.bz2
.dep
tmp.*
*.log
/.yardoc/
7 changes: 7 additions & 0 deletions .yardopts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
--no-private
--markup markdown
--protected
--readme README.md
--output-dir ./doc
--files *.md
src/**/*.rb
7 changes: 7 additions & 0 deletions package/yast2-proxy.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Thu May 10 09:18:19 UTC 2018 - mvidner@suse.com

- Clean up the no_proxy value: not all clients ignore spaces
(bsc#1089796)
- 3.1.7

-------------------------------------------------------------------
Fri Jun 12 16:13:53 UTC 2015 - mvidner@suse.com

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-proxy.spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


Name: yast2-proxy
Version: 3.1.6
Version: 3.1.7
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down
49 changes: 41 additions & 8 deletions src/modules/Proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,34 @@ def main
@pass = ""
end

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

# 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)
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 @@ -71,8 +99,7 @@ def Read
@https = "" if @https == nil
@ftp = Convert.to_string(SCR.Read(path(".sysconfig.proxy.FTP_PROXY")))
@ftp = "" if @ftp == nil
@no = Convert.to_string(SCR.Read(path(".sysconfig.proxy.NO_PROXY")))
@no = "" if @no == nil
self.no = SCR.Read(path(".sysconfig.proxy.NO_PROXY")) || ""
@enabled = Convert.to_string(
SCR.Read(path(".sysconfig.proxy.PROXY_ENABLED"))
) == "yes"
Expand Down Expand Up @@ -108,7 +135,7 @@ def WriteSysconfig
SCR.Write(path(".sysconfig.proxy.HTTP_PROXY"), @http)
SCR.Write(path(".sysconfig.proxy.HTTPS_PROXY"), @https)
SCR.Write(path(".sysconfig.proxy.FTP_PROXY"), @ftp)
SCR.Write(path(".sysconfig.proxy.NO_PROXY"), @no)
SCR.Write(path(".sysconfig.proxy.NO_PROXY"), no)
SCR.Write(path(".sysconfig.proxy"), nil)
end

Expand All @@ -132,7 +159,7 @@ def WriteCurlrc
# bnc#305163
"--proxy" => @http,
# bsc#923788
"--noproxy" => @no
"--noproxy" => no
}

# proxy is used, write /root/.curlrc
Expand Down Expand Up @@ -210,7 +237,7 @@ def Import(settings)
@http = Ops.get_string(settings, "http_proxy", "")
@https = Ops.get_string(settings, "https_proxy", "")
@ftp = Ops.get_string(settings, "ftp_proxy", "")
@no = Ops.get_string(settings, "no_proxy", "localhost")
self.no = Ops.get_string(settings, "no_proxy", "localhost")
@user = Ops.get_string(settings, "proxy_user", "")
@pass = Ops.get_string(settings, "proxy_password", "")

Expand Down Expand Up @@ -401,7 +428,7 @@ def Export
"http_proxy" => @http,
"https_proxy" => @https,
"ftp_proxy" => @ftp,
"no_proxy" => @no,
"no_proxy" => no,
"proxy_user" => @user,
"proxy_password" => @pass
}
Expand Down Expand Up @@ -480,7 +507,7 @@ def GetEnvironment
"http_proxy" => @http,
"HTTPS_PROXY" => @https,
"FTP_PROXY" => @ftp,
"NO_PROXY" => @no
"NO_PROXY" => no
}
end

Expand All @@ -491,7 +518,6 @@ def GetEnvironment
publish :variable => :http, :type => "string"
publish :variable => :https, :type => "string"
publish :variable => :ftp, :type => "string"
publish :variable => :no, :type => "string"
publish :variable => :user, :type => "string"
publish :variable => :pass, :type => "string"
publish :function => :Read, :type => "boolean ()"
Expand All @@ -503,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
Original file line number Diff line number Diff line change
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 d12a4b7

Please sign in to comment.