Skip to content

Commit

Permalink
Merge 4e6a238 into e6cdfc6
Browse files Browse the repository at this point in the history
  • Loading branch information
lslezak committed Aug 15, 2019
2 parents e6cdfc6 + 4e6a238 commit 02aa094
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 32 deletions.
18 changes: 1 addition & 17 deletions .gitignore
@@ -1,17 +1,3 @@
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
doc/autodocs
Expand All @@ -27,6 +13,4 @@ Makefile.am.common
.yardoc/
*.ami
*.bz2
.dep
tmp.*
*.log
/.yardoc/
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Expand Up @@ -14,7 +14,7 @@ Bug Reports
If you find a problem, please report it either using
[Bugzilla](https://bugzilla.suse.com/enter_bug.cgi?format=guided&product=openSUSE+Factory&component=YaST2)
or [GitHub issues](../../issues). (For Bugzilla, use the [simplified
registration](https://secure-www.novell.com/selfreg/jsp/createSimpleAccount.jsp)
registration](https://www.suse.com/selfreg/jsp/createSimpleAccount.jsp)
if you don't have an account yet.)

When creating a bug report, please follow our [bug reporting
Expand Down
13 changes: 13 additions & 0 deletions package/yast2-proxy.changes
@@ -1,3 +1,16 @@
-------------------------------------------------------------------
Fri Jul 19 12:59:49 UTC 2019 - Knut Alejandro Anderssen González <knut.anderssen@suse.com>

- Replace novel urls by SUSE ones (bsc#1100366)
- 3.1.8

-------------------------------------------------------------------
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
Expand Up @@ -17,7 +17,7 @@


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

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down
53 changes: 40 additions & 13 deletions src/modules/Proxy.rb
Expand Up @@ -29,6 +29,28 @@ 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="
alias_method :no, :no_proxy_domains
alias_method :"no=", :"no_proxy_domains="

# 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 +93,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_proxy_domains = 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 +129,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_proxy_domains)
SCR.Write(path(".sysconfig.proxy"), nil)
end

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

# proxy is used, write /root/.curlrc
Expand Down Expand Up @@ -210,7 +231,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_proxy_domains = 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 @@ -251,8 +272,8 @@ def RunTestProxy(http_proxy, https_proxy, ftp_proxy, proxy_user, proxy_password)
# /usr/bin/curl --verbose
# --proxy http://server_name:port_number
# --proxy-user user:password
# --url http://www.novell.com or ftp://ftp.novell.com | suggested for HTTP or FTP test
# --url https://secure-www.novell.com --insecure
# --url http://www.suse.com or ftp://ftp.suse.com | suggested for HTTP or FTP test
# --url https://www.suse.com --insecure
ret = {}

test_http = http_proxy != "" && http_proxy != "http://" ? true : false
Expand Down Expand Up @@ -306,22 +327,22 @@ def RunTestProxy(http_proxy, https_proxy, ftp_proxy, proxy_user, proxy_password)
http_proxy,
user_pass,
timeout_sec,
"http://www.novell.com"
"http://www.suse.com"
)
# adding option --insecure to accept the certificate without asking
https_command = Builtins.sformat(
command,
https_proxy,
user_pass,
timeout_sec,
"https://secure-www.novell.com --insecure"
"https://www.suse.com --insecure"
)
ftp_command = Builtins.sformat(
command,
ftp_proxy,
user_pass,
timeout_sec,
"ftp://ftp.novell.com"
"ftp://ftp.suse.com"
)

Builtins.y2milestone("Running HTTP_PROXY test...")
Expand Down Expand Up @@ -401,7 +422,7 @@ def Export
"http_proxy" => @http,
"https_proxy" => @https,
"ftp_proxy" => @ftp,
"no_proxy" => @no,
"no_proxy" => no_proxy_domains,
"proxy_user" => @user,
"proxy_password" => @pass
}
Expand Down Expand Up @@ -480,7 +501,7 @@ def GetEnvironment
"http_proxy" => @http,
"HTTPS_PROXY" => @https,
"FTP_PROXY" => @ftp,
"NO_PROXY" => @no
"NO_PROXY" => no_proxy_domains
}
end

Expand All @@ -491,7 +512,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 +523,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 02aa094

Please sign in to comment.