func newCheckers(info requestInfo) checkers.Checker { return checkers.New( checkers.TimeBefore, httpbakery.Checkers(info.request), operationChecker(info.operation), requestObjectChecker(info.request, info.params), ) }
type checkTest struct { caveat string expectError string expectCause func(err error) bool } var isCaveatNotRecognized = errgo.Is(checkers.ErrCaveatNotRecognized) var checkerTests = []struct { about string checker checkers.Checker checks []checkTest }{{ about: "no host name declared", checker: checkers.New(httpbakery.Checkers(&http.Request{})), checks: []checkTest{{ caveat: checkers.ClientIPAddrCaveat(net.IP{0, 0, 0, 0}).Condition, expectError: `caveat "client-ip-addr 0.0.0.0" not satisfied: client has no remote address`, }, { caveat: checkers.ClientIPAddrCaveat(net.IP{127, 0, 0, 1}).Condition, expectError: `caveat "client-ip-addr 127.0.0.1" not satisfied: client has no remote address`, }, { caveat: "client-ip-addr badip", expectError: `caveat "client-ip-addr badip" not satisfied: cannot parse IP address in caveat`, }}, }, { about: "IPv4 host name declared", checker: checkers.New(httpbakery.Checkers(&http.Request{ RemoteAddr: "127.0.0.1:1234", })),