public void Test_DoesAccessRuleQueryGrantAllOfType(bool expected, string reportType, string resourceType, string flags) { // Note: if alias is 'somethingInvalid', then we're expecting the test to short-circuit before even attempting to check type equality or inheritance // I.e. the system should never have the opportunity to evaluate the invalid alias, so the test should pass. StructuredQuery sq = new StructuredQuery( ); sq.RootEntity = new ResourceEntity() { ExactType = flags.Contains("exactType"), EntityTypeId = new EntityRef(reportType) }; if (flags.Contains("addSafeRel")) { sq.RootEntity.RelatedEntities = new List <EDC.ReadiNow.Metadata.Query.Structured.Entity>( ); sq.RootEntity.RelatedEntities.Add(new RelatedResource( )); } if (flags.Contains("addUnsafeRel")) { sq.RootEntity.RelatedEntities = new List <EDC.ReadiNow.Metadata.Query.Structured.Entity>(); sq.RootEntity.RelatedEntities.Add(new RelatedResource { ResourceMustExist = true }); } if (flags.Contains("addAgg")) { sq.RootEntity.RelatedEntities = new List <EDC.ReadiNow.Metadata.Query.Structured.Entity>( ); sq.RootEntity.RelatedEntities.Add(new AggregateEntity( )); } if (flags.Contains("addUnsafeCondition")) { sq.Conditions = new List <QueryCondition>( ); sq.Conditions.Add(new QueryCondition { Operator = ConditionType.Equal }); } if (flags.Contains("addUnusedCondition")) { sq.Conditions = new List <QueryCondition>( ); sq.Conditions.Add(new QueryCondition { Operator = ConditionType.Unspecified }); } if (flags.Contains("summarize")) { sq.RootEntity = new AggregateEntity( ); } bool result = QueryInspector.DoesAccessRuleQueryGrantAllOfType(sq, (new EntityRef(resourceType)).Id); Assert.That(result, Is.EqualTo(expected)); }
public void DoesAccessRuleQueryGrantAllOfTypes(bool expected, string reportType, string resourceTypes, string flags) { // Note: if alias is 'somethingInvalid', then we're expecting the test to short-circuit before even attempting to check type equality or inheritance // I.e. the system should never have the opportunity to evaluate the invalid alias, so the test should pass. StructuredQuery sq = new StructuredQuery( ); sq.RootEntity = new ResourceEntity( ) { EntityTypeId = new EntityRef(reportType) }; var types = resourceTypes.Split(',').Select(alias => (new EntityRef(alias)).Id).ToList( ); bool result = QueryInspector.DoesAccessRuleQueryGrantAllOfTypes(sq, types); Assert.That(result, Is.EqualTo(expected)); }
public void Test_IsQueryUndamaged(bool expected, string errorType) { StructuredQuery sq = new StructuredQuery( ); sq.InvalidReportInformation = new Dictionary <string, Dictionary <long, string> >(); var errors = new Dictionary <long, string>(); errors[1] = "Some error"; if (!string.IsNullOrEmpty(errorType)) { sq.InvalidReportInformation.Add(errorType, errors); } bool actual = QueryInspector.IsQueryUndamaged(sq); Assert.AreEqual(expected, actual); }
public SoapEndpointBehavior(WcfDomainClientFactory factory) { _soapQueryInspector = new QueryInspector(); _cookieInspector = factory.SharedCookieMessageInspector; }