updated get_cookies rspecs

bug/bundler_fix
FireFart 2013-09-25 22:56:13 +02:00
parent 437bc821c0
commit 3d28003285
1 changed files with 85 additions and 23 deletions

View File

@ -82,31 +82,93 @@ Content-Type: text/html; charset=utf-8
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'
get_cookies_test_5 ='
HTTP/1.1 200 OK
Date: Wed, 25 Sep 2013 20:29:23 GMT
Server: Apache/2.2.22 (Ubuntu)
X-Powered-By: PHP/5.4.9-4ubuntu2.2
Expires: Wed, 11 Jan 1984 05:00:00 GMT
Last-Modified: Wed, 25 Sep 2013 20:29:23 GMT
Cache-Control: no-cache, must-revalidate, max-age=0
Pragma: no-cache
Set-Cookie: wordpressuser_a97c5267613d6de70e821ff82dd1ab94=admin; path=/wordpress-2.0/, wordpresspass_a97c5267613d6de70e821ff82dd1ab94=c3284d0f94606de1fd2af172aba15bf3; path=/wordpress-2.0/
Vary: Accept-Encoding
Content-Length: 0
Content-Type: text/html; charset=UTF-8
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'
describe Rex::Proto::Http::Response do
R = Rex::Proto::Http::Response
it "get_cookies returns empty string for no Set-Cookies" do
resp = R.new()
resp.parse(get_cookies_test_1)
resp.get_cookies.should eq("")
end
R = Rex::Proto::Http::Response
it 'get_cookies returns empty string for no Set-Cookies' do
resp = R.new()
resp.parse(get_cookies_test_1)
resp.get_cookies.should eq('')
end
it "get_cookies returns 5 cookies for test 2" do
resp = R.new()
resp.parse(get_cookies_test_2)
resp.get_cookies.split(';').count.should eq(5)
end
it 'get_cookies returns 5 cookies for test 2' do
resp = R.new()
resp.parse(get_cookies_test_2)
cookies = resp.get_cookies
cookies.should_not be_nil
cookies.should_not be ''
cookies_array = cookies.split(';').map(&:strip)
cookies_array.count.should eq(5)
cookies_array.should =~ %w(
pma_lang=en
pma_collation_connection=utf8_general_ci
pma_mcrypt_iv=mF1NmTE64IY%3D
phpMyAdmin=fmilioji5cn4m8bo5vjrrr6q9cada954
phpMyAdmin=gpjif0gtpqbvfion91ddtrq8p8vgjtue
)
end
it "get_cookies returns 5 cookies for test 3 and parses full cookie" do
resp = R.new()
resp.parse(get_cookies_test_3)
resp.get_cookies.split(';').count.should eq(5)
resp.get_cookies.include?("superC00kie!=stupidcookie;").should be_true
end
it 'get_cookies returns 5 cookies for test 3 and parses full cookie' do
resp = R.new()
resp.parse(get_cookies_test_3)
cookies = resp.get_cookies
cookies.should_not be_nil
cookies.should_not be ''
cookies_array = cookies.split(';').map(&:strip)
cookies_array.count.should eq(5)
cookies_array.should =~ %w(
pma_lang=en
pma_collation_connection=utf8_general_ci
pma_mcrypt_iv=mF1NmTE64IY%3D
phpMyAdmin=fmilioji5cn4m8bo5vjrrr6q9cada954
superC00kie!=stupidcookie
)
end
it "get_cookies returns 5 cookies for test 4 and parses empty value" do
resp = R.new()
resp.parse(get_cookies_test_4)
resp.get_cookies.split(';').count.should eq(5)
resp.get_cookies.include?("phpMyAdmin=;").should be_true
end
it 'get_cookies returns 5 cookies for test 4 and parses empty value' do
resp = R.new()
resp.parse(get_cookies_test_4)
cookies = resp.get_cookies
cookies.should_not be_nil
cookies.should_not be ''
cookies_array = cookies.split(';').map(&:strip)
cookies_array.count.should eq(5)
cookies_array.should =~ %w(
pma_lang=en
pma_collation_connection=utf8_general_ci
pma_mcrypt_iv=mF1NmTE64IY%3D
phpMyAdmin=
phpMyAdmin=gpjif0gtpqbvfion91ddtrq8p8vgjtue
)
end
it 'parses multiple cookies in one Set-Cookie header correctly' do
resp = R.new()
resp.parse(get_cookies_test_5)
cookies = resp.get_cookies
cookies.should_not be_nil
cookies.should_not be ''
cookies_array = cookies.split(';').map(&:strip)
cookies_array.count.should eq(2)
cookies_array.should =~ %w(
wordpressuser_a97c5267613d6de70e821ff82dd1ab94=admin
wordpresspass_a97c5267613d6de70e821ff82dd1ab94=c3284d0f94606de1fd2af172aba15bf3
)
end
end