Fix assertion ID tests for python3
Fixing basic renames reveals that some assumptions about the XML produced by etree need fixing, and there is a need to coerce some strings into bytes before base64.
This commit is contained in:
@@ -5,6 +5,7 @@ import copy
|
||||
import re
|
||||
import urllib
|
||||
from six.moves.urllib.parse import urlparse
|
||||
from six.moves.urllib.parse import urlencode
|
||||
import requests
|
||||
import time
|
||||
from six.moves.http_cookies import SimpleCookie
|
||||
@@ -269,10 +270,10 @@ class HTTPBase(object):
|
||||
@staticmethod
|
||||
def use_http_artifact(message, destination="", relay_state=""):
|
||||
if relay_state:
|
||||
query = urllib.urlencode({"SAMLart": message,
|
||||
"RelayState": relay_state})
|
||||
query = urlencode({"SAMLart": message,
|
||||
"RelayState": relay_state})
|
||||
else:
|
||||
query = urllib.urlencode({"SAMLart": message})
|
||||
query = urlencode({"SAMLart": message})
|
||||
info = {
|
||||
"data": "",
|
||||
"url": "%s?%s" % (destination, query)
|
||||
@@ -281,9 +282,13 @@ class HTTPBase(object):
|
||||
|
||||
@staticmethod
|
||||
def use_http_uri(message, typ, destination="", relay_state=""):
|
||||
if "\n" in message:
|
||||
data = message.split("\n")[1]
|
||||
else:
|
||||
data = message.strip()
|
||||
if typ == "SAMLResponse":
|
||||
info = {
|
||||
"data": message.split("\n")[1],
|
||||
"data": data,
|
||||
"headers": [
|
||||
("Content-Type", "application/samlassertion+xml"),
|
||||
("Cache-Control", "no-cache, no-store"),
|
||||
@@ -293,10 +298,10 @@ class HTTPBase(object):
|
||||
elif typ == "SAMLRequest":
|
||||
# msg should be an identifier
|
||||
if relay_state:
|
||||
query = urllib.urlencode({"ID": message,
|
||||
"RelayState": relay_state})
|
||||
query = urlencode({"ID": message,
|
||||
"RelayState": relay_state})
|
||||
else:
|
||||
query = urllib.urlencode({"ID": message})
|
||||
query = urlencode({"ID": message})
|
||||
info = {
|
||||
"data": "",
|
||||
"url": "%s?%s" % (destination, query)
|
||||
|
||||
@@ -59,12 +59,15 @@ def http_form_post_message(message, location, relay_state="",
|
||||
response = ["<head>", """<title>SAML 2.0 POST</title>""", "</head><body>"]
|
||||
|
||||
if not isinstance(message, six.string_types):
|
||||
message = "%s" % (message,)
|
||||
message = str(message)
|
||||
if not isinstance(message, six.binary_type):
|
||||
message = message.encode('utf-8')
|
||||
|
||||
if typ == "SAMLRequest" or typ == "SAMLResponse":
|
||||
_msg = base64.b64encode(message)
|
||||
else:
|
||||
_msg = message
|
||||
_msg = _msg.decode('ascii')
|
||||
|
||||
response.append(FORM_SPEC % (location, typ, _msg, relay_state))
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from contextlib import closing
|
||||
from urlparse import parse_qs
|
||||
from urlparse import urlparse
|
||||
from six.moves.urllib.parse import parse_qs
|
||||
from six.moves.urllib.parse import urlparse
|
||||
from saml2.authn_context import INTERNETPROTOCOLPASSWORD
|
||||
from saml2.samlp import AuthnRequest
|
||||
from saml2.samlp import NameIDPolicy
|
||||
|
||||
Reference in New Issue
Block a user