def test_filter_values_req_opt_4(): r = [ Attribute( friendly_name="surName", name="urn:oid:2.5.4.4", name_format="urn:oasis:names:tc:SAML:2.0:attrname-format:uri"), Attribute( friendly_name="givenName", name="urn:oid:2.5.4.42", name_format="urn:oasis:names:tc:SAML:2.0:attrname-format:uri") ] o = [ Attribute( friendly_name="title", name="urn:oid:2.5.4.12", name_format="urn:oasis:names:tc:SAML:2.0:attrname-format:uri") ] acs = attribute_converter.ac_factory("attributemaps") rava = attribute_converter.ava_fro(acs, r) oava = attribute_converter.ava_fro(acs, o) ava = { "sn": ["Hedberg"], "givenName": ["Roland"], "eduPersonAffiliation": ["staff"], "uid": ["rohe0002"] } ava = assertion.filter_on_demands(ava, rava, oava) print ava assert _eq(ava.keys(), ['givenName', 'sn']) assert ava == {'givenName': ['Roland'], 'sn': ['Hedberg']}
def test_filter_values_req_opt_4(): r = [ Attribute( friendly_name="surName", name="urn:oid:2.5.4.4", name_format="urn:oasis:names:tc:SAML:2.0:attrname-format:uri"), Attribute( friendly_name="givenName", name="urn:oid:2.5.4.42", name_format="urn:oasis:names:tc:SAML:2.0:attrname-format:uri")] o = [ Attribute( friendly_name="title", name="urn:oid:2.5.4.12", name_format="urn:oasis:names:tc:SAML:2.0:attrname-format:uri")] acs = attribute_converter.ac_factory(full_path("attributemaps")) rava = attribute_converter.ava_fro(acs, r) oava = attribute_converter.ava_fro(acs, o) ava = {"sn": ["Hedberg"], "givenName": ["Roland"], "eduPersonAffiliation": ["staff"], "uid": ["rohe0002"]} ava = assertion.filter_on_demands(ava, rava, oava) print ava assert _eq(ava.keys(), ['givenName', 'sn']) assert ava == {'givenName': ['Roland'], 'sn': ['Hedberg']}
def _sp_metadata(self, entity_descr, entity, tag): """ Pick out the SP SSO descriptors from an entity descriptor and store the information in a way which is easily accessible. :param entity_descr: A EntityDescriptor instance """ try: ssd = entity_descr.spsso_descriptor except AttributeError: return ssds = [] required = [] optional = [] #print "..... %s ..... " % entity_descriptor.entity_id for tssd in ssd: # Only want to talk to SAML 2.0 entities if samlp.NAMESPACE not in \ tssd.protocol_support_enumeration.split(" "): #print "<<<", idp.protocol_support_enumeration continue ssds.append(tssd) certs = self._certs(tssd.key_descriptor, "pem") self._add_certs(entity_descr.entity_id, certs) self._extensions(tssd) for acs in tssd.attribute_consuming_service: for attr in acs.requested_attribute: #print "==", attr if attr.is_required == "true": required.append(attr) else: optional.append(attr) for acs in tssd.assertion_consumer_service: self._add_certs(acs.location, certs) if required or optional: #print "REQ",required #print "OPT",optional self._wants[entity_descr.entity_id] = (ava_fro(self.attrconv, required), ava_fro(self.attrconv, optional)) if ssds: entity[tag] = ssds
def _sp_metadata(self, entity_descr, entity, tag): """ Pick out the SP SSO descriptors from an entity descriptor and store the information in a way which is easily accessible. :param entity_descr: A EntityDescriptor instance """ try: ssd = entity_descr.spsso_descriptor except AttributeError: return ssds = [] required = [] optional = [] #print "..... %s ..... " % entity_descriptor.entity_id for tssd in ssd: # Only want to talk to SAML 2.0 entities if samlp.NAMESPACE not in \ tssd.protocol_support_enumeration.split(" "): #print "<<<", idp.protocol_support_enumeration continue ssds.append(tssd) certs = self._certs(tssd.key_descriptor, "pem") self._add_certs(entity_descr.entity_id, certs) self._extensions(tssd) for acs in tssd.attribute_consuming_service: for attr in acs.requested_attribute: #print "==", attr if attr.is_required == "true": required.append(attr) else: optional.append(attr) for acs in tssd.assertion_consumer_service: self._add_certs(acs.location, certs) if required or optional: #print "REQ",required #print "OPT",optional self._wants[entity_descr.entity_id] = (ava_fro( self.attrconv, required), ava_fro(self.attrconv, optional)) if ssds: entity[tag] = ssds
def test_ava_fro_1(self): attr = [saml.Attribute(friendly_name="surName", name="urn:oid:2.5.4.4", name_format="urn:oasis:names:tc:SAML:2.0:attrname-format:uri"), saml.Attribute(friendly_name="efternamn", name="urn:oid:2.5.4.42", name_format="urn:oasis:names:tc:SAML:2.0:attrname-format:uri"), saml.Attribute(friendly_name="titel", name="urn:oid:2.5.4.12", name_format="urn:oasis:names:tc:SAML:2.0:attrname-format:uri")] result = attribute_converter.ava_fro(self.acs, attr) print result assert result == {'givenName': [], 'sn': [], 'title': []}