Skip to content

Commit

Permalink
Fix incorrect validation of sumary table type environment variable (#578
Browse files Browse the repository at this point in the history
)
  • Loading branch information
andrcuns authored Nov 2, 2023
1 parent d712172 commit 74814ac
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/allure_report_publisher/lib/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 74814ac

Please sign in to comment.