public void ConformanceTestsIIE_11(XmlDocument policy, XmlDocument request, XmlDocument response, XmlDocument aPolicy, XmlDocument aPolicySet) { var serialize = new Xacml11ProtocolSerializer(); XacmlContextRequest requestData; XacmlContextResponse responseData; XacmlPolicy aPolicyData; XacmlPolicySet aPolicySetData; using (XmlReader reader = XmlReader.Create(new StringReader(request.OuterXml))) { requestData = serialize.ReadContextRequest(reader); } using (XmlReader reader = XmlReader.Create(new StringReader(response.OuterXml))) { responseData = serialize.ReadContextResponse(reader); } using (XmlReader reader = XmlReader.Create(new StringReader(aPolicy.OuterXml))) { aPolicyData = serialize.ReadPolicy(reader); } using (XmlReader reader = XmlReader.Create(new StringReader(aPolicySet.OuterXml))) { aPolicySetData = serialize.ReadPolicySet(reader); } Mock<IXacmlPolicyRepository> policyRepositoryMock = new Mock<IXacmlPolicyRepository>(); policyRepositoryMock.Setup(x => x.RequestPolicy(aPolicyData.PolicyId)).Returns(aPolicyData); policyRepositoryMock.Setup(x => x.RequestPolicySet(aPolicySetData.PolicySetId)).Returns(aPolicySetData); EvaluationEngine engine = EvaluationEngineFactory.Create(policy, policyRepositoryMock.Object); XacmlContextResponse evaluatedResponse = engine.Evaluate(requestData, request); XacmlResponseAssert(responseData, evaluatedResponse); }
public void IID030_11() { XmlDocument request = new XmlDocument(); XmlDocument response = new XmlDocument(); XmlDocument policy1 = new XmlDocument(); XmlDocument policy2 = new XmlDocument(); request.Load(Path.Combine(Xacml11TestsCases.TestCasePath, "IID030Request.xml")); response.Load(Path.Combine(Xacml11TestsCases.TestCasePath, "IID030Response.xml")); policy1.Load(Path.Combine(Xacml11TestsCases.TestCasePath, "IID030Policy1.xml")); policy2.Load(Path.Combine(Xacml11TestsCases.TestCasePath, "IID030Policy2.xml")); var serialize = new Xacml11ProtocolSerializer(); XacmlContextRequest requestData; XacmlContextResponse responseData; XacmlPolicy policy1Data; XacmlPolicy policy2Data; using (XmlReader reader = XmlReader.Create(new StringReader(request.OuterXml))) { requestData = serialize.ReadContextRequest(reader); } using (XmlReader reader = XmlReader.Create(new StringReader(response.OuterXml))) { responseData = serialize.ReadContextResponse(reader); } using (XmlReader reader = XmlReader.Create(new StringReader(policy1.OuterXml))) { policy1Data = serialize.ReadPolicy(reader); } using (XmlReader reader = XmlReader.Create(new StringReader(policy2.OuterXml))) { policy2Data = serialize.ReadPolicy(reader); } var policySet = new XacmlPolicySet(Xacml10Constants.PolicyCombiningAlgorithms.OnlyOneApplicable, new XacmlTarget()); // TODO: PolicyCombiningAlgorithms policySet.Policies.Add(policy1Data); policySet.Policies.Add(policy2Data); EvaluationEngine engine = new EvaluationEngine(policySet); XacmlContextResponse evaluatedResponse = engine.Evaluate(requestData, request); XacmlResponseAssert(responseData, evaluatedResponse); }
public void IIE003_11() { XmlDocument policy = new XmlDocument(); XmlDocument request = new XmlDocument(); XmlDocument response = new XmlDocument(); XmlDocument policy1 = new XmlDocument(); XmlDocument policy2 = new XmlDocument(); policy.Load(Path.Combine(Xacml11TestsCases.TestCasePath, "IIE003Policy.xml")); request.Load(Path.Combine(Xacml11TestsCases.TestCasePath, "IIE003Request.xml")); response.Load(Path.Combine(Xacml11TestsCases.TestCasePath, "IIE003Response.xml")); policy1.Load(Path.Combine(Xacml11TestsCases.TestCasePath, "IIE003PolicyId1.xml")); policy2.Load(Path.Combine(Xacml11TestsCases.TestCasePath, "IIE003PolicyId2.xml")); var serialize = new Xacml11ProtocolSerializer(); XacmlContextRequest requestData; XacmlContextResponse responseData; XacmlPolicy policy1Data; XacmlPolicy policy2Data; using (XmlReader reader = XmlReader.Create(new StringReader(request.OuterXml))) { requestData = serialize.ReadContextRequest(reader); } using (XmlReader reader = XmlReader.Create(new StringReader(response.OuterXml))) { responseData = serialize.ReadContextResponse(reader); } using (XmlReader reader = XmlReader.Create(new StringReader(policy1.OuterXml))) { policy1Data = serialize.ReadPolicy(reader); } using (XmlReader reader = XmlReader.Create(new StringReader(policy2.OuterXml))) { policy2Data = serialize.ReadPolicy(reader); } Mock<IXacmlPolicyRepository> policyRepositoryMock = new Mock<IXacmlPolicyRepository>(); policyRepositoryMock.Setup(x => x.RequestPolicy(policy1Data.PolicyId)).Returns(policy1Data); policyRepositoryMock.Setup(x => x.RequestPolicy(policy2Data.PolicyId)).Returns(policy2Data); policyRepositoryMock.Setup(x => x.RequestPolicySet(It.IsAny<Uri>())).Returns<XacmlPolicySet>(null); EvaluationEngine engine = EvaluationEngineFactory.Create(policy, policyRepositoryMock.Object); XacmlContextResponse evaluatedResponse = engine.Evaluate(requestData, request); XacmlResponseAssert(responseData, evaluatedResponse); }