Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions cloudant/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,24 @@ def __delitem__(self, name):
response = response.result()
response.raise_for_status()

def session(self, **kwargs):
"""Get current user's authentication and authorization status."""
return self.get(self._reset_path('_session'), **kwargs)

def login(self, username, password, **kwargs):
"""Authenticate the connection via cookie."""
# set headers, body explicitly
headers = {
"Content-Type": "application/x-www-form-urlencoded"
}
data = "name=%s&password=%s" % (username, password)
return self.post(self._reset_path('_session'), headers=headers,
data=data, **kwargs)

def logout(self, **kwargs):
"""De-authenticate the connection's cookie."""
return self.delete(self._reset_path('_session'), **kwargs)

def all_dbs(self, **kwargs):
"""List all databases."""
return self.get('_all_dbs', **kwargs)
Expand Down
17 changes: 0 additions & 17 deletions cloudant/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,23 +104,6 @@ def _make_request(self, method, path='', **kwargs):
**opts)
return future

def session(self, **kwargs):
"""Get current user's authentication and authorization status."""
return self.get(self._reset_path('_session'), **kwargs)

def login(self, username, password, **kwargs):
"""Authenticate the connection via cookie."""
# set headers, body explicitly
headers = {
"Content-Type": "application/x-www-form-urlencoded"
}
data = "name=%s&password=%s" % (username, password)
return self.post(self._reset_path('_session'), headers=headers, data=data, **kwargs)

def logout(self, **kwargs):
"""De-authenticate the connection's cookie."""
return self.delete(self._reset_path('_session'), **kwargs)

def head(self, path='', **kwargs):
"""
Make a HEAD request against the object's URI joined
Expand Down
4 changes: 4 additions & 0 deletions test/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,10 @@ def testMerge(self):
def testAttachment(self):
self.doc.attachment('file')

def testNoLoginLogout(self):
assert not hasattr(self.doc, 'login')
assert not hasattr(self.doc, 'logout')

def tearDown(self):
assert self.db.delete().status_code == 200

Expand Down