def test04ParseAttributeQuery(self): samlUtil = SAMLUtil() samlUtil.firstName = '' samlUtil.lastName = '' samlUtil.emailAddress = '' attributeQuery = samlUtil.buildAttributeQuery(SAMLTestCase.ISSUER_DN, SAMLTestCase.NAMEID_VALUE) elem = AttributeQueryElementTree.toXML(attributeQuery) xmlOutput = prettyPrint(elem) print("\n"+"_"*80) print(xmlOutput) attributeQueryStream = StringIO() attributeQueryStream.write(xmlOutput) attributeQueryStream.seek(0) tree = ElementTree.parse(attributeQueryStream) elem2 = tree.getroot() attributeQuery2 = AttributeQueryElementTree.fromXML(elem2) self.assert_(attributeQuery2.id == attributeQuery.id) self.assert_(attributeQuery2.issuer.value==attributeQuery.issuer.value) self.assert_(attributeQuery2.subject.nameID.value == \ attributeQuery.subject.nameID.value) self.assert_(attributeQuery2.attributes[1].name == \ attributeQuery.attributes[1].name) xmlOutput2 = prettyPrint(elem2) print("_"*80) print(xmlOutput2) print("_"*80)
def _serialize_authz_decision_query_response(self): response = SAMLUtil.create_authz_decision_query_response() # Create ElementTree Assertion Element responseElem = ResponseElementTree.toXML(response) self.assertTrue(ElementTree.iselement(responseElem)) # Serialise to output xmlOutput = prettyPrint(responseElem) return xmlOutput
def _serializeAuthzDecisionQueryResponse(self): response = self._createAuthzDecisionQueryResponse() # Create ElementTree Assertion Element responseElem = ResponseElementTree.toXML(response) self.assert_(ElementTree.iselement(responseElem)) # Serialise to output xmlOutput = prettyPrint(responseElem) return xmlOutput
def test05CreateAttributeQueryResponse(self): response = self._createAttributeQueryResponse() # Create ElementTree Assertion Element responseElem = ResponseElementTree.toXML(response) self.assert_(ElementTree.iselement(responseElem)) # Serialise to output xmlOutput = prettyPrint(responseElem) self.assert_(len(xmlOutput)) print("\n"+"_"*80) print(xmlOutput) print("_"*80)
def test03CreateAttributeQuery(self): samlUtil = SAMLUtil() samlUtil.firstName = '' samlUtil.lastName = '' samlUtil.emailAddress = '' attributeQuery = samlUtil.buildAttributeQuery(SAMLTestCase.ISSUER_DN, SAMLTestCase.NAMEID_VALUE) elem = AttributeQueryElementTree.toXML(attributeQuery) xmlOutput = prettyPrint(elem) print("\n"+"_"*80) print(xmlOutput) print("_"*80)
def test03_serialize_authz_decision_query(self): samlUtil = SAMLUtil() authzDecisionQuery = samlUtil.buildAuthzDecisionQuery() # Create ElementTree Assertion Element authzDecisionQueryElem = AuthzDecisionQueryElementTree.toXML( authzDecisionQuery) self.assertTrue(ElementTree.iselement(authzDecisionQueryElem)) # Serialise to output xmlOutput = prettyPrint(authzDecisionQueryElem) self.assertTrue(len(xmlOutput)) print(("\n"+"_"*80)) print(xmlOutput) print(("_"*80))
def test01CreateAssertion(self): assertion = self._createAttributeAssertionHelper() # Create ElementTree Assertion Element assertionElem = AssertionElementTree.toXML(assertion) self.assert_(ElementTree.iselement(assertionElem)) # Serialise to output xmlOutput = prettyPrint(assertionElem) self.assert_(len(xmlOutput)) print("\n"+"_"*80) print(xmlOutput) print("_"*80)
def test04_deserialize_authz_decision_query(self): samlUtil = SAMLUtil() authzDecisionQuery = samlUtil.buildAuthzDecisionQuery() # Create ElementTree Assertion Element authzDecisionQueryElem = AuthzDecisionQueryElementTree.toXML( authzDecisionQuery) self.assertTrue(ElementTree.iselement(authzDecisionQueryElem)) # Serialise to output xmlOutput = prettyPrint(authzDecisionQueryElem) self.assertTrue(len(xmlOutput)) authzDecisionQueryStream = StringIO() authzDecisionQueryStream.write(xmlOutput) authzDecisionQueryStream.seek(0) tree = ElementTree.parse(authzDecisionQueryStream) elem2 = tree.getroot() authzDecisionQuery2 = AuthzDecisionQueryElementTree.fromXML(elem2) self.assertTrue(authzDecisionQuery2) self.assertTrue( authzDecisionQuery2.subject.nameID.value == SAMLUtil.NAMEID_VALUE) self.assertTrue( authzDecisionQuery2.subject.nameID.format == SAMLUtil.NAMEID_FORMAT) self.assertTrue( authzDecisionQuery2.issuer.value == SAMLUtil.ISSUER_DN) self.assertTrue( authzDecisionQuery2.resource == SAMLUtil.RESOURCE_URI) self.assertTrue(len(authzDecisionQuery2.actions) == 1) self.assertTrue( authzDecisionQuery2.actions[0].value == Action.HTTP_GET_ACTION) self.assertTrue( authzDecisionQuery2.actions[0].namespace == Action.GHPP_NS_URI) self.assertTrue(authzDecisionQuery2.evidence is None)
def test02ParseAssertion(self): assertion = self._createAttributeAssertionHelper() # Create ElementTree Assertion Element assertionElem = AssertionElementTree.toXML(assertion) self.assert_(ElementTree.iselement(assertionElem)) # Serialise to output xmlOutput = prettyPrint(assertionElem) print("\n"+"_"*80) print(xmlOutput) print("_"*80) assertionStream = StringIO() assertionStream.write(xmlOutput) assertionStream.seek(0) tree = ElementTree.parse(assertionStream) elem2 = tree.getroot() assertion2 = AssertionElementTree.fromXML(elem2) self.assert_(assertion2)