-
Notifications
You must be signed in to change notification settings - Fork 369
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pass locale through preliminary step (#2444)
* Pass locale through preliminary step * Add Tests to validate
- Loading branch information
1 parent
2be7408
commit 94d81c1
Showing
8 changed files
with
296 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 112 additions & 0 deletions
112
test/integration/file_push/file_push_requested_locale_test.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
# frozen_string_literal: true | ||
|
||
require "test_helper" | ||
|
||
class FilePushReqLocaleTest < ActionDispatch::IntegrationTest | ||
include Devise::Test::IntegrationHelpers | ||
|
||
setup do | ||
Settings.enable_logins = true | ||
Settings.enable_file_pushes = true | ||
Rails.application.reload_routes! | ||
@luca = users(:luca) | ||
@luca.confirm | ||
sign_in @luca | ||
end | ||
|
||
teardown do | ||
sign_out :user | ||
end | ||
|
||
def test_requested_locale | ||
get new_file_push_path | ||
assert_response :success | ||
|
||
post file_pushes_path, params: { | ||
file_push: { | ||
payload: "Message", | ||
passphrase: "asdf", | ||
retrieval_step: true, | ||
files: [ | ||
fixture_file_upload("monkey.png", "image/jpeg") | ||
] | ||
} | ||
} | ||
assert_response :redirect | ||
|
||
# Preview page | ||
follow_redirect! | ||
assert_response :success | ||
assert_select "h2", "Your push has been created." | ||
|
||
# Retrieve the push with a locale | ||
push_with_locale = request.url.sub("/preview", "") + "/r?locale=es" | ||
get push_with_locale | ||
assert_response :success | ||
assert response.body.include?("<html lang=\"es\">\n") | ||
|
||
links = assert_select("a") | ||
assert_equal 1, links.count | ||
|
||
push_with_locale = links.first.attributes["href"].value | ||
get push_with_locale | ||
|
||
# Redirected to the passphrase page | ||
assert_response :redirect | ||
follow_redirect! | ||
assert_response :success | ||
assert response.body.include?("<html lang=\"es\">\n") | ||
|
||
# We should be on the passphrase page now | ||
|
||
# Validate passphrase form | ||
forms = css_select "form" | ||
assert_select "form input", 1 | ||
|
||
# Provide the value passphrase | ||
post forms.first.attributes["action"].value, params: {passphrase: "asdf"} | ||
assert_response :redirect | ||
follow_redirect! | ||
|
||
# We should be on the password#show page now | ||
assert_response :success | ||
assert response.body.include?("<html lang=\"es\">\n") | ||
end | ||
|
||
def test_requested_locale_without_passphrase | ||
get new_file_push_path | ||
assert_response :success | ||
|
||
post file_pushes_path, params: { | ||
file_push: { | ||
payload: "Message", | ||
retrieval_step: true, | ||
files: [ | ||
fixture_file_upload("monkey.png", "image/jpeg") | ||
] | ||
} | ||
} | ||
assert_response :redirect | ||
|
||
# Preview page | ||
follow_redirect! | ||
assert_response :success | ||
assert_select "h2", "Your push has been created." | ||
|
||
# Retrieve the push with a locale | ||
push_with_locale = request.url.sub("/preview", "") + "/r?locale=es" | ||
get push_with_locale | ||
assert_response :success | ||
assert response.body.include?("<html lang=\"es\">\n") | ||
|
||
links = assert_select("a") | ||
assert_equal 1, links.count | ||
|
||
push_with_locale = links.first.attributes["href"].value | ||
get push_with_locale | ||
|
||
# We should be on the password#show page now | ||
assert_response :success | ||
assert response.body.include?("<html lang=\"es\">\n") | ||
end | ||
end |
80 changes: 80 additions & 0 deletions
80
test/integration/password/password_requested_locale_test.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# frozen_string_literal: true | ||
|
||
require "test_helper" | ||
|
||
class PasswordReqLocaleTest < ActionDispatch::IntegrationTest | ||
def test_requested_locale | ||
get new_password_path | ||
assert_response :success | ||
|
||
post passwords_path, params: {password: {payload: "testpw", passphrase: "asdf", retrieval_step: true}} | ||
assert_response :redirect | ||
|
||
# Preview page | ||
follow_redirect! | ||
assert_response :success | ||
assert_select "h2", "Your push has been created." | ||
|
||
# Retrieve the push with a locale | ||
push_with_locale = request.url.sub("/preview", "") + "/r?locale=es" | ||
get push_with_locale | ||
assert_response :success | ||
assert response.body.include?("<html lang=\"es\">\n") | ||
|
||
links = assert_select("a") | ||
assert_equal 1, links.count | ||
|
||
push_with_locale = links.first.attributes["href"].value | ||
get push_with_locale | ||
|
||
# Redirected to the passphrase page | ||
assert_response :redirect | ||
follow_redirect! | ||
assert_response :success | ||
assert response.body.include?("<html lang=\"es\">\n") | ||
|
||
# We should be on the passphrase page now | ||
|
||
# Validate passphrase form | ||
forms = css_select "form" | ||
assert_select "form input", 1 | ||
|
||
# Provide the value passphrase | ||
post forms.first.attributes["action"].value, params: {passphrase: "asdf"} | ||
assert_response :redirect | ||
follow_redirect! | ||
|
||
# We should be on the password#show page now | ||
assert_response :success | ||
assert response.body.include?("<html lang=\"es\">\n") | ||
end | ||
|
||
def test_requested_locale_without_passphrase | ||
get new_password_path | ||
assert_response :success | ||
|
||
post passwords_path, params: {password: {payload: "testpw", retrieval_step: true}} | ||
assert_response :redirect | ||
|
||
# Preview page | ||
follow_redirect! | ||
assert_response :success | ||
assert_select "h2", "Your push has been created." | ||
|
||
# Retrieve the push with a locale | ||
push_with_locale = request.url.sub("/preview", "") + "/r?locale=es" | ||
get push_with_locale | ||
assert_response :success | ||
assert response.body.include?("<html lang=\"es\">\n") | ||
|
||
links = assert_select("a") | ||
assert_equal 1, links.count | ||
|
||
push_with_locale = links.first.attributes["href"].value | ||
get push_with_locale | ||
|
||
# We should be on the password#show page now | ||
assert_response :success | ||
assert response.body.include?("<html lang=\"es\">\n") | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
# frozen_string_literal: true | ||
|
||
require "test_helper" | ||
|
||
class UrlReqLocaleTest < ActionDispatch::IntegrationTest | ||
include Devise::Test::IntegrationHelpers | ||
|
||
setup do | ||
Settings.enable_logins = true | ||
Settings.enable_url_pushes = true | ||
Rails.application.reload_routes! | ||
|
||
@luca = users(:luca) | ||
@luca.confirm | ||
sign_in @luca | ||
end | ||
|
||
teardown do | ||
sign_out @luca | ||
end | ||
|
||
def test_requested_locale | ||
get new_url_path | ||
assert_response :success | ||
|
||
post urls_path, params: {url: {payload: "https://the0x00.dev", passphrase: "asdf", retrieval_step: true}} | ||
assert_response :redirect | ||
|
||
# Preview page | ||
follow_redirect! | ||
assert_response :success | ||
assert_select "h2", "Your push has been created." | ||
|
||
# Retrieve the push with a locale | ||
push_with_locale = request.url.sub("/preview", "") + "/r?locale=es" | ||
get push_with_locale | ||
assert_response :success | ||
assert response.body.include?("<html lang=\"es\">\n") | ||
|
||
links = assert_select("a") | ||
assert_equal 1, links.count | ||
|
||
push_with_locale = links.first.attributes["href"].value | ||
get push_with_locale | ||
|
||
# Redirected to the passphrase page | ||
assert_response :redirect | ||
follow_redirect! | ||
assert_response :success | ||
assert response.body.include?("<html lang=\"es\">\n") | ||
|
||
# We should be on the passphrase page now | ||
|
||
# Validate passphrase form | ||
forms = css_select "form" | ||
assert_select "form input", 1 | ||
|
||
# Provide the value passphrase | ||
post forms.first.attributes["action"].value, params: {passphrase: "asdf"} | ||
assert_response :redirect | ||
follow_redirect! | ||
|
||
# We should be then redirected to URL | ||
assert_response :redirect | ||
assert_equal "https://the0x00.dev", response.headers["Location"] | ||
end | ||
|
||
def test_requested_locale_without_passphrase | ||
get new_url_path | ||
assert_response :success | ||
|
||
post urls_path, params: {url: {payload: "https://the0x00.dev", retrieval_step: true}} | ||
assert_response :redirect | ||
|
||
# Preview page | ||
follow_redirect! | ||
assert_response :success | ||
assert_select "h2", "Your push has been created." | ||
|
||
# Retrieve the push with a locale | ||
push_with_locale = request.url.sub("/preview", "") + "/r?locale=es" | ||
get push_with_locale | ||
assert_response :success | ||
assert response.body.include?("<html lang=\"es\">\n") | ||
|
||
links = assert_select("a") | ||
assert_equal 1, links.count | ||
|
||
push_with_locale = links.first.attributes["href"].value | ||
get push_with_locale | ||
|
||
# We should be then redirected to URL | ||
assert_response :redirect | ||
assert_equal "https://the0x00.dev", response.headers["Location"] | ||
end | ||
end |