Class: Mxrb::WidgetCertification
- Inherits:
-
Object
- Object
- Mxrb::WidgetCertification
- Defined in:
- lib/mxrb/widget_certification.rb
Overview
Fail-closed evidence gate for core and pluggable widgets used by an MPR. rubocop:disable Metrics
Constant Summary collapse
- CORE_WIDGET_TYPES =
%w[ Forms$DivContainer Forms$LayoutGrid Forms$LayoutGridRow Forms$LayoutGridColumn Forms$Table Forms$DynamicText Forms$Title Forms$ActionButton Forms$DataView Forms$ListView Forms$TextBox Forms$TextArea Forms$DatePicker Forms$CheckBox Forms$RadioButtonGroup Forms$FileManager Forms$GroupBox Forms$SnippetCallWidget Forms$Label Forms$TabControl Forms$StaticImageViewer Forms$ScrollContainer Forms$Placeholder Forms$SidebarToggleButton Forms$Header Forms$NavigationTree Forms$MenuBar Forms$SimpleMenuBar ].freeze
- FAILURE_MARKERS =
[ 'Could not render widget', 'An error occurred, please contact your system administrator.', 'Executing runtime operation failed for security reasons', 'Out of context', 'out of context', 'must be placed inside', 'should be placed within', 'failed to load' ].freeze
Instance Method Summary collapse
-
#initialize(path, browser_report: nil, build: true, mendix_home: nil) ⇒ WidgetCertification
constructor
A new instance of WidgetCertification.
- #run ⇒ Object
Constructor Details
#initialize(path, browser_report: nil, build: true, mendix_home: nil) ⇒ WidgetCertification
Returns a new instance of WidgetCertification.
28 29 30 31 32 33 |
# File 'lib/mxrb/widget_certification.rb', line 28 def initialize(path, browser_report: nil, build: true, mendix_home: nil) @path = File.(path) @browser_report = browser_report && File.(browser_report) @build = build @mendix_home = mendix_home end |
Instance Method Details
#run ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/mxrb/widget_certification.rb', line 35 def run started = monotonic source = Compiler::SourceModel.read(@path) inventory = (source) compilation = compile_pages(source) package_inventory = packages(inventory.fetch(:custom).map { _1.fetch(:id) }) native_build = @build ? build_web(source.version) : { status: 'not_run' } browser = browser_evidence(inventory) failures = failures(compilation, package_inventory, native_build, browser) { path: @path, mendix_version: source.version, status: failures.empty? ? 'pass' : 'fail', failures:, inventory:, packages: package_inventory, compilation:, native_build:, browser:, elapsed_seconds: (monotonic - started).round(3) } rescue StandardError => e { path: @path, status: 'fail', failures: [e.], error: { class: e.class.name, message: e. }, elapsed_seconds: (monotonic - started).round(3) } end |