2015-12-25 21:33:27 +00:00
|
|
|
package tusd_test
|
2015-02-09 18:37:06 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
"testing"
|
2015-12-25 21:33:27 +00:00
|
|
|
|
|
|
|
. "github.com/tus/tusd"
|
2015-02-09 18:37:06 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestCORS(t *testing.T) {
|
|
|
|
handler, _ := NewHandler(Config{})
|
|
|
|
|
2015-02-17 14:44:12 +00:00
|
|
|
(&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)
|
2015-02-09 18:37:06 +00:00
|
|
|
|
2015-02-17 14:44:12 +00:00
|
|
|
(&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)
|
2015-02-09 18:37:06 +00:00
|
|
|
}
|