Permalink
Browse files

get correct ssic

  • Loading branch information...
1 parent bf73766 commit 36f081839c78b0b4582229d0670f80b199841450 @flyerhzm committed Jun 1, 2010
Showing with 5 additions and 17 deletions.
  1. +3 −7 lib/rfetion/fetion.rb
  2. +2 −10 spec/rfetion/fetion_spec.rb
View
@@ -386,9 +386,7 @@ def parse_ssic(response)
raise Fetion::PasswordError.new('帐号或密码不正确') if Net::HTTPUnauthorized === response
raise Fetion::PasswordMaxError.new('您已连续输入错误密码,为了保障您的帐户安全,请输入图形验证码:') if Net::HTTPClientError === response
raise Fetion::LoginException.new('Login failed.') unless Net::HTTPSuccess === response
- raise Fetion::LoginException.new('No ssic found in cookie.') unless response['set-cookie'] =~ /ssic=(.*);/
- @ssic = $1
@logger.debug response.body
doc = Nokogiri::XML(response.body)
results = doc.root
@@ -401,6 +399,9 @@ def parse_ssic(response)
if @uri =~ /sip:(\d+)@(.+);/
@sid = $1
end
+ doc.root.xpath("/results/user/credentials/credential[@domain='fetion.com.cn']").each do |credential|
+ @ssic = credential['c']
+ end
@logger.debug "ssic: " + @ssic
@logger.debug "status_code: " + @status_code
@@ -485,11 +486,6 @@ def curl_exec(body='', url=next_url, expected=SipcMessage::OK)
contact = Fetion::Contact.parse_buddy(buddy)
@buddy_lists.find {|buddy_list| buddy_list.bid == contact.bid}.add_contact(contact)
end
- doc.root.xpath("/results/credentials/credential[@domain='fetion.com.cn']").each do |credential|
- puts "===========rijndael============"
- @ssic = rijndael(credential['c'])
- puts @ssic
- end
end
response.body.scan(%r{<events>.*?</events>}).each do |events|
@@ -62,7 +62,7 @@
@fetion.mobile_no.should == "15800681509"
@fetion.uid.should == "390937727"
@fetion.sid.should == "730020377"
- @fetion.ssic.should == "DhIOAADVEY68pV4EcRHsJ/GIIeltaYJsYJR2pj7b2+hCYLtgUd2j2mFaOqoqR98S3dm5pPH9t7W1yH5Cp/lVRP6VTwpLVvwxhhvj8qDz/p8rrW/Ljor6P4ZQKUZYz80JHjMt8R4AAA=="
+ @fetion.ssic.should == "CBIOAAAm+FiuQgpcnFi+B4PZgtvTLcLwrzk84mf5XsP9hnneRVyMvEFuPpvTyfV2FFZfhJrCoiLYptvuSd9M95fwTUj4jRE6NuiE43EPl220u/chMyebsSbsUDxSjuJh1hXV76sAAA=="
end
it "should login failed with wrong password" do
@@ -90,14 +90,7 @@
@fetion.mobile_no.should == "15800681509"
@fetion.uid.should == "390937727"
@fetion.sid.should == "730020377"
- @fetion.ssic.should == "DhIOAADVEY68pV4EcRHsJ/GIIeltaYJsYJR2pj7b2+hCYLtgUd2j2mFaOqoqR98S3dm5pPH9t7W1yH5Cp/lVRP6VTwpLVvwxhhvj8qDz/p8rrW/Ljor6P4ZQKUZYz80JHjMt8R4AAA=="
- end
-
- it "should get login exception without ssic" do
- @fetion.mobile_no = '15800681509'
- @fetion.password = 'password'
- FakeWeb.register_uri(:get, 'https://uid.fetion.com.cn/ssiportal/SSIAppSignInV4.aspx?mobileno=15800681509&domains=fetion.com.cn;m161.com.cn;www.ikuwa.cn&v4digest-type=1&v4digest=79cd56b93f21298dc8ae9d26de1258e3d6ce85a7', :body => %Q|<?xml version="1.0" encoding="utf-8" ?><results status-code="200"><user uri="sip:730020377@fetion.com.cn;p=6907" mobile-no="15800681509" user-status="101" user-id="390937727"><credentials><credential domain="fetion.com.cn" c="CBIOAAAm+FiuQgpcnFi+B4PZgtvTLcLwrzk84mf5XsP9hnneRVyMvEFuPpvTyfV2FFZfhJrCoiLYptvuSd9M95fwTUj4jRE6NuiE43EPl220u/chMyebsSbsUDxSjuJh1hXV76sAAA==" /><credential domain="m161.com.cn" c="CBAOAADowH3pYcBkGIkxcH56EXCIPEJmZ2EXyUKNoOM2xqaJ33i9d5fKaMYY9N7irpMmffobHQws5Eekiz/h+v9nuc3v6zzO8Pd0lIXzutXwzXCROw==" /><credential domain="www.ikuwa.cn" c="ChAOAABbuQDP66jvw7EVpUEjmgWcX/m+qx1KjApplisfSwro1Wp7Aj6Ngu6goEMEx4SHBj+ID4pf+shcudvrfr4C2fUJnmwovu4HZ3+Y1MvS96TtUQ==" /></credentials></user></results>|)
- lambda { @fetion.login }.should raise_exception(Fetion::LoginException)
+ @fetion.ssic.should == "CBIOAAAm+FiuQgpcnFi+B4PZgtvTLcLwrzk84mf5XsP9hnneRVyMvEFuPpvTyfV2FFZfhJrCoiLYptvuSd9M95fwTUj4jRE6NuiE43EPl220u/chMyebsSbsUDxSjuJh1hXV76sAAA=="
end
end
@@ -604,7 +597,6 @@
response_body.gsub!("\n", "\r\n")
FakeWeb.register_uri(:post, "http://221.176.31.39/ht/sd.aspx?t=s&i=11", :body => response_body)
@fetion.keep_alive
- @fetion.ssic.size.should == 140
end
end

0 comments on commit 36f0818

Please sign in to comment.