Skip to content

Commit

Permalink
Use correct filetype for malicious consent forms in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
monotypical committed Jan 27, 2025
1 parent 5bc1cc5 commit 80e4a9c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
2 changes: 1 addition & 1 deletion spec/support/unaccompanied_minor_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ def uam_enter_minors_contact_details(email: nil, confirm_email: nil, telephone:
end

def make_malicious_file
file = Tempfile.new('malicious-test-file')
file = Tempfile.new(['malicious-test-file', '.pdf'])
# We need to construct the EICAR test string from multiple parts because if it appears in it's entirely in the
# source file our dev machine's AV will be unhappy
file.write('X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-' + 'STANDARD-ANTIVIRUS-TEST-FILE!$H+H*')
Expand Down
28 changes: 19 additions & 9 deletions spec/system/unaccompanied_minor_file_upload_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,16 @@

expect(page).to have_content("Upload the UK sponsorship arrangement consent form")

malicious_file = make_malicious_file
attach_file("unaccompanied-minor-uk-parental-consent-field", malicious_file.path)
click_button("Continue")

expect(page).to have_content(malicious_file_message)
begin
malicious_file = make_malicious_file
attach_file("unaccompanied-minor-uk-parental-consent-field", malicious_file.path)
click_button("Continue")

expect(page).to have_content(malicious_file_message)
ensure
malicious_file.close
malicious_file.unlink
end
end

it "gets rejected trying to upload a malicious UK consent form" do
Expand All @@ -89,11 +94,16 @@

expect(page).to have_content("Upload the Ukraine certified consent form")

malicious_file = make_malicious_file
attach_file("unaccompanied-minor-ukraine-parental-consent-field", malicious_file.path)
click_button("Continue")
begin
malicious_file = make_malicious_file
attach_file("unaccompanied-minor-ukraine-parental-consent-field", malicious_file.path)
click_button("Continue")

expect(page).to have_content(malicious_file_message)
expect(page).to have_content(malicious_file_message)
ensure
malicious_file.close
malicious_file.unlink
end
end
end
end

0 comments on commit 80e4a9c

Please sign in to comment.