From a512d0d5be495df661229cbc0ebd3e36b7f623a1 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Thu, 30 May 2024 14:17:10 -0700 Subject: [PATCH] Improved tests --- test/click_test.rb | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/test/click_test.rb b/test/click_test.rb index c15580d..bf2ac91 100644 --- a/test/click_test.rb +++ b/test/click_test.rb @@ -46,12 +46,28 @@ def test_invalid_redirect_url end end - def test_legacy_signature + def test_secret_token_signature + get AhoyEmail::Engine.routes.url_helpers.click_path(c: "test", s: "1xjjEyEbkRSohoe0RpWUYAeDNthXDDNdaKFtCJp5lyg", t: "123", u: "https://example.org") + assert_redirected_to "https://example.org" + end + + def test_legacy_secret_token_signature + get AhoyEmail::Engine.routes.url_helpers.click_path(c: "test", s: "ncBvGv-Q804GPmVf1JzHm767cx4CmGLrc1mwR0KFnLY", t: "123", u: "https://example.org") + assert_redirected_to "https://example.org" + end + + def test_legacy_secret_token_bad_signature + get AhoyEmail::Engine.routes.url_helpers.click_path(c: "test", s: "bad", t: "123", u: "https://example.org") + assert_response :not_found + assert_equal "Link expired", response.body + end + + def test_legacy_route_signature get AhoyEmail::Engine.routes.url_helpers.click_message_path("123", signature: "d77812b6f1406cff37c4ee6fcfc744b986281c5c", url: "https://example.org") assert_redirected_to "https://example.org" end - def test_legacy_bad_signature + def test_legacy_route_bad_signature get AhoyEmail::Engine.routes.url_helpers.click_message_path("123", signature: "bad", url: "https://example.org") assert_response :not_found assert_equal "Link expired", response.body