OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Set up test bucket for direct uploads on initializer
Oliver Günthera3ab5a5b5e62
diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rbindex e3b844bc760..4a5cb31b105 100644--- a/config/initializers/content_security_policy.rb+++ b/config/initializers/content_security_policy.rb@@ -67,11 +67,19 @@ Rails.application.config.after_initialize doassets_src += ["https://www.ssa.gov"]end+ form_action = default_src++ # Allow test s3 bucket for direct uploads in tests+ if Rails.env.test?+ connect_src += ["test-bucket.s3.amazonaws.com"]+ form_action += ["test-bucket.s3.amazonaws.com"]+ end+# Configure CSP directivespolicy.default_src(*default_src)policy.base_uri("'self'")policy.font_src(*assets_src, "data:", "'self'")- policy.form_action(*default_src)+ policy.form_action(*form_action)policy.frame_src(*frame_src, "'self'")policy.frame_ancestors("'self'")policy.img_src("*", "data:", "blob:")diff --git a/spec/support/shared/with_direct_uploads.rb b/spec/support/shared/with_direct_uploads.rbindex c82a1288070..302dd0b5677 100644--- a/spec/support/shared/with_direct_uploads.rb+++ b/spec/support/shared/with_direct_uploads.rb@@ -64,25 +64,7 @@ class WithDirectUploadsdef around(example)example.metadata[:javascript_driver] = example.metadata[:driver] = :chrome_billy-- # Temporarily modify CSP for direct uploads testing- original_csp = Rails.application.config.content_security_policy-- Rails.application.config.content_security_policy do |policy|- # Copy existing policy and add test bucket domain- original_csp.call(policy) if original_csp-- # Add test bucket to connect_src and form_action for direct uploads- policy.connect_src(*(policy.instance_variable_get(:@directives)[:connect_src] || []), "test-bucket.s3.amazonaws.com")- policy.form_action(*(policy.instance_variable_get(:@directives)[:form_action] || []), "test-bucket.s3.amazonaws.com")- end-- begin- example.run- ensure- # Restore original CSP configuration- Rails.application.config.content_security_policy = original_csp- end+ example.runenddef mock_attachment