class TestActTypekey
Public Instance Methods
nutypekey_get_sitetoken()
click to toggle source
# File vendor/qwik/lib/qwik/act-typekey.rb, line 144 def nutypekey_get_sitetoken file = @config.etc_dir.path+Qwik::Action::TYPEKEY_SITETOKEN_FILE return file.read.chomp end
test_act_typekey()
click to toggle source
# File vendor/qwik/lib/qwik/act-typekey.rb, line 98 def test_act_typekey t_add_user t_site_open # OPEN site res = session # test_get_sitetoken sitetoken = @action.typekey_get_sitetoken return if sitetoken.nil? # Stop test here. eq 20, sitetoken.length # See the FrontPage. res = session '/test/' ok_title('FrontPage') # See the Login page. res = session('/test/.login') {|req| req.cookies.clear } ok_title('Login') # Redirect to TypeKey login page. res = session '/test/.typekey' eq 302, @res.status assert_match(%r|\Ahttps://www.typekey.com/t/typekey/login|, @res['Location']) meta = @res.body.get_path('//meta[2]') assert_match(%r|url=https://www.typekey.com/t/typekey/login|, meta[1][:content]) # The client returned from the TypeKey login page. begin res = session '/test/.typekey?&ts=1111111111&email=guest@example.com&name=guestexample&nick=guest&sig=ttttttttttttttttttttttttttt=:LLLLLLLLLLLLLLLLLLLLLLLLLLL=' ok_title('Verify failed.') rescue => e p 'failed.', e end begin res = session '/test/.typekey?&ts=1110026410&email=2005@eto.com&name=etocom&nick=eto&sig=tRUcIO6haAHv/vQSguPk2EijTrc=:LCUvoHCXFLaeO8SoldCKmFr2Guo=' ok_title('Time out.') rescue => e p 'failed.', e end end
test_typekey()
click to toggle source
# File vendor/qwik/lib/qwik/act-typekey.rb, line 149 def test_typekey return if $0 != __FILE__ # just only for unit test. return if ! $have_typekey res = session sitetoken = 't' tk = TypeKey.new(sitetoken, '1.1') tk.key_cache_timeout = 60 * 60 * 24 * 365 * 100 # 100years tk.key_cache_path = (@config.cache_dir.path+'typekey-publickey.txt').to_s return_url = 'http://example.com/.typekey' eq 'https://www.typekey.com/t/typekey/login?t=t&_return=http://example.com/.typekey&v=1.1', tk.get_login_url(return_url) eq 'https://www.typekey.com/t/typekey/login?t=t&need_email=1&_return=http://example.com/.typekey&v=1.1', tk.get_login_url(return_url, true) eq 'https://www.typekey.com/t/typekey/logout?_return=http://example.com/.typekey', tk.get_logout_url(return_url) begin key = tk.get_key eq ['p', 'q', 'pub_key', 'g'], key.keys rescue p 'failed' end end
test_verify()
click to toggle source
# File vendor/qwik/lib/qwik/act-typekey.rb, line 173 def test_verify return if $0 != __FILE__ # just only for unit test. return if ! $have_typekey res = session sitetoken = @action.typekey_get_sitetoken tk = TypeKey.new(sitetoken, '1.1') tk.key_cache_timeout = 60 * 60 * 24 * 365 * 100 # 100years tk.key_cache_path = (@config.cache_dir.path+'typekey-publickey.txt').to_s ts = '1111111111' email = 'guest@example.com' name = 'guestexample' nick = 'guest' sig = 'ttttttttttttttttttttttttttt=:LLLLLLLLLLLLLLLLLLLLLLLLLLL=' begin assert_raise(VerifyFailed){ result = tk.verify(email, name, nick, ts, sig) } rescue => e p 'failed', e end end