Content Security Policy for iFrame embedding

This commit is contained in:
HTWKalender Team
2024-09-20 04:25:57 -04:00
parent 3895537f4f
commit 76d464e9dd
2 changed files with 32 additions and 1 deletions

View File

@ -71,7 +71,7 @@ Rails.application.configure do
# The `child_src` directive is only a fallback for browsers not supporting `worker_src`.
policy.child_src :self, :blob
policy.form_action :self
policy.frame_ancestors :none
policy.frame_ancestors :self, 'https://*.htwk-leipzig.de'
policy.frame_src :none
policy.manifest_src :none

31
lib/cabal_adapter.rb Normal file
View File

@ -0,0 +1,31 @@
# frozen_string_literal: true
class CabalAdapter < TestingFrameworkAdapter
# Regular expressions to extract the number of test suites, test cases, and their status
COUNT_REGEXP = /(\d+) of \d+ test suites \((\d+) of \d+ test cases\)/
PASS_REGEXP = /passed/
FAIL_REGEXP = /failed/
def self.framework_name
'Haskell Cabal'
end
# Parse the output from Cabal test suite
def parse_output(output)
# Extract the total count of test suites and test cases
count_match = output[:stdout].scan(COUNT_REGEXP).last
test_cases_count = count_match&.last&.to_i || 0
# Check if the test suite passed or failed
passed = output[:stdout] =~ PASS_REGEXP
failed = output[:stdout] =~ FAIL_REGEXP
if passed
{count: test_cases_count, passed: test_cases_count}
elsif failed
{count: test_cases_count, failed: test_cases_count}
else
{count: test_cases_count, passed: 0, failed: 0}
end
end
end