mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
feat(rpc): support jsonp callbacks
This change introduces alternate rendering of text/javascript JSONP-compatible callback content. The `examples/jsonp.html` HTML document can be used to test this functionality against a running aurweb server. Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
05e6cfca62
commit
12b4269ba8
3 changed files with 107 additions and 7 deletions
|
@ -1,3 +1,5 @@
|
|||
import re
|
||||
|
||||
from http import HTTPStatus
|
||||
from unittest import mock
|
||||
|
||||
|
@ -610,3 +612,15 @@ def test_rpc_search_checkdepends():
|
|||
def test_rpc_incorrect_by():
|
||||
response = make_request("/rpc?v=5&type=search&by=fake&arg=big")
|
||||
assert response.json().get("error") == "Incorrect by field specified."
|
||||
|
||||
|
||||
def test_rpc_jsonp_callback():
|
||||
""" Test the callback parameter.
|
||||
|
||||
For end-to-end verification, the `examples/jsonp.html` file can be
|
||||
used to submit jsonp callback requests to the RPC.
|
||||
"""
|
||||
response = make_request(
|
||||
"/rpc?v=5&type=search&arg=big&callback=jsonCallback")
|
||||
assert response.headers.get("content-type") == "text/javascript"
|
||||
assert re.search(r'^/\*\*/jsonCallback\(.*\)$', response.text) is not None
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue