forked from kiwitcms/Kiwi
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix kiwitcms#1620 add automated tests for missing coverage in tcms.rp…
…c.api.auth
- Loading branch information
1 parent
65361a7
commit ae7965b
Showing
2 changed files
with
37 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# -*- coding: utf-8 -*- | ||
# pylint: disable=attribute-defined-outside-init | ||
|
||
from xmlrpc.client import Fault as XmlRPCFault, ProtocolError | ||
from tcms.rpc.tests.utils import APITestCase | ||
|
||
|
||
class TestAuthLogin(APITestCase): | ||
"""Test Auth.login method""" | ||
|
||
def _fixture_setup(self): | ||
super()._fixture_setup() | ||
|
||
self.rpc_client.Auth.logout() | ||
|
||
def test_login_with_username(self): | ||
sesson_id = self.rpc_client.Auth.login(self.api_user.username, "api-testing") | ||
self.assertIsNotNone(sesson_id) | ||
|
||
def test_login_without_password(self): | ||
with self.assertRaisesRegex(XmlRPCFault, "Username and password is required"): | ||
self.rpc_client.Auth.login(self.api_user.username, "") | ||
|
||
def test_login_with_incorrect_password(self): | ||
with self.assertRaisesRegex(XmlRPCFault, "Wrong username or password"): | ||
self.rpc_client.Auth.login(self.api_user.username, "kiwi-password") | ||
|
||
|
||
class TestAuthLogout(APITestCase): | ||
"""Test Auth.logout method""" | ||
|
||
def test_logout(self): | ||
self.rpc_client.Auth.logout() | ||
with self.assertRaisesRegex(ProtocolError, "403 Forbidden"): | ||
# this method requires a logged-in user | ||
self.rpc_client.Bug.details("http://some.url") |