class TestActPassword

Public Instance Methods

test_password() click to toggle source
# File vendor/qwik/lib/qwik/act-password.rb, line 82
def test_password
  @pages = Qwik::Pages.new(@config, @dir)
  page = @pages.create('1')
  page.store('test2')

  eq 'test2', page.load
  # The text is rewrite to the text with embeded password.
  text = Qwik::Page.embed_password('take1 {{password(testpassword)}}')
  eq "take1 {{password(e16b2ab8d12314bf4efbd6203906ea6c)}}", text
  page.store(text)

  eq "e16b2ab8d12314bf4efbd6203906ea6c", page.get_password

  take2 = Qwik::Page.embed_password('take2 {{password(notcorrectpassword)}}')
  eq false, page.match_password?(take2)     # NG

  take3 = Qwik::Page.embed_password('take3 {{password(testpassword)}}')
  eq true, page.match_password?(take3)
  page.store(take3) # OK
  assert_match(/take3/, page.load)
  eq "take3 {{password(e16b2ab8d12314bf4efbd6203906ea6c)}}", page.load

  eq "e16b2ab8d12314bf4efbd6203906ea6c", page.get_password
  eq 'testpassword'.md5hex, page.get_password
  @pages.erase_all
end
test_usecase_password() click to toggle source
# File vendor/qwik/lib/qwik/act-password.rb, line 109
def test_usecase_password
  t_add_user

  page = @site.create_new
  page.store("test\n")
  res = session('/test/1.html')
  ok_in(['test'], "//div[@class='section']/p")

  res = session('/test/1.edit')
  assert_text("test\n", 'textarea')

  res = session('/test/1.save?contents=test%0A{{password(test)}}%0A')
  ok_title('Page is saved.')

  res = session('/test/1.edit')
  assert_text("test\n{{password(098f6bcd4621d373cade4e832627b4f6)}}\n",
              'textarea')

  res = session('/test/1.save?contents=t2%0A{{password(test)}}%0A')
  ok_title('Page is saved.')

  res = session('/test/1.edit')
  assert_text("t2\n{{password(098f6bcd4621d373cade4e832627b4f6)}}\n",
              'textarea')

  res = session('/test/1.save?contents=t3%0A{{password(nomatch)}}%0A')
  ok_in([[:tt, '{{password('], 'Password', [:tt, ')}}']],
        "//div[@class='section']/p")
  assert_text("t3\n{{password(nomatch)}}\n", 'textarea')

  res = session('/test/1.save?contents=t3%0A{{password(test)}}%0A')
  ok_title('Page is saved.')
  eq "t3\n{{password(098f6bcd4621d373cade4e832627b4f6)}}\n",
    page.load
end