-
Notifications
You must be signed in to change notification settings - Fork 0
/
cors_test.go
40 lines (35 loc) · 822 Bytes
/
cors_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package tusd_test
import (
"net/http"
"testing"
. "github.com/tus/tusd"
)
func TestCORS(t *testing.T) {
handler, _ := NewHandler(Config{})
(&httpTest{
Name: "Preflight request",
Method: "OPTIONS",
ReqHeader: map[string]string{
"Origin": "tus.io",
},
Code: http.StatusNoContent,
ResHeader: map[string]string{
"Access-Control-Allow-Headers": "",
"Access-Control-Allow-Methods": "",
"Access-Control-Max-Age": "",
"Access-Control-Allow-Origin": "tus.io",
},
}).Run(handler, t)
(&httpTest{
Name: "Actual request",
Method: "GET",
ReqHeader: map[string]string{
"Origin": "tus.io",
},
Code: http.StatusMethodNotAllowed,
ResHeader: map[string]string{
"Access-Control-Expose-Headers": "",
"Access-Control-Allow-Origin": "tus.io",
},
}).Run(handler, t)
}