31 lines
820 B
Go
31 lines
820 B
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")
|
|
}
|
|
}
|
|
}
|