public void ConfirmanceTests_20(XmlDocument policy, XmlDocument request, XmlDocument response, Type expectedException)
        {
            var serialize = new Xacml20ProtocolSerializer();
            XacmlContextRequest  requestData;
            XacmlContextResponse responseData;

            Action action = () => {
                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);
                }

                EvaluationEngine     engine            = EvaluationEngineFactory.Create(policy, null);
                XacmlContextResponse evaluatedResponse = engine.Evaluate(requestData, request);
                XacmlResponseAssert(responseData, evaluatedResponse);
            };

            if (expectedException != null)
            {
                Assert.That(() => action(), Throws.TypeOf(expectedException));
            }
            else
            {
                action();
            }
        }
        public void EvaluateRun()
        {
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load(@"..\..\..\_Data\XACML_Samples\2.0\EvaluationSampleRequest.xml"); //c:\aa.xml

            var serialize = new Xacml20ProtocolSerializer();

            using (XmlReader reader = XmlReader.Create(new StringReader(xmlDoc.OuterXml))) {  // string data = reader.ReadOuterXml();
                var data = serialize.ReadContextRequest(reader);


                XmlDocument xmlDoc2 = new XmlDocument();
                xmlDoc2.Load(@"..\..\..\_Data\XACML_Samples\2.0\EvaluationSamplePolicy.xml"); //c:\aa.xml

                var serialize2 = new Xacml20ProtocolSerializer();

                using (XmlReader reader2 = XmlReader.Create(new StringReader(xmlDoc2.OuterXml))) {
                    var data2 = serialize2.ReadPolicy(reader2);

                    //EvaluationEngine engine = new EvaluationEngine(data2);
                    //engine.Evaluate(data);

                    Assert.IsNotNull(data);
                }

                Assert.IsNotNull(data);
            }
        }
        public void IIE003_20()
        {
            XmlDocument policy   = new XmlDocument();
            XmlDocument request  = new XmlDocument();
            XmlDocument response = new XmlDocument();

            XmlDocument policy1 = new XmlDocument();
            XmlDocument policy2 = new XmlDocument();

            policy.Load(Path.Combine(Xacml20TestsCases.TestCasePath, "IIE003Policy.xml"));
            request.Load(Path.Combine(Xacml20TestsCases.TestCasePath, "IIE003Request.xml"));
            response.Load(Path.Combine(Xacml20TestsCases.TestCasePath, "IIE003Response.xml"));
            policy1.Load(Path.Combine(Xacml20TestsCases.TestCasePath, "IIE003PolicyId1.xml"));
            policy2.Load(Path.Combine(Xacml20TestsCases.TestCasePath, "IIE003PolicyId2.xml"));

            var serialize = new Xacml20ProtocolSerializer();
            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 policyRepositoryMock = Substitute.For <IXacmlPolicyRepository>();

            policyRepositoryMock.RequestPolicy(Arg.Is(policy1Data.PolicyId)).Returns(policy1Data);
            policyRepositoryMock.RequestPolicy(Arg.Is(policy2Data.PolicyId)).Returns(policy2Data);
            policyRepositoryMock.RequestPolicySet(Arg.Any <Uri>()).Returns((XacmlPolicySet)null);

            EvaluationEngine engine = EvaluationEngineFactory.Create(policy, policyRepositoryMock);

            XacmlContextResponse evaluatedResponse = engine.Evaluate(requestData, request);

            XacmlResponseAssert(responseData, evaluatedResponse);
        }
        public void IID030_20()
        {
            XmlDocument request  = new XmlDocument();
            XmlDocument response = new XmlDocument();

            XmlDocument policy1 = new XmlDocument();
            XmlDocument policy2 = new XmlDocument();

            request.Load(Path.Combine(Xacml20TestsCases.TestCasePath, "IID030Request.xml"));
            response.Load(Path.Combine(Xacml20TestsCases.TestCasePath, "IID030Response.xml"));
            policy1.Load(Path.Combine(Xacml20TestsCases.TestCasePath, "IID030Policy1.xml"));
            policy2.Load(Path.Combine(Xacml20TestsCases.TestCasePath, "IID030Policy2.xml"));

            var serialize = new Xacml20ProtocolSerializer();
            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 ConfirmanceTestsIIE_20(XmlDocument policy, XmlDocument request, XmlDocument response, XmlDocument aPolicy, XmlDocument aPolicySet)
        {
            var serialize = new Xacml20ProtocolSerializer();
            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);
            }

            var policyRepositoryMock = Substitute.For <IXacmlPolicyRepository>();

            policyRepositoryMock.RequestPolicy(Arg.Is(aPolicyData.PolicyId)).Returns(aPolicyData);
            policyRepositoryMock.RequestPolicySet(Arg.Is(aPolicySetData.PolicySetId)).Returns(aPolicySetData);

            EvaluationEngine engine = EvaluationEngineFactory.Create(policy, policyRepositoryMock);

            XacmlContextResponse evaluatedResponse = engine.Evaluate(requestData, request);

            XacmlResponseAssert(responseData, evaluatedResponse);
        }