def test_ava_fro_2(self): ats = saml.attribute_statement_from_string(STATEMENT2) # print(ats) ava = {} for ac in self.acs: ava.update(ac.fro(ats)) print(ava.keys()) assert _eq(ava.keys(), ['eduPersonEntitlement', 'eduPersonAffiliation', 'uid', 'mail', 'givenName', 'sn'])
def test_ava_fro_2(self): ats = saml.attribute_statement_from_string(STATEMENT2) # print(ats) ava = {} for ac in self.acs: ava.update(ac.fro(ats)) print(ava.keys()) assert _eq(ava.keys(), [ 'eduPersonEntitlement', 'eduPersonAffiliation', 'uid', 'mail', 'givenName', 'sn' ])
def test_mixed_attributes_1(self): ats = saml.attribute_statement_from_string(STATEMENT_MIXED) ava = to_local(self.acs, ats) assert ava == {'eduPersonAffiliation': ['staff'], 'givenName': ['Roland'], 'sn': ['Hedberg'], 'uid': ['demouser'], 'user_id': ['bob']} # Allow unknown ava = to_local(self.acs, ats, True) assert ava == {'eduPersonAffiliation': ['staff'], 'givenName': ['Roland'], 'sn': ['Hedberg'], 'urn:oid:2.16.756.1.2.5.1.1.5': ['others'], 'uid': ['demouser'], 'urn:example:com:foo': ['Thing'], 'user_id': ['bob']}
def test_to_local_name_from_unspecified(self): _xml = """<?xml version='1.0' encoding='UTF-8'?> <ns0:AttributeStatement xmlns:ns0="urn:oasis:names:tc:SAML:2.0:assertion"> <ns0:Attribute xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Name="EmailAddress" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified"> <ns0:AttributeValue xsi:type="xs:string">[email protected]</ns0:AttributeValue> </ns0:Attribute> </ns0:AttributeStatement> """ attr = attribute_statement_from_string(_xml) ava = attribute_converter.to_local(self.acs, attr) assert _eq(list(ava.keys()), ['EmailAddress'])
def test_ava_fro_1(self): ats = saml.attribute_statement_from_string(STATEMENT1) # print(ats) ava = None for ac in self.acs: try: ava = ac.fro(ats) except attribute_converter.UnknownNameFormat: pass # break if we have something if ava: break print(ava.keys()) assert _eq(ava.keys(), ['givenName', 'displayName', 'uid', 'eduPersonNickname', 'street', 'eduPersonScopedAffiliation', 'employeeType', 'eduPersonAffiliation', 'eduPersonPrincipalName', 'sn', 'postalCode', 'physicalDeliveryOfficeName', 'ou', 'eduPersonTargetedID', 'cn'])
def test_ava_fro_1(self): ats = saml.attribute_statement_from_string(STATEMENT1) # print(ats) ava = None for ac in self.acs: try: ava = ac.fro(ats) except attribute_converter.UnknownNameFormat: pass # break if we have something if ava: break print(ava.keys()) assert _eq(ava.keys(), [ 'givenName', 'displayName', 'uid', 'eduPersonNickname', 'street', 'eduPersonScopedAffiliation', 'employeeType', 'eduPersonAffiliation', 'eduPersonPrincipalName', 'sn', 'postalCode', 'physicalDeliveryOfficeName', 'ou', 'eduPersonTargetedID', 'cn' ])
def test_mixed_attributes_1(self): ats = saml.attribute_statement_from_string(STATEMENT_MIXED) ava = to_local(self.acs, ats) assert ava == { 'eduPersonAffiliation': ['staff'], 'givenName': ['Roland'], 'sn': ['Hedberg'], 'uid': ['demouser'], 'user_id': ['bob'] } # Allow unknown ava = to_local(self.acs, ats, True) assert ava == { 'eduPersonAffiliation': ['staff'], 'givenName': ['Roland'], 'sn': ['Hedberg'], 'urn:oid:2.16.756.1.2.5.1.1.5': ['others'], 'uid': ['demouser'], 'urn:example:com:foo': ['Thing'], 'user_id': ['bob'] }
def test_unspecified_name_format(self): ats = saml.attribute_statement_from_string(STATEMENT4) ava = to_local(self.acs, ats) assert ava == {'user_id': ['bob'], 'NameID': ['bobsnameagain']}