Should close the db after extracting the cookies from it.
This commit is contained in:
parent
f764e35095
commit
7e9e160f17
4 changed files with 50 additions and 8 deletions
|
@ -11,9 +11,9 @@ module CookieExtractor
|
|||
def extract
|
||||
db = SQLite3::Database.new @cookie_file
|
||||
db.results_as_hash = true
|
||||
@result = []
|
||||
result = []
|
||||
db.execute("SELECT * FROM cookies") do |row|
|
||||
@result << [ row['host_key'],
|
||||
result << [ row['host_key'],
|
||||
true_false_word(is_domain_wide(row['host_key'])),
|
||||
row['path'],
|
||||
true_false_word(row['secure']),
|
||||
|
@ -22,7 +22,8 @@ module CookieExtractor
|
|||
row['value']
|
||||
].join("\t")
|
||||
end
|
||||
@result
|
||||
db.close
|
||||
result
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,9 +11,9 @@ module CookieExtractor
|
|||
def extract
|
||||
db = SQLite3::Database.new @cookie_file
|
||||
db.results_as_hash = true
|
||||
@result = []
|
||||
result = []
|
||||
db.execute("SELECT * FROM moz_cookies") do |row|
|
||||
@result << [ row['host'],
|
||||
result << [ row['host'],
|
||||
true_false_word(is_domain_wide(row['host'])),
|
||||
row['path'],
|
||||
true_false_word(row['isSecure']),
|
||||
|
@ -22,7 +22,8 @@ module CookieExtractor
|
|||
row['value']
|
||||
].join("\t")
|
||||
end
|
||||
@result
|
||||
db.close
|
||||
result
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,12 +2,32 @@ require File.join(File.dirname(__FILE__), "spec_helper")
|
|||
|
||||
describe CookieExtractor::ChromeCookieExtractor do
|
||||
before :each do
|
||||
@fake_cookie_db = double("cookie database", :results_as_hash= => true)
|
||||
@fake_cookie_db = double("cookie database",
|
||||
:results_as_hash= => true,
|
||||
:close => true)
|
||||
SQLite3::Database.should_receive(:new).
|
||||
with('filename').
|
||||
and_return(@fake_cookie_db)
|
||||
end
|
||||
|
||||
describe "opening and closing a sqlite db" do
|
||||
before :each do
|
||||
@fake_cookie_db.should_receive(:execute).and_yield(
|
||||
{ 'host_key' => '.dallien.net',
|
||||
'path' => '/',
|
||||
'secure' => '0',
|
||||
'expires_utc' => '1234567890',
|
||||
'name' => 'NAME',
|
||||
'value' => 'VALUE'})
|
||||
@extractor = CookieExtractor::ChromeCookieExtractor.new('filename')
|
||||
end
|
||||
|
||||
it "should close the db when finished" do
|
||||
@fake_cookie_db.should_receive(:close)
|
||||
@extractor.extract
|
||||
end
|
||||
end
|
||||
|
||||
describe "with a cookie that has a host starting with a dot" do
|
||||
before :each do
|
||||
@fake_cookie_db.should_receive(:execute).and_yield(
|
||||
|
|
|
@ -2,12 +2,32 @@ require File.join(File.dirname(__FILE__), "spec_helper")
|
|||
|
||||
describe CookieExtractor::FirefoxCookieExtractor do
|
||||
before :each do
|
||||
@fake_cookie_db = double("cookie database", :results_as_hash= => true)
|
||||
@fake_cookie_db = double("cookie database",
|
||||
:results_as_hash= => true,
|
||||
:close => true)
|
||||
SQLite3::Database.should_receive(:new).
|
||||
with('filename').
|
||||
and_return(@fake_cookie_db)
|
||||
end
|
||||
|
||||
describe "opening and closing a sqlite db" do
|
||||
before :each do
|
||||
@fake_cookie_db.should_receive(:execute).and_yield(
|
||||
{'host' => '.dallien.net',
|
||||
'path' => '/',
|
||||
'isSecure' => '0',
|
||||
'expiry' => '1234567890',
|
||||
'name' => 'NAME',
|
||||
'value' => 'VALUE'})
|
||||
@extractor = CookieExtractor::FirefoxCookieExtractor.new('filename')
|
||||
end
|
||||
|
||||
it "should close the db when finished" do
|
||||
@fake_cookie_db.should_receive(:close)
|
||||
@extractor.extract
|
||||
end
|
||||
end
|
||||
|
||||
describe "with a cookie that has a host starting with a dot" do
|
||||
before :each do
|
||||
@fake_cookie_db.should_receive(:execute).and_yield(
|
||||
|
|
Loading…
Reference in a new issue