mirror of
https://github.com/rickbarrette/simple-aircraft-manager-rails.git
synced 2026-11-17 15:50:36 -05:00
- Refuse to start with a placeholder or short SECRET_KEY_BASE (under 32 characters); warn and fail sam:doctor under 64. .env.example no longer ships a placeholder. - First-run setup needs a one-time code printed only in the server log, so only whoever runs the server can create the admin account. - AirTrail: the server resolves the address and connects to exactly that; never the server itself or link-local addresses (cloud metadata); private-network addresses only for admins or hosts in AIRTRAIL_ALLOWED_HOSTS. - Host authorization when APP_HOST is set: APP_HOST, the APP_URL host, ALLOWED_HOSTS, localhost and IP addresses; /up exempt. A blocked name gets a short explanation instead of a blank 403. - docker-compose.direct.yml: HTTPS without a proxy via Thruster's built-in Let's Encrypt (TLS_DOMAIN). - Notes' Markdown no longer allows the unused class attribute. - README, .env.example and the user guide updated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
32 lines
1.2 KiB
Ruby
32 lines
1.2 KiB
Ruby
require "test_helper"
|
|
|
|
class SetupTest < ActionDispatch::IntegrationTest
|
|
test "first run creates admin with the code from the server log, then setup is closed" do
|
|
get root_path
|
|
assert_redirected_to new_setup_path
|
|
get new_setup_path
|
|
assert_select "input[name=setup_code]"
|
|
admin = { name: "Jane", email_address: "a@b.com", password: "test-password-123", password_confirmation: "test-password-123" }
|
|
|
|
post setup_path, params: { user: admin, setup_code: "AAAA-AAAA" }
|
|
assert_response :unprocessable_entity
|
|
assert_not User.exists?
|
|
|
|
post setup_path, params: { user: admin, setup_code: SetupCode.current.downcase.delete("-") } # forgiving about case and the dash
|
|
assert_redirected_to root_path
|
|
assert_not SetupCode.file.exist?, "the code is used up"
|
|
assert User.last.admin?
|
|
get new_setup_path
|
|
assert_redirected_to root_path
|
|
end
|
|
|
|
test "create aircraft makes creator the owner" do
|
|
user = create_user
|
|
sign_in user
|
|
post aircraft_index_path, params: { aircraft: { tail_number: "N1", tach_time: 50 } }
|
|
a = Aircraft.find_by!(tail_number: "N1")
|
|
assert_redirected_to aircraft_path(a)
|
|
assert_equal "owner", user.role_for(a)
|
|
end
|
|
end
|