public void check_for_authorise_finds_derived_authorization_attributes() { var controllerViewer = new TypeViewer(typeof(AnalyticsDataController)); controllerViewer.CheckForAuthorise(ControllerType.WebAPI) .ShouldBeTrue(); }
private SitecoreService BuildSitecoreService(Type controllerType) { var controller = new TypeViewer(controllerType); var service = new SitecoreService { Name = RemoveControllerSuffix(controllerType.FullName), Url = GetRouteFromType(controllerType), Definition = controller.ToJson(), CsrfProtection = controller.CheckForMitigations(ControllerType.WebAPI), Authorise = controller.CheckForAuthorise(ControllerType.WebAPI) }; var entityService = controllerType.GetGenericInterface(typeof(IEntityService <>)); if (entityService != null) { var pocoObject = entityService.GetGenericArguments()[0]; service.IsEntityService = true; service.Metadata = GetMetadata(pocoObject); } return(service); }
private static Controller BuildController(ControllerWrapper wrapper) { System.Diagnostics.Debug.Assert(wrapper.ControllerType.HasValue); var typeViewer = new TypeViewer(wrapper.Type); return(new Controller( wrapper.Type.FullName, wrapper.ControllerType.Value, typeViewer.ToJson(), typeViewer.CheckForMitigations(wrapper.ControllerType.Value), typeViewer.CheckForAuthorise(wrapper.ControllerType.Value))); }