'Given a SAML redirect URL, parse it and change the ID to
a consistent value, so the request is always identical.'

def modify_start_url(self, start_url):

    url_parts = urlparse(start_url)
    query = dict(((k, v[0]) for (k, v) in parse_qs(url_parts.query).iteritems()))
    xml = OneLogin_Saml2_Utils.decode_base64_and_inflate(query['SAMLRequest'])
    (xml, changed) = re.subn('ID="[^"]+"', 'ID="TEST_ID"', xml)
    self.assertEqual(changed, 1)
    query['SAMLRequest'] = OneLogin_Saml2_Utils.deflate_and_base64_encode(xml)
    url_parts = list(url_parts)
    url_parts[4] = urlencode(query)
    return urlunparse(url_parts)
