From 74814ac80e076ef7b7ec94f691334a0af1025243 Mon Sep 17 00:00:00 2001 From: Andrejs Date: Thu, 2 Nov 2023 13:44:10 +0200 Subject: [PATCH] Fix incorrect validation of sumary table type environment variable (#578) --- lib/allure_report_publisher/lib/parser.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/allure_report_publisher/lib/parser.rb b/lib/allure_report_publisher/lib/parser.rb index 9b769cbe..a52fb987 100644 --- a/lib/allure_report_publisher/lib/parser.rb +++ b/lib/allure_report_publisher/lib/parser.rb @@ -44,15 +44,21 @@ def load_options(options, parsed_options) end.compact end - def option_from_env(option) # rubocop:disable Metrics/CyclomaticComplexity + def option_from_env(option) name = "ALLURE_REPORT_#{option.name.to_s.upcase}" value = ENV[name] return if value.nil? || value.empty? return if option.boolean? && !%w[true false].include?(value) - raise(InvalidEnvValue, "#{name} contains invalid value: '#{value}'") if option.values&.none?(value) + validate_accepted_values(option, value) option.boolean? ? value == "true" : value end + + def validate_accepted_values(option, value) + return unless option.values&.none? { |v| v.to_s == value } + + raise(InvalidEnvValue, "#{name} contains invalid value: '#{value}'") + end end end end