private XacmlContextResponse SetuUpPolicyDecisionPoint(string testCase, bool contextRequstIsEnriched) { XacmlContextRequest contextRequest = XacmlTestDataParser.ParseRequest(testCase + "Request.xml", GetConformancePath()); XacmlContextRequest contextRequestEnriched = contextRequest; if (contextRequstIsEnriched) { contextRequestEnriched = XacmlTestDataParser.ParseRequest(testCase + "Request_Enriched.xml", GetConformancePath()); } Moq.Mock <IContextHandler> moqContextHandler = new Mock <IContextHandler>(); moqContextHandler.Setup(c => c.Enrich(It.IsAny <XacmlContextRequest>())).ReturnsAsync(contextRequestEnriched); Moq.Mock <IPolicyRetrievalPoint> moqPRP = new Mock <IPolicyRetrievalPoint>(); XacmlPolicy policy = null; try { policy = XacmlTestDataParser.ParsePolicy(testCase + "Policy.xml", GetConformancePath()); moqPRP.Setup(p => p.GetPolicyAsync(It.IsAny <XacmlContextRequest>())).ReturnsAsync(policy); } catch (XmlException ex) { moqPRP.Setup(p => p.GetPolicyAsync(It.IsAny <XacmlContextRequest>())).Throws(ex); } PolicyDecisionPoint pdp = new PolicyDecisionPoint(); XacmlContextResponse xacmlResponse = pdp.Authorize(contextRequestEnriched, policy); return(xacmlResponse); }
private XacmlContextResponse SetuUpPolicyDecisionPoint(string testCase, bool contextRequstIsEnriched) { XacmlContextRequest contextRequest = XacmlTestDataParser.ParseRequest(testCase + "Request.xml", GetAltinnAppsPath()); XacmlContextRequest contextRequestEnriched = contextRequest; if (contextRequstIsEnriched) { contextRequestEnriched = XacmlTestDataParser.ParseRequest(testCase + "Request_Enriched.xml", GetAltinnAppsPath()); } XacmlPolicy policy = XacmlTestDataParser.ParsePolicy(testCase + "Policy.xml", GetAltinnAppsPath()); Moq.Mock <IContextHandler> moqContextHandler = new Mock <IContextHandler>(); moqContextHandler.Setup(c => c.Enrich(It.IsAny <XacmlContextRequest>())).ReturnsAsync(contextRequestEnriched); PolicyDecisionPoint pdp = new PolicyDecisionPoint(); XacmlContextResponse xacmlResponse = pdp.Authorize(contextRequestEnriched, policy); return(xacmlResponse); }