url_allowlist only works against DATABASE_URL
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 25/100
Hướng nghiên cứu
Bắt đầu bằng cách lần theo cách Safeguard xử lý url_allowlist và cách các cleaners được gọi, sau đó so sánh với kết nối ActiveRecord của database_cleaner-active_record. Hoàn tất nghĩa là safeguard kiểm tra kết nối thực sự được sử dụng từ database.yml hoặc DATABASE_URL thay vì chỉ dựa vào ENV['DATABASE_URL'], kể cả khi biến đó chưa được thiết lập.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
I debated filing this against database_cleaner-active_record, but after digging in a bit I think it would need a more comprehensive fix.
I have a Rails app running in a Docker stack, where under test, the database is configured the old-fashioned way in database.yml rather than with ENV['DATABASE_URL'] -- or rather, both are supported, but if DATABASE_URL isn't set, it falls back to a hard-coded value.
test:
url: <%= ENV['DATABASE_URL'] ||'postgres://root:root@db/framework-test?pool=5' %>
I wanted a safeguard that would work both with the Docker stack in CI, or for a developer setting up a test database locally or on some other database server, so I assumed I had to set url_allowlist. My first attempt was this lambda:
DatabaseCleaner.url_allowlist = [
->(url) { URI.parse(url).path.end_with?('framework-test') }
]
This blows up, though, because the URL that gets passed here is ENV['DATABASE_URL'], and URI.parse(nil) fails.
My next concern was that DatabaseCleaner would truncate the database at ENV['DATABASE_URL'] (if it exists) rather than the one ActiveRecord is actually using in tests. Thankfully database_cleaner-active_record is smarter than that, and it's using the ActiveRecord connection.
But it seems like if that's how it actually works, Safeguard should somehow hook into that, rather than relying on ENV['DATABASE_URL']. Maybe instead of running once before all cleaners, it should be run per-cleaner, and the cleaner implementations should be responsible for providing the URL they're actually using?
- Ngôn ngữ chính
- Ruby
- Star
- 3k
- Fork
- 485
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Không có mẫu pull request
- Không có hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của DatabaseCleaner/database_cleaner
-
:transaction strategy: uncommitted data disappears after perform_enqueued_jobs on Rails ≥ 7.2Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 67/100
-
Cleaning of dev DBĐang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
-
Cannot truncate a table referenced in a foreign key constraint (ActiveRecord::StatementInvalid)Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
DatabaseCleaner/database_cleaner#717 · 5 bình luận · 1 reaction ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
DatabaseCleaner/database_cleaner#716 · 2 bình luận ·
Tất cả issue của DatabaseCleaner/database_cleaner
Issue tương tự
-
Add Catalan (ca) translationĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
eurosky-social/eu-haul#32 ·
-
README configuration examples use the wrong module name and describe removed Bootstrap assetsĐang mởgood first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
benbalter/add-to-org#17 ·
-
good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
benbalter/change_agent#11 ·
-
good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
benbalter/count-org-loc#20 ·
-
good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
benbalter/sitemap-parser#33 ·