-
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.
WP-547: case insensitive email in GET tickets (#944)
* WP-547: case insensitive email in GET tickets * Do not assume ticket fields are a list. * lint fix * Fix redundancy
- Loading branch information
1 parent
da11ca2
commit 461e53c
Showing
2 changed files
with
70 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 |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
from django.http import HttpResponse | ||
from django.http import HttpRequest | ||
from portal.apps.tickets.utils import get_recaptcha_verification | ||
from portal.apps.tickets import rtUtil | ||
|
||
|
||
@pytest.fixture(autouse=True) | ||
|
@@ -46,3 +47,61 @@ def test_get_recaptcha_verification(mocker, requests_mock, regular_user): | |
request.POST['recaptchaResponse'] = 'string' | ||
result = get_recaptcha_verification(request) | ||
assert result['success'] == recaptchaSuccess['success'] | ||
|
||
|
||
class RtUtilTestable(rtUtil.DjangoRt): | ||
''' | ||
Tester for rtUtil.DjangoRt. | ||
''' | ||
|
||
def __init__(self, tracker): | ||
# Set the attributes directly | ||
self.rtHost = 'mock_host' | ||
self.rtUn = 'mock_rt_user' | ||
self.rtPw = 'mock_pw' | ||
self.rtQueue = '' | ||
self.tracker = tracker | ||
|
||
|
||
@pytest.fixture | ||
def rt_ticket(request): | ||
return request.param | ||
|
||
|
||
@pytest.fixture | ||
def mock_tracker(mocker, rt_ticket): | ||
mock_tracker = mocker.MagicMock() | ||
mock_tracker.get_ticket.return_value = rt_ticket | ||
yield mock_tracker | ||
|
||
|
||
@pytest.mark.parametrize('rt_ticket', [ | ||
{'id': 1, 'Requestors': ["[email protected]", "[email protected]"], 'Cc': []}, | ||
{'id': 1, 'Requestors': "[email protected],[email protected]", 'Cc': []}, | ||
{'id': 1, 'Requestors': ["[email protected]", "[email protected]"], 'Cc': []}], indirect=True) | ||
def test_rt_hasaccess_requestors_or_cc(mock_tracker): | ||
rtTester = RtUtilTestable(mock_tracker) | ||
assert rtTester.hasAccess(1, '[email protected]') is True | ||
assert rtTester.hasAccess(1, '[email protected]') is True | ||
|
||
|
||
@pytest.mark.parametrize('rt_ticket', [ | ||
{'id': 1, 'Requestors': ["[email protected]"], 'Cc': ["[email protected]", "[email protected]"]}, | ||
{'id': 1, 'Requestors': ["[email protected]"], 'Cc': "[email protected],[email protected]"}, | ||
{'id': 1, 'Requestors': ["[email protected]"], 'Cc': ["[email protected]", "[email protected]"]}, | ||
{'id': 1, 'Cc': ["[email protected]", "[email protected]"]}, | ||
{'id': 1, 'Requestors': [], 'Cc': ["[email protected]", "[email protected]"]}], indirect=True) | ||
def test_rt_hasaccess_cc(mock_tracker): | ||
rtTester = RtUtilTestable(mock_tracker) | ||
assert rtTester.hasAccess(1, '[email protected]') is True | ||
assert rtTester.hasAccess(1, '[email protected]') is True | ||
|
||
|
||
@pytest.mark.parametrize('rt_ticket', [ | ||
{'id': 1, 'Requestors': ["[email protected]"], 'Cc': ["[email protected]"]}, | ||
{'id': 1, 'Requestors': ["[email protected]"], 'Cc': ["[email protected]"]}, | ||
{'id': 1}, | ||
{'id': 1, 'Requestors': [], 'Cc': []}], indirect=True) | ||
def test_rt_hasnoaccess(mock_tracker): | ||
rtTester = RtUtilTestable(mock_tracker) | ||
assert rtTester.hasAccess(1, '[email protected]') is False |