Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
See what's new at GitLab
4
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
I
instrumented-soap
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
thelabnyc
instrumented-soap
Commits
41a1c84a
Commit
41a1c84a
authored
Apr 22, 2019
by
Craig Weber
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new setting to allow setting SOAP proxy per domain
parent
33c6c1ce
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
7 deletions
+34
-7
sandbox/settings.py
sandbox/settings.py
+2
-1
src/soap/http.py
src/soap/http.py
+18
-5
src/soap/settings.py
src/soap/settings.py
+13
-0
src/soap/tests/test_soap.py
src/soap/tests/test_soap.py
+1
-1
No files found.
sandbox/settings.py
View file @
41a1c84a
...
...
@@ -16,4 +16,5 @@ INSTALLED_APPS = [
SECRET_KEY
=
'li0$-gnv)76g$yf7p@(cg-^_q7j6df5cx$o-gsef5hd68phj!4'
SOAP_PROXY_URL
=
None
SOAP_PROXIES
=
{
}
src/soap/http.py
View file @
41a1c84a
...
...
@@ -2,6 +2,7 @@ from django_statsd.clients import statsd
from
suds.transport
import
Transport
,
Reply
from
.
import
settings
import
urllib.request
import
urllib.parse
import
logging
import
requests
import
io
...
...
@@ -45,11 +46,14 @@ class HttpTransport(Transport):
if
url
.
startswith
(
'file://'
):
content
=
urllib
.
request
.
urlopen
(
url
)
else
:
resp
=
self
.
session
.
get
(
url
,
proxies
=
self
.
proxies
,
timeout
=
self
.
open_timeout
)
resp
=
self
.
session
.
get
(
url
,
proxies
=
self
.
proxies
(
url
),
timeout
=
self
.
open_timeout
)
resp
.
raise_for_status
()
content
=
io
.
BytesIO
(
resp
.
content
)
return
content
def
send
(
self
,
request
):
"""
Send a SOAP method call
...
...
@@ -64,21 +68,30 @@ class HttpTransport(Transport):
logger
.
debug
(
'Sending SOAP request: %s'
%
url
)
statsd
.
incr
(
'soap.send'
)
with
statsd
.
timer
(
'soap.send'
):
resp
=
self
.
session
.
post
(
url
,
proxies
=
self
.
proxies
,
timeout
=
self
.
send_timeout
,
data
=
msg
,
headers
=
headers
)
resp
=
self
.
session
.
post
(
url
,
proxies
=
self
.
proxies
(
url
),
timeout
=
self
.
send_timeout
,
data
=
msg
,
headers
=
headers
)
resp
.
raise_for_status
()
reply
=
Reply
(
requests
.
codes
.
OK
,
resp
.
headers
,
resp
.
content
)
return
reply
@
property
def
proxies
(
self
):
def
proxies
(
self
,
url
):
"""
Get the transport proxy configuration
:param url: string
:return: Proxy configuration dictionary
:rtype: Dictionary
"""
netloc
=
urllib
.
parse
.
urlparse
(
url
).
netloc
proxies
=
{}
if
settings
.
PROXY_URL
:
if
settings
.
PROXIES
and
settings
.
PROXIES
.
get
(
netloc
):
proxies
[
"http"
]
=
settings
.
PROXIES
[
netloc
]
proxies
[
"https"
]
=
settings
.
PROXIES
[
netloc
]
elif
settings
.
PROXY_URL
:
proxies
[
"http"
]
=
settings
.
PROXY_URL
proxies
[
"https"
]
=
settings
.
PROXY_URL
return
proxies
src/soap/settings.py
View file @
41a1c84a
import
warnings
try
:
from
django.conf
import
settings
except
ImportError
:
...
...
@@ -25,8 +26,20 @@ REMOVE_CACHE_ON_EXIT = overridable('SOAP_REMOVE_CACHE_ON_EXIT', False)
WSDL_INTERCEPTS
=
overridable
(
'SOAP_WSDL_INTERCEPTS'
,
{})
#: Optional HTTP/HTTPS proxy URL
#: DEPRECATED: Use SOAP_PROXIES instead
#: Set Django ``settings.SOAP_PROXY_URL`` to override.
PROXY_URL
=
overridable
(
'SOAP_PROXY_URL'
)
if
PROXY_URL
:
warnings
.
warn
(
"The SOAP_PROXY_URL setting is deprecated. Migrate to the SOAP_PROXIES setting."
,
DeprecationWarning
)
#: Optional HTTP/HTTPS proxy URL
#: Set Django ``settings.SOAP_PROXY_URL`` to override.
#: Format:
#:
#: SOAP_PROXIES = {
#: "soap.my-server.com": "http://myproxy.com:3128/",
#: }
PROXIES
=
overridable
(
'SOAP_PROXIES'
)
#: Timeout for opening WSDLs. Should be a tuple containing (1) the TCP connect
#: timeout and (2) the response timeout.
...
...
src/soap/tests/test_soap.py
View file @
41a1c84a
...
...
@@ -9,7 +9,7 @@ class SOAPTest(TestCase):
client
=
soap
.
get_client
(
wsdl
,
'LOCATIONS'
)
client
.
set_options
(
port
=
'NumberConversionSoap'
)
resp
=
client
.
service
.
NumberToWords
(
'42'
)
self
.
assertEqual
s
(
str
(
resp
).
strip
(),
'forty two'
)
self
.
assertEqual
(
str
(
resp
).
strip
(),
'forty two'
)
class
SOAPProxyTest
(
TestCase
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment