| 1516 | } |
| 1517 | |
| 1518 | func TestOptionsRequest(t *testing.T) { |
| 1519 | t.Parallel() |
| 1520 | |
| 1521 | baseURL := startHTTP(t, apiCfg) |
| 1522 | cli := &http.Client{ |
| 1523 | Timeout: time.Second, |
| 1524 | } |
| 1525 | |
| 1526 | req, _ := http.NewRequest("OPTIONS", baseURL+"/rest/system/status", nil) |
| 1527 | resp, err := cli.Do(req) |
| 1528 | if err != nil { |
| 1529 | t.Fatal(err) |
| 1530 | } |
| 1531 | |
| 1532 | resp.Body.Close() |
| 1533 | if resp.StatusCode != http.StatusNoContent { |
| 1534 | t.Fatal("OPTIONS on /rest/system/status should succeed, not", resp.Status) |
| 1535 | } |
| 1536 | if resp.Header.Get("Access-Control-Allow-Origin") != "*" { |
| 1537 | t.Fatal("OPTIONS on /rest/system/status should return a 'Access-Control-Allow-Origin: *' header") |
| 1538 | } |
| 1539 | if resp.Header.Get("Access-Control-Allow-Methods") != "GET, POST, PUT, PATCH, DELETE, OPTIONS" { |
| 1540 | t.Fatal("OPTIONS on /rest/system/status should return a 'Access-Control-Allow-Methods: GET, POST, PUT, PATCH, DELETE, OPTIONS' header") |
| 1541 | } |
| 1542 | if resp.Header.Get("Access-Control-Allow-Headers") != "Content-Type, X-API-Key" { |
| 1543 | t.Fatal("OPTIONS on /rest/system/status should return a 'Access-Control-Allow-Headers: Content-Type, X-API-KEY' header") |
| 1544 | } |
| 1545 | } |
| 1546 | |
| 1547 | func TestEventMasks(t *testing.T) { |
| 1548 | t.Parallel() |