示例#1
0
 def get_metadata_context(self) -> dict:
     """Get any extra context for the metadata template.
     Suggested extra context variables include 'org' and 'contacts'.
     """
     return {
         'sls_url': self.get_sls_url(),
         'acs_url': self.get_acs_url(),
         'entity_id': self.get_sp_entity_id(),
         'certificate': certificate_to_string(self.get_sp_certificate()),
         'org': None,
         'contacts': [],
     }
示例#2
0
    def test_rendering_metadata_view(self):
        xpath = lambda el, path: el.xpath(path, namespaces=NAMESPACE_MAP)[0]

        response = self.client.get(url_for('flask_saml2_sp.metadata'))
        response_xml = etree.fromstring(response.data.decode('utf-8'))

        certificate = certificate_to_string(CERTIFICATE)

        sp = xpath(response_xml, '/md:EntityDescriptor/md:SPSSODescriptor')
        enc_key = xpath(sp, './md:KeyDescriptor[@use="encryption"]')
        sign_key = xpath(sp, './md:KeyDescriptor[@use="signing"]')

        assert certificate == xpath(enc_key, './/ds:X509Certificate').text
        assert certificate == xpath(sign_key, './/ds:X509Certificate').text

        acs_url = url_for('flask_saml2_sp.acs', _external=True)
        slo_url = url_for('flask_saml2_sp.sls', _external=True)
        assert acs_url == xpath(sp, './md:AssertionConsumerService').attrib['Location']
        assert slo_url == xpath(sp, './md:SingleLogoutService').attrib['Location']
示例#3
0
    def test_rendering_metadata_view(self):
        xpath = lambda el, path: el.xpath(path, namespaces=NAMESPACE_MAP)[0]

        response = self.client.get(url_for('flask_saml2_idp.metadata'))
        response_xml = etree.fromstring(response.data.decode('utf-8'))

        certificate = certificate_to_string(CERTIFICATE)
        login_url = url_for('flask_saml2_idp.login_begin', _external=True)
        logout_url = url_for('flask_saml2_idp.logout', _external=True)

        idp = xpath(response_xml, '/md:EntityDescriptor/md:IDPSSODescriptor')
        enc_key = xpath(idp, 'md:KeyDescriptor[@use="encryption"]')
        sign_key = xpath(idp, 'md:KeyDescriptor[@use="signing"]')

        assert certificate == xpath(enc_key, './/ds:X509Certificate').text
        assert certificate == xpath(sign_key, './/ds:X509Certificate').text

        assert login_url == xpath(idp,
                                  'md:SingleSignOnService').get('Location')
        assert logout_url == xpath(idp,
                                   'md:SingleLogoutService').get('Location')