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); }
public void PDP_AuthorizeAccess_AltinnApps0003() { bool contextRequstIsEnriched = true; string testCase = "AltinnApps0003"; XacmlContextResponse contextResponeExpected = XacmlTestDataParser.ParseResponse(testCase + "Response.xml", GetAltinnAppsPath()); XacmlContextResponse xacmlResponse = SetuUpPolicyDecisionPoint(testCase, contextRequstIsEnriched); AssertionUtil.AssertEqual(contextResponeExpected, xacmlResponse); }
public void PDP_AuthorizeAccess_IIA007() { bool contextRequstIsEnriched = false; string testCase = "IIA007"; XacmlContextResponse contextResponeExpected = XacmlTestDataParser.ParseResponse(testCase + "Response.xml", GetConformancePath()); XacmlContextResponse xacmlResponse = SetuUpPolicyDecisionPoint(testCase, contextRequstIsEnriched); AssertionUtil.AssertEqual(contextResponeExpected, 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); }