summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/credential-management/support/fedcm/token.py
blob: 867dab9592f89a36fd2ef6d3656046318673cf5b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
def main(request, response):
  if request.cookies.get(b"cookie") != b"1":
    return (530, [], "Missing cookie")
  if request.method != "POST":
    return (531, [], "Method is not POST")
  if request.headers.get(b"Content-Type") != b"application/x-www-form-urlencoded":
    return (532, [], "Wrong Content-Type")
  if request.headers.get(b"Accept") != b"application/json":
    return (533, [], "Wrong Accept")
  if request.headers.get(b"Sec-Fetch-Dest") != b"webidentity":
    return (500, [], "Wrong Sec-Fetch-Dest header")
  if request.headers.get(b"Referer"):
    return (534, [], "Should not have Referer")
  if not request.headers.get(b"Origin"):
    return (535, [], "Missing Origin")

  if not request.POST.get(b"client_id"):
    return (536, [], "Missing 'client_id' POST parameter")
  if not request.POST.get(b"account_id"):
    return (537, [], "Missing 'account_id' POST parameter")
  if not request.POST.get(b"disclosure_text_shown"):
    return (538, [], "Missing 'disclosure_text_shown' POST parameter")

  return "{\"token\": \"token\"}"