File tree Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -97,7 +97,7 @@ def proxy_bypass_registry(host):
97
97
# '<local>' string by the localhost entry and the corresponding
98
98
# canonical entry.
99
99
proxyOverride = proxyOverride .split (";" )
100
- # filter out empty strings to avoid re.match all true.
100
+ # filter out empty strings to avoid re.match return true in the following code .
101
101
proxyOverride = filter (None , proxyOverride )
102
102
# now check if we match one of the registry values.
103
103
for test in proxyOverride :
Original file line number Diff line number Diff line change @@ -924,3 +924,35 @@ def test_set_environ_raises_exception():
924
924
raise Exception ("Expected exception" )
925
925
926
926
assert "Expected exception" in str (exception .value )
927
+
928
+
929
+ @pytest .mark .skipif (os .name != "nt" , reason = "Test only on Windows" )
930
+ def test_should_bypass_proxies_win_registry_ProxyOverride_value (monkeypatch ):
931
+ """Tests for function should_bypass_proxies to check if proxy
932
+ can be bypassed or not with Windows ProxyOverride registry value ending with a semicolon.
933
+ """
934
+ import winreg
935
+
936
+ class RegHandle :
937
+ def Close (self ):
938
+ pass
939
+
940
+ ie_settings = RegHandle ()
941
+
942
+ def OpenKey (key , subkey ):
943
+ return ie_settings
944
+
945
+ def QueryValueEx (key , value_name ):
946
+ if key is ie_settings :
947
+ if value_name == "ProxyEnable" :
948
+ return [1 ]
949
+ elif value_name == "ProxyOverride" :
950
+ return [
951
+ "192.168.*;127.0.0.1;localhost.localdomain;172.16.1.1;<-loopback>;"
952
+ ]
953
+
954
+ monkeypatch .setenv ("NO_PROXY" , "" )
955
+ monkeypatch .setenv ("no_proxy" , "" )
956
+ monkeypatch .setattr (winreg , "OpenKey" , OpenKey )
957
+ monkeypatch .setattr (winreg , "QueryValueEx" , QueryValueEx )
958
+ assert should_bypass_proxies ("http://example.com/" , None ) is False
You can’t perform that action at this time.
0 commit comments