Skip to content

Commit

Permalink
Fix tests for newer mailpit where <> are disallowed in emails.
Browse files Browse the repository at this point in the history
  • Loading branch information
GUI committed Jan 31, 2025
1 parent 9634e4d commit 5098cf4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions config/schema.cue
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ import "path"
listen_backlog?: uint
error_log_level: string | *"notice"
api_user: {
email_regex: string | *"\\A[^@\\s]+@[^@\\s]+\\.[^@\\s]+\\z"
email_regex: string | *"\\A[^@<>\\s]+@[^@<>\\s]+\\.[^@<>\\s]+\\z"
first_name_exclude_regex: string | *"(http|https|www|<|>|\\r|\\n)"
last_name_exclude_regex: string | *"(http|https|www|<|>|\\r|\\n)"
force_public_verify_email: bool | *false
Expand All @@ -256,7 +256,7 @@ import "path"
username_is_email: bool | *true
password_length_min: uint | *14
password_length_max: uint | *72
email_regex: string | *"\\A[^@\\s]+@[^@\\s]+\\.[^@\\s]+\\z"
email_regex: string | *"\\A[^@<>\\s]+@[^@<>\\s]+\\.[^@<>\\s]+\\z"
password_regex?: string
login_header?: string
login_footer?: string
Expand Down
10 changes: 5 additions & 5 deletions test/apis/v1/users/test_create_welcome_email.rb
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ def test_html_escaping
response = Typhoeus.post("https://127.0.0.1:9081/api-umbrella/v1/users.json", http_options.deep_merge(non_admin_key_creator_api_key).deep_merge({
:headers => { "Content-Type" => "application/x-www-form-urlencoded" },
:body => {
:user => FactoryBot.attributes_for(:api_user, :email => "foo<script>&[email protected]", :first_name => "Test&First", :last_name => "Test&Last"),
:user => FactoryBot.attributes_for(:api_user, :email => "foo&[email protected]", :first_name => "Test&First", :last_name => "Test&Last"),
:options => { :send_welcome_email => true },
},
}))
Expand All @@ -309,12 +309,12 @@ def test_html_escaping
assert_match("Hi,</p>", message.fetch("HTML"))
assert_match("Hi,", message.fetch("Text"))

assert_match("Your API key for <strong>foo&lt;script&gt;&amp;[email protected]</strong> is:</p>", message.fetch("HTML"))
assert_match("Your API key for foo<script>&[email protected] is:", message.fetch("Text"))
assert_match("Your API key for <strong>foo&amp;[email protected]</strong> is:</p>", message.fetch("HTML"))
assert_match("Your API key for foo&[email protected] is:", message.fetch("Text"))

# Support footer
assert_match("Account Email: foo&lt;script&gt;&amp;[email protected]", message.fetch("HTML"))
assert_match("Account Email: foo<script>&[email protected]", message.fetch("Text"))
assert_match("Account Email: foo&amp;[email protected]", message.fetch("HTML"))
assert_match("Account Email: foo&[email protected]", message.fetch("Text"))

assert_match("Account ID: #{user.id}", message.fetch("HTML"))
assert_match("Account ID: #{user.id}", message.fetch("Text"))
Expand Down

0 comments on commit 5098cf4

Please sign in to comment.