option to return ErrSkip and ErrBlock from validator
parent
195394da10
commit
f02fb45ced
@ -0,0 +1,4 @@
|
||||
github.com/99designs/httpsignatures-go v0.0.0-20170731043157-88528bf4ca7e h1:rl2Aq4ZODqTDkeSqQBy+fzpZPamacO1Srp8zq7jf2Sc=
|
||||
github.com/99designs/httpsignatures-go v0.0.0-20170731043157-88528bf4ca7e/go.mod h1:Xa6lInWHNQnuWoF0YPSsx+INFA9qk7/7pTjwb3PInkY=
|
||||
github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ=
|
||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
@ -0,0 +1,51 @@
|
||||
// Copyright 2018 Drone.IO Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package validator
|
||||
|
||||
// import (
|
||||
// "bytes"
|
||||
// "context"
|
||||
// "io/ioutil"
|
||||
// "net/http"
|
||||
// "testing"
|
||||
// )
|
||||
|
||||
// var noContext = context.Background()
|
||||
|
||||
// func TestErrSkip(t *testing.T) {
|
||||
// client := http.Client{}
|
||||
// client.Transport = roundTripFunc(func(r *http.Request) (*http.Response, error) {
|
||||
// buf := bytes.NewBuffer(nil)
|
||||
// buf.WriteString("skip")
|
||||
// return &http.Response{
|
||||
// Body: ioutil.NopCloser(buf),
|
||||
// StatusCode: 498,
|
||||
// }, nil
|
||||
// })
|
||||
|
||||
// plugin := Client("http://localhost", "top-secret", false)
|
||||
// plugin.(*pluginClient).client.Client = &client
|
||||
|
||||
// err := plugin.Validate(noContext, &Request{})
|
||||
// if err != ErrSkip {
|
||||
// t.Errorf("Expect skip error, got %v", err)
|
||||
// }
|
||||
// }
|
||||
|
||||
// type roundTripFunc func(r *http.Request) (*http.Response, error)
|
||||
|
||||
// func (s roundTripFunc) RoundTrip(r *http.Request) (*http.Response, error) {
|
||||
// return s(r)
|
||||
// }
|
Loading…
Reference in New Issue