2015-02-09 18:37:06 +00:00
|
|
|
package tusd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestCORS(t *testing.T) {
|
2015-11-04 23:46:22 +00:00
|
|
|
handler, _ := NewRoutedHandler(Config{})
|
2015-02-09 18:37:06 +00:00
|
|
|
|
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
|
|
|
}
|