Merge pull request #3575 from VaishnaviHire/add_content_type

Validate Content-Type Header for api POST requests
This commit is contained in:
Min RK
2021-09-01 10:16:39 +02:00
committed by GitHub
2 changed files with 56 additions and 5 deletions

View File

@@ -65,7 +65,7 @@ async def test_auth_api(app):
assert r.status_code == 403
async def test_referer_check(app):
async def test_cors_checks(app):
url = ujoin(public_host(app), app.hub.base_url)
host = urlparse(url).netloc
# add admin user
@@ -110,6 +110,32 @@ async def test_referer_check(app):
)
assert r.status_code == 200
r = await api_request(
app,
'users',
method='post',
data='{}',
headers={
"Authorization": "",
"Content-Type": "text/plain",
},
cookies=cookies,
)
assert r.status_code == 403
r = await api_request(
app,
'users',
method='post',
data='{}',
headers={
"Authorization": "",
"Content-Type": "application/json; charset=UTF-8",
},
cookies=cookies,
)
assert r.status_code == 400 # accepted, but invalid
# --------------
# User API tests