42 lines
1.2 KiB
Go
42 lines
1.2 KiB
Go
package system
|
|
|
|
import "testing"
|
|
|
|
func TestDefaultIgnoredAPIsIncludeSwagger(t *testing.T) {
|
|
wants := map[string]bool{
|
|
"GET /swagger/*any": false,
|
|
"GET /uploads/file/*filepath": false,
|
|
"HEAD /uploads/file/*filepath": false,
|
|
}
|
|
for _, api := range DefaultIgnoredAPIs("uploads/file") {
|
|
key := api.Method + " " + api.Path
|
|
if _, ok := wants[key]; ok {
|
|
wants[key] = true
|
|
}
|
|
}
|
|
for key, found := range wants {
|
|
if !found {
|
|
t.Fatalf("default ignored APIs do not include %s", key)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestDefaultIgnoredAPIsDoNotHideAnnouncementDataSource(t *testing.T) {
|
|
for _, api := range DefaultIgnoredAPIs("uploads/file") {
|
|
if api.Method == "GET" && api.Path == "/info/getInfoDataSource" {
|
|
t.Fatal("announcement data-source endpoint must remain protected by the normal API policy")
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestStaticFileAPIsAreIgnoredRegardlessOfConfiguredPrefix(t *testing.T) {
|
|
for _, method := range []string{"GET", "HEAD"} {
|
|
if !isStaticFileAPI(apiPO{Method: method, Path: "/files/*filepath"}) {
|
|
t.Fatalf("%s static route was not recognized", method)
|
|
}
|
|
}
|
|
if isStaticFileAPI(apiPO{Method: "POST", Path: "/files/*filepath"}) {
|
|
t.Fatal("non-read static route was incorrectly ignored")
|
|
}
|
|
}
|