@@ -1567,65 +1567,44 @@ defmodule PlausibleWeb.StatsControllerTest do
15671567 conn =
15681568 get (
15691569 conn ,
1570- "/share/#{ site . domain } ?auth=#{ link . slug } &#{ filters } "
1570+ "/share/#{ URI . encode_www_form ( site . domain ) } ?auth=#{ link . slug } &#{ filters } "
15711571 )
15721572
15731573 assert html_response ( conn , 200 ) =~ "Enter password"
15741574 html = html_response ( conn , 200 )
15751575
1576- assert html =~ ~s( action="/share/#{ link . slug } /authenticate?)
1577- assert html =~ "f=is,browser,Firefox"
1578- assert html =~ "f=is,country,EE"
1579- assert html =~ "l=EE,Estonia"
1576+ expected_action_string =
1577+ "/share/#{ URI . encode_www_form ( link . slug ) } /authenticate?auth=#{ link . slug } &#{ filters } "
15801578
1581- conn =
1582- post (
1583- conn ,
1584- "/share/#{ link . slug } /authenticate?#{ filters } " ,
1585- % { password: "password" }
1586- )
1587-
1588- expected_redirect =
1589- "/share/#{ URI . encode_www_form ( site . domain ) } /?auth=#{ link . slug } &#{ filters } "
1590-
1591- assert redirected_to ( conn , 302 ) == expected_redirect
1579+ assert text_of_attr ( html , "form" , "action" ) == expected_action_string
15921580
15931581 conn =
15941582 post (
15951583 conn ,
1596- "/share/ #{ link . slug } /authenticate? #{ filters } " ,
1584+ expected_action_string ,
15971585 % { password: "WRONG!" }
15981586 )
15991587
16001588 html = html_response ( conn , 200 )
16011589 assert html =~ "Enter password"
16021590 assert html =~ "Incorrect password"
16031591
1604- assert text_of_attr ( html , "form" , "action" ) =~ "? #{ filters } "
1592+ assert text_of_attr ( html , "form" , "action" ) == expected_action_string
16051593
16061594 conn =
16071595 post (
16081596 conn ,
1609- "/share/ #{ link . slug } /authenticate? #{ filters } " ,
1597+ expected_action_string ,
16101598 % { password: "password" }
16111599 )
16121600
1613- redirected_url = redirected_to ( conn , 302 )
1614- assert redirected_url =~ filters
1615-
1616- conn =
1617- post (
1618- conn ,
1619- "/share/#{ link . slug } /authenticate?#{ filters } " ,
1620- % { password: "password" }
1621- )
1601+ expected_redirect =
1602+ "/share/#{ URI . encode_www_form ( site . domain ) } ?auth=#{ link . slug } &#{ filters } "
16221603
1623- redirect_path = redirected_to ( conn , 302 )
1604+ assert redirected_to ( conn , 302 ) == expected_redirect
16241605
1625- conn = get ( conn , redirect_path )
1606+ conn = get ( conn , expected_redirect )
16261607 assert html_response ( conn , 200 ) =~ "stats-react-container"
1627- assert redirect_path =~ filters
1628- assert redirect_path =~ "auth=#{ link . slug } "
16291608 end
16301609 end
16311610
@@ -1651,7 +1630,7 @@ defmodule PlausibleWeb.StatsControllerTest do
16511630 expected_action_string =
16521631 "/share/#{ link . slug } /authenticate?auth=#{ link . slug } &#{ filters } &return_to=#{ deep_path } "
16531632
1654- assert html =~ ~s ( action=" #{ expected_action_string |> String . replace ( "&" , "&" ) } " )
1633+ assert text_of_attr ( html , "form" , "action" ) == expected_action_string
16551634
16561635 conn =
16571636 post (
0 commit comments