class TestActGetPass

Public Instance Methods

nu_test_obsolete_format() click to toggle source
# File vendor/qwik/lib/qwik/act-getpass.rb, line 221
def nu_test_obsolete_format
  t_add_user
  res = session '/test/GetPass.html'
  ok_in ['Get Password'], 'title'
end
test_open_site() click to toggle source
# File vendor/qwik/lib/qwik/act-getpass.rb, line 227
def test_open_site
  t_site_open

  # You can see the page.
  res = session '/test/.getpass'
  ok_title 'Get Password'

  # You can get any pass.
  res = session '/test/.getpass?mail=user@e.com'
  ok_title 'Send Password done'

  res = session '/test/.getpass?mail=guest@example.com'
  ok_title 'Send Password done'
end
test_private_site() click to toggle source
# File vendor/qwik/lib/qwik/act-getpass.rb, line 131
    def test_private_site
      # Try to see a get password page, but you can't.
      res = session '/test/.getpass'
      ok_title 'Members Only'

      # But you can see the page without login.
      res = session('/test/.getpass') {|req|
        req.cookies.clear
      }
      ok_title 'Get Password'

      t_add_user
      eq ",user@e.com,\n", @site['_SiteMember'].load
      eq false, @site.is_open?

      # See get password page.
      res = session '/test/.getpass'
      ok_title 'Get Password'
      ok_in ['Get Password'], 'h1'
      ok_xp [:input, {:istyle=>'3', :size=>'40', :class=>'focus',
          :name=>'mail'}], '//input'
      ok_xp [:input, {:value=>'Send', :type=>'submit'}], '//input[2]'

      # Invalid mail address
      res = session '/test/.getpass?mail=wrong@mail@address'
      ok_title 'Invalid mail address'

      # You can not get pass if you are not a member.
      res = session '/test/.getpass?mail=guest@example.com'
      ok_title 'Members Only'

      # Input your mail address
      res = session '/test/.getpass?mail=user@e.com'
      ok_title 'Send Password done'
      ok_in ['user@e.com'], 'em'
      eq ['test@q.example.com', 'user@e.com'], $smtp_sendmail[2..3]
      assert_match /user@e.com/, $smtp_sendmail[4]
      assert_match /95988593/, $smtp_sendmail[4]
      header =
"From: test@q.example.com
To: user@e.com
Subject: Your password: http://example.com
Content-Type: text/plain; charset=\"ISO-2022-JP\"

"
      body = 'This is your user name and password: http://example.com

Username:       user@e.com
Password:       95988593

Please access login page http://example.com/test/.login

You can input the user name and password from this URL automatically.
http://example.com/test/.login?user=user@e.com&pass=95988593

'.set_sourcecode_charset
      eq header+body.to_mail_charset, $smtp_sendmail[4]

      # Input your mail address in Japanese mode.
      res = session('/test/.getpass?mail=user@e.com') {|req|
        req.accept_language = ['ja']
      }
      ok_title 'パスワード送信完了'
      ok_in ['user@e.com'], 'em'
      eq ['test@q.example.com', 'user@e.com'], $smtp_sendmail[2..3]
      assert_match /user@e.com/, $smtp_sendmail[4]
      assert_match /95988593/, $smtp_sendmail[4]
      header =
"From: test@q.example.com
To: user@e.com
Subject: =?ISO-2022-JP?B?GyRCJVElOSVvITwlSRsoQiA=?=: http://example.com
Content-Type: text/plain; charset=\"ISO-2022-JP\"

"
      body =
'このサイトにおけるユーザ名とパスワードです : http://example.com

ユーザ名:   user@e.com
パスワード:  95988593

ログインページにアクセスしてください : http://example.com/test/.login

下記URLにアクセスすると、自動的にユーザー名とパスワードを入力します。
http://example.com/test/.login?user=user@e.com&pass=95988593

'.set_sourcecode_charset
      str = header+body.to_mail_charset
      eq str, $smtp_sendmail[4]
    end