validate_protocol_test.go 675 B

123456789101112131415161718
  1. package middleware
  2. import (
  3. "testing"
  4. "github.com/mhsanaei/3x-ui/v3/internal/database/model"
  5. )
  6. // The inbound add/update handlers validate the body with this validator, so a protocol
  7. // missing from Inbound.Protocol's oneof makes every save of that protocol fail.
  8. func TestValidateAcceptsMasqueInboundProtocol(t *testing.T) {
  9. if err := validate.StructPartial(model.Inbound{Protocol: model.MASQUE}, "Protocol"); err != nil {
  10. t.Fatalf("validate rejected a masque inbound: %v", err)
  11. }
  12. if err := validate.StructPartial(model.Inbound{Protocol: "dokodemo"}, "Protocol"); err == nil {
  13. t.Fatal("validate accepted an unknown protocol; the oneof no longer guards it")
  14. }
  15. }