对接
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
package routecatalog
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestLiveClientRouteVisibilityContract(t *testing.T) {
|
||||
public := []struct{ method, path string }{
|
||||
{"GET", "/live/streams"},
|
||||
{"GET", "/live/streams/:streamId"},
|
||||
{"GET", "/live/categories"},
|
||||
{"GET", "/live/rooms"},
|
||||
{"GET", "/live/rooms/:id"},
|
||||
{"POST", "/live/rooms/:id/like"},
|
||||
{"GET", "/live/rooms/:id/messages"},
|
||||
{"GET", "/live/gifts"},
|
||||
{"GET", "/live/recharge/providers"},
|
||||
{"GET", "/live/recharge/plans"},
|
||||
{"POST", "/live/client/auth/login"},
|
||||
{"POST", "/live/client/auth/register"},
|
||||
}
|
||||
for _, route := range public {
|
||||
descriptor, ok := Lookup(route.method, route.path)
|
||||
if !ok || !descriptor.Public {
|
||||
t.Errorf("%s %s must be public: found=%v descriptor=%+v", route.method, route.path, ok, descriptor)
|
||||
}
|
||||
}
|
||||
|
||||
private := []struct{ method, path string }{
|
||||
{"GET", "/live/client/me"},
|
||||
{"GET", "/live/client/balance"},
|
||||
{"POST", "/live/client/auth/logout"},
|
||||
{"GET", "/live/rooms/:id/follow"},
|
||||
{"POST", "/live/rooms/:id/follow"},
|
||||
{"DELETE", "/live/rooms/:id/follow"},
|
||||
{"POST", "/live/rooms/:id/gifts"},
|
||||
{"POST", "/live/recharge/orders"},
|
||||
{"GET", "/live/recharge/orders/:orderNo"},
|
||||
{"GET", "/live/recharge/orders/:orderNo/status"},
|
||||
}
|
||||
for _, route := range private {
|
||||
descriptor, ok := Lookup(route.method, route.path)
|
||||
if !ok || descriptor.Public {
|
||||
t.Errorf("%s %s must require login: found=%v descriptor=%+v", route.method, route.path, ok, descriptor)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestLiveMoneyChangingRoutesAreAudited(t *testing.T) {
|
||||
for _, route := range []struct{ method, path string }{
|
||||
{"POST", "/live/rooms/:id/gifts"},
|
||||
{"POST", "/live/recharge/orders"},
|
||||
{"POST", "/live/client/auth/logout"},
|
||||
} {
|
||||
if !ShouldAudit(route.method, route.path) {
|
||||
t.Errorf("%s %s must be audited", route.method, route.path)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user