swift/test/cors/test-account.js
Tim Burke c5152ed4d3 Add some functional CORS tests
If you've got selenium installed (and working), the whole thing can be
automated pretty well; run main.py, wait while some windows pop up (or
use xvfb-run to run things on a virtual display), then check out what
tests were run on which browsers and whether any of them failed. Exit
code is the number of failed tests.

Includes tests against:
- Account
- Containers, with various ACLs/CORS settings
- Objects
- /info
- SLOs
- DLOs
- Symlinks

Include a gate job that runs the tests in firefox.

Areas for future work:

- Install chromium and chromedriver in the gate; tests should
  automatically pick up on the fact that it's available
- Capture the web browser's console logs, too, so we can get
  more info when things go wrong

Change-Id: Ic1d3a062419f1133c6e2f00a598867d567358c9f
2021-03-01 10:09:03 -08:00

17 lines
644 B
JavaScript

import { runTests, MakeRequest, CorsBlocked } from './harness.js'
runTests('account', [
['GET', () => MakeRequest('GET', '')
// 200, but missing Access-Control-Allow-Origin
.then(CorsBlocked)],
['HEAD', () => MakeRequest('HEAD', '')
// 200, but missing Access-Control-Allow-Origin
.then(CorsBlocked)],
['POST', () => MakeRequest('POST', '')
// 200, but missing Access-Control-Allow-Origin
.then(CorsBlocked)],
['POST with meta', () => MakeRequest('POST', '', { 'X-Account-Meta-Never-Makes-It': 'preflight failed' })
// preflight 200s, but it's missing Access-Control-Allow-Origin
.then(CorsBlocked)]
])