Skip to content

Commit 02af203

Browse files
committed
Fix credentials handling for dump tool (issue 223).
1 parent 20a844f commit 02af203

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

couchdb/tests/tools.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@
1111
import unittest
1212
from StringIO import StringIO
1313

14-
from couchdb.tools import load
14+
from couchdb import Unauthorized
15+
from couchdb.tools import load, dump
1516
from couchdb.tests import testutil
1617

18+
1719
class ToolLoadTestCase(testutil.TempDatabaseMixin, unittest.TestCase):
1820

1921
def test_handle_credentials(self):
@@ -22,6 +24,18 @@ def test_handle_credentials(self):
2224
load.load_db(StringIO(''), self.db.resource.url, 'foo', 'bar')
2325

2426

27+
class ToolDumpTestCase(testutil.TempDatabaseMixin, unittest.TestCase):
28+
29+
def test_handle_credentials(self):
30+
# Similar to issue 194
31+
# Fixing: AttributeError: 'Resource' object has no attribute 'http'
32+
try:
33+
dump.dump_db(self.db.resource.url, 'foo', 'bar', output=StringIO())
34+
except Unauthorized:
35+
# This is ok, since we provided dummy credentials.
36+
pass
37+
38+
2539
def suite():
2640
suite = unittest.TestSuite()
2741
suite.addTest(unittest.makeSuite(ToolLoadTestCase, 'test'))

couchdb/tools/dump.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def dump_db(dburl, username=None, password=None, boundary=None,
2525
output=sys.stdout):
2626
db = Database(dburl)
2727
if username is not None and password is not None:
28-
db.resource.http.add_credentials(username, password)
28+
db.resource.credentials = username, password
2929

3030
envelope = write_multipart(output, boundary=boundary)
3131
for docid in db:

0 commit comments

Comments
 (0)