Mercurial > p > roundup > code
comparison test/test_liveserver.py @ 7983:dd229bbdd32d
issue 2551353 - add roundup-classhelper
Add test for rest/data/user/roles endpoint. Fix allow header returned
from endpoint to allow GET only.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Wed, 22 May 2024 19:36:00 -0400 |
| parents | 22354d7fc94a |
| children | 60c98a8a23bd |
comparison
equal
deleted
inserted
replaced
| 7982:5f1e26f93b09 | 7983:dd229bbdd32d |
|---|---|
| 681 'Origin': "http://localhost:9001",}) | 681 'Origin': "http://localhost:9001",}) |
| 682 print(f.status_code) | 682 print(f.status_code) |
| 683 print(f.headers) | 683 print(f.headers) |
| 684 | 684 |
| 685 self.assertEqual(f.status_code, 404) | 685 self.assertEqual(f.status_code, 404) |
| 686 | |
| 687 def test_rest_endpoint_user_roles(self): | |
| 688 # use basic auth for rest endpoint | |
| 689 f = requests.get(self.url_base() + '/rest/data/user/roles', | |
| 690 auth=('admin', 'sekrit'), | |
| 691 headers = {'content-type': "", | |
| 692 'Origin': "http://localhost:9001", | |
| 693 }) | |
| 694 print(f.status_code) | |
| 695 print(f.headers) | |
| 696 | |
| 697 self.assertEqual(f.status_code, 200) | |
| 698 expected = { 'Access-Control-Expose-Headers': 'X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-RateLimit-Limit-Period, Retry-After, Sunset, Allow', | |
| 699 'Access-Control-Allow-Credentials': 'true', | |
| 700 'Allow': 'GET', | |
| 701 } | |
| 702 # use dict comprehension to remove fields like date, | |
| 703 # content-length etc. from f.headers. | |
| 704 self.assertDictEqual({ key: value for (key, value) in f.headers.items() if key in expected }, expected) | |
| 705 | |
| 706 content = json.loads(f.content) | |
| 707 | |
| 708 self.assertEqual(3, len(json.loads(f.content)['data']['collection'])) | |
| 709 | |
| 686 | 710 |
| 687 def test_ims(self): | 711 def test_ims(self): |
| 688 ''' retreive the user_utils.js file with old and new | 712 ''' retreive the user_utils.js file with old and new |
| 689 if-modified-since timestamps. | 713 if-modified-since timestamps. |
| 690 ''' | 714 ''' |
