Adding a simpler interface for the HTTP request library. (#8862)
This commit is contained in:
parent
79a311d3be
commit
12c9f00931
18 changed files with 954 additions and 102 deletions
20
go.mod
20
go.mod
|
@ -6,7 +6,6 @@ require (
|
|||
github.com/armon/go-proxyproto v0.0.0-20210323213023-7e956b284f0a
|
||||
github.com/eapache/channels v1.1.0
|
||||
github.com/fsnotify/fsnotify v1.5.4
|
||||
github.com/gavv/httpexpect/v2 v2.3.1
|
||||
github.com/imdario/mergo v0.3.13
|
||||
github.com/json-iterator/go v1.1.12
|
||||
github.com/kylelemons/godebug v1.1.0
|
||||
|
@ -24,6 +23,7 @@ require (
|
|||
github.com/spf13/cobra v1.5.0
|
||||
github.com/spf13/pflag v1.0.5
|
||||
github.com/stretchr/testify v1.8.0
|
||||
github.com/yudai/gojsondiff v1.0.0
|
||||
github.com/zakjan/cert-chain-resolver v0.0.0-20211122211144-c6b0b792af9a
|
||||
golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b
|
||||
|
@ -55,8 +55,6 @@ require (
|
|||
github.com/BurntSushi/toml v0.3.1 // indirect
|
||||
github.com/PuerkitoBio/purell v1.1.1 // indirect
|
||||
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
|
||||
github.com/ajg/form v1.5.1 // indirect
|
||||
github.com/andybalholm/brotli v1.0.4 // indirect
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/blang/semver/v4 v4.0.0 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.1.2 // indirect
|
||||
|
@ -66,13 +64,13 @@ require (
|
|||
github.com/eapache/queue v1.1.0 // indirect
|
||||
github.com/emicklei/go-restful/v3 v3.8.0 // indirect
|
||||
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
|
||||
github.com/fatih/structs v1.0.0 // indirect
|
||||
github.com/fullsailor/pkcs7 v0.0.0-20160414161337-2585af45975b // indirect
|
||||
github.com/go-errors/errors v1.0.1 // indirect
|
||||
github.com/go-logr/logr v1.2.3 // indirect
|
||||
github.com/go-openapi/jsonpointer v0.19.5 // indirect
|
||||
github.com/go-openapi/jsonreference v0.19.5 // indirect
|
||||
github.com/go-openapi/swag v0.19.14 // indirect
|
||||
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect
|
||||
github.com/godbus/dbus/v5 v5.0.6 // indirect
|
||||
github.com/gogo/protobuf v1.3.2 // indirect
|
||||
github.com/golang-jwt/jwt/v4 v4.2.0 // indirect
|
||||
|
@ -82,16 +80,13 @@ require (
|
|||
github.com/google/btree v1.0.1 // indirect
|
||||
github.com/google/gnostic v0.5.7-v3refs // indirect
|
||||
github.com/google/go-cmp v0.5.8 // indirect
|
||||
github.com/google/go-querystring v1.0.0 // indirect
|
||||
github.com/google/gofuzz v1.1.0 // indirect
|
||||
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 // indirect
|
||||
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
|
||||
github.com/google/uuid v1.2.0 // indirect
|
||||
github.com/gorilla/websocket v1.4.2 // indirect
|
||||
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 // indirect
|
||||
github.com/imkira/go-interpol v1.0.0 // indirect
|
||||
github.com/inconshreveable/mousetrap v1.0.0 // indirect
|
||||
github.com/josharian/intern v1.0.0 // indirect
|
||||
github.com/klauspost/compress v1.15.7 // indirect
|
||||
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect
|
||||
github.com/mailru/easyjson v0.7.6 // indirect
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
|
||||
|
@ -108,15 +103,9 @@ require (
|
|||
github.com/prometheus/procfs v0.8.0 // indirect
|
||||
github.com/sergi/go-diff v1.1.0 // indirect
|
||||
github.com/sirupsen/logrus v1.8.1 // indirect
|
||||
github.com/valyala/bytebufferpool v1.0.0 // indirect
|
||||
github.com/valyala/fasthttp v1.38.0 // indirect
|
||||
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect
|
||||
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
|
||||
github.com/xeipuuv/gojsonschema v1.1.0 // indirect
|
||||
github.com/xlab/treeprint v1.1.0 // indirect
|
||||
github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0 // indirect
|
||||
github.com/yudai/gojsondiff v1.0.0 // indirect
|
||||
github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 // indirect
|
||||
github.com/yudai/pp v2.0.1+incompatible // indirect
|
||||
go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 // indirect
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
|
||||
golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b // indirect
|
||||
|
@ -135,7 +124,6 @@ require (
|
|||
k8s.io/gengo v0.0.0-20210813121822-485abfe95c7c // indirect
|
||||
k8s.io/kube-openapi v0.0.0-20220803162953-67bda5d908f1 // indirect
|
||||
k8s.io/utils v0.0.0-20220728103510-ee6ede2d64ed // indirect
|
||||
moul.io/http2curl v1.0.1-0.20190925090545-5cd742060b0e // indirect
|
||||
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect
|
||||
sigs.k8s.io/kustomize/api v0.12.1 // indirect
|
||||
sigs.k8s.io/kustomize/kyaml v0.13.9 // indirect
|
||||
|
|
56
go.sum
56
go.sum
|
@ -75,16 +75,11 @@ github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tN
|
|||
github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
|
||||
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M=
|
||||
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
|
||||
github.com/ajg/form v1.5.1 h1:t9c7v8JUKu/XxOGBU0yjNpaMloxGEJhUkqFRq0ibGeU=
|
||||
github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY=
|
||||
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho=
|
||||
github.com/andybalholm/brotli v1.0.2/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y=
|
||||
github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY=
|
||||
github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
|
||||
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
|
||||
github.com/antlr/antlr4/runtime/Go/antlr v0.0.0-20210826220005-b48c857c3a0e/go.mod h1:F7bn7fEU90QkQ3tnmaTx3LTKLEDqnwWODIYppRQ5hnY=
|
||||
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
|
||||
|
@ -173,11 +168,7 @@ github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.
|
|||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||
github.com/evanphx/json-patch v4.12.0+incompatible h1:4onqiflcdA9EOZ4RxV643DvftH5pOlLGNtQ5lPWQu84=
|
||||
github.com/evanphx/json-patch v4.12.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
|
||||
github.com/fasthttp/websocket v1.4.3-rc.6 h1:omHqsl8j+KXpmzRjF8bmzOSYJ8GnS0E3efi1wYT+niY=
|
||||
github.com/fasthttp/websocket v1.4.3-rc.6/go.mod h1:43W9OM2T8FeXpCWMsBd9Cb7nE2CACNqNvCqQCoty/Lc=
|
||||
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
|
||||
github.com/fatih/structs v1.0.0 h1:BrX964Rv5uQ3wwS+KRUAJCBBw5PQmgJfJ6v4yly5QwU=
|
||||
github.com/fatih/structs v1.0.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M=
|
||||
github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
|
||||
github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
|
||||
github.com/form3tech-oss/jwt-go v3.2.3+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
|
||||
|
@ -188,8 +179,6 @@ github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwV
|
|||
github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU=
|
||||
github.com/fullsailor/pkcs7 v0.0.0-20160414161337-2585af45975b h1:074/xhloHUBOpTZwlIzQ28rbPY8pNJvzY7Gcx5KnNOk=
|
||||
github.com/fullsailor/pkcs7 v0.0.0-20160414161337-2585af45975b/go.mod h1:KnogPXtdwXqoenmZCw6S+25EAm2MkxbG0deNDu4cbSA=
|
||||
github.com/gavv/httpexpect/v2 v2.3.1 h1:sGLlKMn8AuHS9ztK9Sb7AJ7OxIL8v2PcLdyxfKt1Fo4=
|
||||
github.com/gavv/httpexpect/v2 v2.3.1/go.mod h1:yOE8m/aqFYQDNrgprMeXgq4YynfN9h1NgcE1+1suV64=
|
||||
github.com/getkin/kin-openapi v0.76.0/go.mod h1:660oXbgy5JFMKreazJaQTw7o+X00qeSyhcnluiMv+Xg=
|
||||
github.com/getsentry/raven-go v0.2.0/go.mod h1:KungGk8q33+aIAZUIVWZDr2OfAEBsO49PX4NzFV5kcQ=
|
||||
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||
|
@ -223,6 +212,8 @@ github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh
|
|||
github.com/go-openapi/swag v0.19.14 h1:gm3vOOXfiuw5i9p5N9xJvfjvuofpyvLA9Wr6QfK5Fng=
|
||||
github.com/go-openapi/swag v0.19.14/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ=
|
||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 h1:p104kn46Q8WdvHunIJ9dAyjPVtrBPhSr3KT2yUst43I=
|
||||
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
|
||||
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||
github.com/godbus/dbus/v5 v5.0.6 h1:mkgN1ofwASrYnJ5W6U/BxG15eXXXjirgZc7CLqkcaro=
|
||||
github.com/godbus/dbus/v5 v5.0.6/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||
|
@ -294,8 +285,6 @@ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
|
|||
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
|
||||
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk=
|
||||
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/google/gofuzz v1.1.0 h1:Hsa8mG0dQ46ij8Sl2AYJDUv1oA9/d6Vk+3LG99Oe02g=
|
||||
github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
|
@ -316,6 +305,7 @@ github.com/google/pprof v0.0.0-20210122040257-d980be63207e/go.mod h1:kpwsk12EmLe
|
|||
github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
||||
github.com/google/pprof v0.0.0-20210601050228-01bbb1931b22/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
||||
github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
||||
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 h1:K6RDEckDVWvDI9JAJYCmNdQXq6neHJOYx3V6jnqNEec=
|
||||
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
||||
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
||||
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4=
|
||||
|
@ -330,7 +320,6 @@ github.com/googleapis/gnostic v0.5.1/go.mod h1:6U4PtQXGIEt/Z3h5MAT7FNofLnw9vXk2c
|
|||
github.com/googleapis/gnostic v0.5.5/go.mod h1:7+EbHbldMins07ALC74bsA81Ovc97DwqyJO1AENw9kA=
|
||||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
||||
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
|
||||
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
|
||||
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 h1:pdN6V1QBWetyv/0+wjACpqVH+eVULgEjkurDLq3goeM=
|
||||
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA=
|
||||
|
@ -365,8 +354,6 @@ github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:
|
|||
github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
|
||||
github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk=
|
||||
github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg=
|
||||
github.com/imkira/go-interpol v1.0.0 h1:HrmLyvOLJyjR0YofMw8QGdCIuYOs4TJUBDNU5sJC09E=
|
||||
github.com/imkira/go-interpol v1.0.0/go.mod h1:z0h2/2T3XF8kyEPpRgJ3kmNv+C43p+I/CoI+jC3w2iA=
|
||||
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
|
||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
|
||||
|
@ -384,15 +371,10 @@ github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/X
|
|||
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
|
||||
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
||||
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
|
||||
github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q1U84EfirKl04SVQ/s7nPm1ZPhiXd34z40TNz36k=
|
||||
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
|
||||
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
|
||||
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
|
||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||
github.com/klauspost/compress v1.12.2/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg=
|
||||
github.com/klauspost/compress v1.15.0/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
|
||||
github.com/klauspost/compress v1.15.7 h1:7cgTQxJCU/vy+oP/E3B9RGbQTgbiVzIJWIKOLoAsPok=
|
||||
github.com/klauspost/compress v1.15.7/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
|
||||
|
@ -416,12 +398,10 @@ github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN
|
|||
github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
||||
github.com/mailru/easyjson v0.7.6 h1:8yTIVnZgCoiM1TgqoeTl+LfU5Jg6/xL3QhGQnimLYnA=
|
||||
github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
|
||||
github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRUIY4=
|
||||
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
|
||||
github.com/mattn/go-colorable v0.1.2 h1:/bC9yWikZXAL9uJdulbSfyVNIR3n3trXl+v8+1sx8mU=
|
||||
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
|
||||
github.com/mattn/go-isatty v0.0.3 h1:ns/ykhmWi7G9O+8a448SecJU3nSMBXJfqQkl0upE1jI=
|
||||
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
||||
github.com/mattn/go-isatty v0.0.8 h1:HLtExJ+uU2HOZ+wI0Tt5DtUDrx8yhUqDcp7fYERX4CE=
|
||||
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 h1:I0XW9+e1XWDxdcEniV4rQAIOPUGDq67JSCiRCgGCZLI=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4=
|
||||
|
@ -476,14 +456,12 @@ github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
|
|||
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
|
||||
github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
|
||||
github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY=
|
||||
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
|
||||
github.com/onsi/ginkgo/v2 v2.1.4 h1:GNapqRSid3zijZ9H77KrgVG4/8KqiyRsxcSxe+7ApXY=
|
||||
github.com/onsi/ginkgo/v2 v2.1.4/go.mod h1:um6tUpWM/cxCK3/FK8BXqEiUMUwRgSM4JXG47RKZmLU=
|
||||
github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA=
|
||||
github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
||||
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
|
||||
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
|
||||
github.com/onsi/gomega v1.19.0 h1:4ieX6qQjPP/BfC3mpsAtIGGlxTWPeA3Inl/7DtXw1tw=
|
||||
|
@ -550,11 +528,8 @@ github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6po
|
|||
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
|
||||
github.com/savsgio/gotils v0.0.0-20210617111740-97865ed5a873 h1:N3Af8f13ooDKcIhsmFT7Z05CStZWu4C7Md0uDEy4q6o=
|
||||
github.com/savsgio/gotils v0.0.0-20210617111740-97865ed5a873/go.mod h1:dmPawKuiAeG/aFYVs2i+Dyosoo7FNcm+Pi8iK6ZUrX8=
|
||||
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
|
||||
github.com/seccomp/libseccomp-golang v0.9.2-0.20220502022130-f33da4d89646/go.mod h1:JA8cRccbGaA1s33RQf7Y1+q9gHmZX1yB/z9WDN1C6fg=
|
||||
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
|
||||
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
|
||||
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
|
||||
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||
|
@ -606,25 +581,11 @@ github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1
|
|||
github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
|
||||
github.com/urfave/cli v1.17.1-0.20160602030128-01a33823596e/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
|
||||
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
|
||||
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
|
||||
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
||||
github.com/valyala/fasthttp v1.27.0/go.mod h1:cmWIqlu99AO/RKcp1HWaViTqc57FswJOfYYdPJBl8BA=
|
||||
github.com/valyala/fasthttp v1.38.0 h1:yTjSSNjuDi2PPvXY2836bIwLmiTS2T4T9p1coQshpco=
|
||||
github.com/valyala/fasthttp v1.38.0/go.mod h1:t/G+3rLek+CyY9bnIE+YlMRddxVAAGjhxndDB4i4C0I=
|
||||
github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc=
|
||||
github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE=
|
||||
github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df/go.mod h1:JP3t17pCcGlemwknint6hfoeCVQrEMVwxRLRjXpq+BU=
|
||||
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f h1:J9EGpcZtP0E/raorCMxlFGSTBrsSlaDGf3jU/qvAE2c=
|
||||
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
|
||||
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0=
|
||||
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=
|
||||
github.com/xeipuuv/gojsonschema v1.1.0 h1:ngVtJC9TY/lg0AA/1k48FYhBrhRoFlEmWzsehpNAaZg=
|
||||
github.com/xeipuuv/gojsonschema v1.1.0/go.mod h1:5yf86TLmAcydyeJq5YvxkGPE2fm/u4myDekKRoLuqhs=
|
||||
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
|
||||
github.com/xlab/treeprint v1.1.0 h1:G/1DjNkPpfZCFt9CSh6b5/nY4VimlbHF3Rh4obvtzDk=
|
||||
github.com/xlab/treeprint v1.1.0/go.mod h1:gj5Gd3gPdKtR1ikdDK6fnFLdmIS0X30kTTuNd/WEJu0=
|
||||
github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0 h1:6fRhSjgLCkTD3JnJxvaJ4Sj+TYblw757bqYgZaOq5ZY=
|
||||
github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0/go.mod h1:/LWChgwKmvncFJFHJ7Gvn9wZArjbV5/FppcK2fKk/tI=
|
||||
github.com/yudai/gojsondiff v1.0.0 h1:27cbfqXLVEJ1o8I6v3y9lg8Ydm53EKqHXAOMxEGlCOA=
|
||||
github.com/yudai/gojsondiff v1.0.0/go.mod h1:AY32+k2cwILAkW1fbgxQ5mUmMiZFgLIV+FBNExI05xg=
|
||||
github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 h1:BHyfKlQyqbsFN5p3IfnEUduWvb9is428/nNb5L3U01M=
|
||||
|
@ -690,12 +651,10 @@ golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8U
|
|||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8=
|
||||
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||
golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||
golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd h1:XcWmESyNjXJMLahc3mqVQJcgSTDxFxhETVlfk9uGc38=
|
||||
golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
|
@ -780,7 +739,6 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v
|
|||
golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc=
|
||||
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
|
||||
golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20210510120150-4163338589ed/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20210825183410-e898025ed96a/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
|
@ -827,7 +785,6 @@ golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5h
|
|||
golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
|
@ -896,7 +853,6 @@ golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBc
|
|||
golang.org/x/sys v0.0.0-20211116061358-0a5406a5449c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f h1:v4INt8xihDGvnrfjMDVXGxw9wrfxYyCjk0KbXjhR55s=
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
|
@ -1215,8 +1171,6 @@ k8s.io/utils v0.0.0-20210802155522-efc7438f0176/go.mod h1:jPW/WVKK9YHAvNhRxK0md/
|
|||
k8s.io/utils v0.0.0-20211116205334-6203023598ed/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
k8s.io/utils v0.0.0-20220728103510-ee6ede2d64ed h1:jAne/RjBTyawwAy0utX5eqigAwz/lQhTmy+Hr/Cpue4=
|
||||
k8s.io/utils v0.0.0-20220728103510-ee6ede2d64ed/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
moul.io/http2curl v1.0.1-0.20190925090545-5cd742060b0e h1:C7q+e9M5nggAvWfVg9Nl66kebKeuJlP3FD58V4RR5wo=
|
||||
moul.io/http2curl v1.0.1-0.20190925090545-5cd742060b0e/go.mod h1:nejbQVfXh96n9dSF6cH3Jsk/QI1Z2oEL7sSI2ifXFNA=
|
||||
pault.ag/go/sniff v0.0.0-20200207005214-cf7e4d167732 h1:SAElp8THCfmBdM+4lmWX5gebiSSkEr7PAYDVF91qpfg=
|
||||
pault.ag/go/sniff v0.0.0-20200207005214-cf7e4d167732/go.mod h1:lpvCfhqEHNJSSpG5R5A2EgsVzG8RTt4RfPoQuRAcDmg=
|
||||
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
|
||||
|
|
|
@ -42,7 +42,7 @@ var _ = framework.DescribeAnnotation("affinitymode", func() {
|
|||
host := "affinity-mode-balance.com"
|
||||
annotations := make(map[string]string)
|
||||
annotations["nginx.ingress.kubernetes.io/affinity"] = "cookie"
|
||||
annotations["ginx.ingress.kubernetes.io/session-cookie-name"] = "hello-cookie"
|
||||
annotations["nginx.ingress.kubernetes.io/session-cookie-name"] = "hello-cookie"
|
||||
annotations["nginx.ingress.kubernetes.io/session-cookie-expires"] = "172800"
|
||||
annotations["nginx.ingress.kubernetes.io/session-cookie-max-age"] = "172800"
|
||||
annotations["nginx.ingress.kubernetes.io/ssl-redirect"] = "false"
|
||||
|
@ -75,7 +75,7 @@ var _ = framework.DescribeAnnotation("affinitymode", func() {
|
|||
host := "affinity-mode-persistent.com"
|
||||
annotations := make(map[string]string)
|
||||
annotations["nginx.ingress.kubernetes.io/affinity"] = "cookie"
|
||||
annotations["ginx.ingress.kubernetes.io/session-cookie-name"] = "hello-cookie"
|
||||
annotations["nginx.ingress.kubernetes.io/session-cookie-name"] = "hello-cookie"
|
||||
annotations["nginx.ingress.kubernetes.io/session-cookie-expires"] = "172800"
|
||||
annotations["nginx.ingress.kubernetes.io/session-cookie-max-age"] = "172800"
|
||||
annotations["nginx.ingress.kubernetes.io/ssl-redirect"] = "false"
|
||||
|
|
|
@ -19,7 +19,8 @@ package defaultbackend
|
|||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gavv/httpexpect/v2"
|
||||
"k8s.io/ingress-nginx/test/e2e/framework/httpexpect"
|
||||
|
||||
"github.com/onsi/ginkgo/v2"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
|
@ -64,15 +65,13 @@ var _ = framework.IngressNginxDescribe("[Default Backend]", func() {
|
|||
for _, test := range testCases {
|
||||
ginkgo.By(test.Name)
|
||||
|
||||
var req *httpexpect.Request
|
||||
var req *httpexpect.HTTPRequest
|
||||
|
||||
switch test.Scheme {
|
||||
case framework.HTTP:
|
||||
req = f.HTTPTestClient().Request(test.Method, test.Path)
|
||||
req.WithURL(f.GetURL(framework.HTTP) + test.Path)
|
||||
req = f.HTTPTestClient().DoRequest(test.Method, test.Path).WithURL(f.GetURL(framework.HTTP) + test.Path)
|
||||
case framework.HTTPS:
|
||||
req = f.HTTPTestClient().Request(test.Method, test.Path)
|
||||
req.WithURL(f.GetURL(framework.HTTPS) + test.Path)
|
||||
req = f.HTTPTestClient().DoRequest(test.Method, test.Path).WithURL(f.GetURL(framework.HTTPS) + test.Path)
|
||||
default:
|
||||
ginkgo.Fail("Unexpected request scheme")
|
||||
}
|
||||
|
|
|
@ -22,7 +22,8 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/gavv/httpexpect/v2"
|
||||
"k8s.io/ingress-nginx/test/e2e/framework/httpexpect"
|
||||
|
||||
"github.com/onsi/ginkgo/v2"
|
||||
"github.com/stretchr/testify/assert"
|
||||
appsv1 "k8s.io/api/apps/v1"
|
||||
|
@ -445,22 +446,22 @@ func (f *Framework) DeleteNGINXPod(grace int64) {
|
|||
}
|
||||
|
||||
// HTTPDumbTestClient returns a new httpexpect client without BaseURL.
|
||||
func (f *Framework) HTTPDumbTestClient() *httpexpect.Expect {
|
||||
return f.newTestClient(nil, false)
|
||||
func (f *Framework) HTTPDumbTestClient() *httpexpect.HTTPRequest {
|
||||
return f.newHTTPTestClient(nil, false)
|
||||
}
|
||||
|
||||
// HTTPTestClient returns a new httpexpect client for end-to-end HTTP testing.
|
||||
func (f *Framework) HTTPTestClient() *httpexpect.Expect {
|
||||
return f.newTestClient(nil, true)
|
||||
// HTTPTestClient returns a new HTTPRequest client for end-to-end HTTP testing.
|
||||
func (f *Framework) HTTPTestClient() *httpexpect.HTTPRequest {
|
||||
return f.newHTTPTestClient(nil, true)
|
||||
}
|
||||
|
||||
// HTTPTestClientWithTLSConfig returns a new httpexpect client for end-to-end
|
||||
// HTTP testing with a custom TLS configuration.
|
||||
func (f *Framework) HTTPTestClientWithTLSConfig(config *tls.Config) *httpexpect.Expect {
|
||||
return f.newTestClient(config, true)
|
||||
func (f *Framework) HTTPTestClientWithTLSConfig(config *tls.Config) *httpexpect.HTTPRequest {
|
||||
return f.newHTTPTestClient(config, true)
|
||||
}
|
||||
|
||||
func (f *Framework) newTestClient(config *tls.Config, setIngressURL bool) *httpexpect.Expect {
|
||||
func (f *Framework) newHTTPTestClient(config *tls.Config, setIngressURL bool) *httpexpect.HTTPRequest {
|
||||
if config == nil {
|
||||
config = &tls.Config{
|
||||
InsecureSkipVerify: true,
|
||||
|
@ -471,24 +472,14 @@ func (f *Framework) newTestClient(config *tls.Config, setIngressURL bool) *httpe
|
|||
baseURL = f.GetURL(HTTP)
|
||||
}
|
||||
|
||||
return httpexpect.WithConfig(httpexpect.Config{
|
||||
BaseURL: baseURL,
|
||||
Client: &http.Client{
|
||||
Transport: &http.Transport{
|
||||
TLSClientConfig: config,
|
||||
},
|
||||
CheckRedirect: func(req *http.Request, via []*http.Request) error {
|
||||
return http.ErrUseLastResponse
|
||||
},
|
||||
return httpexpect.NewRequest(baseURL, &http.Client{
|
||||
Transport: &http.Transport{
|
||||
TLSClientConfig: config,
|
||||
},
|
||||
Reporter: httpexpect.NewAssertReporter(
|
||||
httpexpect.NewAssertReporter(ginkgo.GinkgoT()),
|
||||
),
|
||||
Printers: []httpexpect.Printer{
|
||||
// TODO: enable conditionally?
|
||||
// httpexpect.NewDebugPrinter(ginkgo.GinkgoT(), false),
|
||||
CheckRedirect: func(req *http.Request, via []*http.Request) error {
|
||||
return http.ErrUseLastResponse
|
||||
},
|
||||
})
|
||||
}, httpexpect.NewAssertReporter())
|
||||
}
|
||||
|
||||
// WaitForNginxListening waits until NGINX starts accepting connections on a port
|
||||
|
|
1
test/e2e/framework/httpexpect/README.md
Normal file
1
test/e2e/framework/httpexpect/README.md
Normal file
|
@ -0,0 +1 @@
|
|||
This module is based in the deprecated library `github.com/gavv/httpexpect`, and contains slightly adaptations.
|
36
test/e2e/framework/httpexpect/array.go
Normal file
36
test/e2e/framework/httpexpect/array.go
Normal file
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
Copyright 2022 The Kubernetes Authors.
|
||||
|
||||
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 httpexpect
|
||||
|
||||
// Array provides methods to inspect attached []interface{} object
|
||||
// (Go representation of JSON array).
|
||||
type Array struct {
|
||||
chain chain
|
||||
value []interface{}
|
||||
}
|
||||
|
||||
// Iter returns a new slice of Values attached to array elements.
|
||||
func (a *Array) Iter() []Value {
|
||||
if a.chain.failed() {
|
||||
return []Value{}
|
||||
}
|
||||
ret := []Value{}
|
||||
for n := range a.value {
|
||||
ret = append(ret, Value{a.chain, a.value[n]})
|
||||
}
|
||||
return ret
|
||||
}
|
54
test/e2e/framework/httpexpect/chain.go
Normal file
54
test/e2e/framework/httpexpect/chain.go
Normal file
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
Copyright 2022 The Kubernetes Authors.
|
||||
|
||||
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 httpexpect
|
||||
|
||||
type chain struct {
|
||||
reporter Reporter
|
||||
failbit bool
|
||||
}
|
||||
|
||||
func makeChain(reporter Reporter) chain {
|
||||
return chain{reporter, false}
|
||||
}
|
||||
|
||||
func (c *chain) failed() bool {
|
||||
return c.failbit
|
||||
}
|
||||
|
||||
func (c *chain) fail(message string, args ...interface{}) {
|
||||
if c.failbit {
|
||||
return
|
||||
}
|
||||
c.failbit = true
|
||||
c.reporter.Errorf(message, args...)
|
||||
}
|
||||
|
||||
func (c *chain) reset() {
|
||||
c.failbit = false
|
||||
}
|
||||
|
||||
func (c *chain) assertFailed(r Reporter) {
|
||||
if !c.failbit {
|
||||
r.Errorf("expected chain is failed, but it's ok")
|
||||
}
|
||||
}
|
||||
|
||||
func (c *chain) assertOK(r Reporter) {
|
||||
if c.failbit {
|
||||
r.Errorf("expected chain is ok, but it's failed")
|
||||
}
|
||||
}
|
29
test/e2e/framework/httpexpect/cookie.go
Normal file
29
test/e2e/framework/httpexpect/cookie.go
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
Copyright 2022 The Kubernetes Authors.
|
||||
|
||||
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 httpexpect
|
||||
|
||||
import "net/http"
|
||||
|
||||
// Cookie provides methods to inspect attached http.Cookie value.
|
||||
type Cookie struct {
|
||||
chain chain
|
||||
value *http.Cookie
|
||||
}
|
||||
|
||||
func (c *Cookie) Raw() *http.Cookie {
|
||||
return c.value
|
||||
}
|
37
test/e2e/framework/httpexpect/match.go
Normal file
37
test/e2e/framework/httpexpect/match.go
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
Copyright 2022 The Kubernetes Authors.
|
||||
|
||||
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 httpexpect
|
||||
|
||||
// Match provides methods to inspect attached regexp match results.
|
||||
type Match struct {
|
||||
chain chain
|
||||
submatches []string
|
||||
names map[string]int
|
||||
}
|
||||
|
||||
func makeMatch(chain chain, submatches []string, names []string) *Match {
|
||||
if submatches == nil {
|
||||
submatches = []string{}
|
||||
}
|
||||
namemap := map[string]int{}
|
||||
for n, name := range names {
|
||||
if name != "" {
|
||||
namemap[name] = n
|
||||
}
|
||||
}
|
||||
return &Match{chain, submatches, namemap}
|
||||
}
|
111
test/e2e/framework/httpexpect/object.go
Normal file
111
test/e2e/framework/httpexpect/object.go
Normal file
|
@ -0,0 +1,111 @@
|
|||
/*
|
||||
Copyright 2022 The Kubernetes Authors.
|
||||
|
||||
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 httpexpect
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
|
||||
"github.com/yudai/gojsondiff"
|
||||
"github.com/yudai/gojsondiff/formatter"
|
||||
)
|
||||
|
||||
// Object provides methods to inspect attached map[string]interface{} object
|
||||
// (Go representation of JSON object).
|
||||
type Object struct {
|
||||
chain chain
|
||||
value map[string]interface{}
|
||||
}
|
||||
|
||||
func (o *Object) ValueEqual(key string, value interface{}) *Object {
|
||||
if !o.containsKey(key) {
|
||||
o.chain.fail("\nexpected object containing key '%s', but got:\n%s",
|
||||
key, dumpValue(o.value))
|
||||
return o
|
||||
}
|
||||
expected, ok := canonValue(&o.chain, value)
|
||||
if !ok {
|
||||
return o
|
||||
}
|
||||
if !reflect.DeepEqual(expected, o.value[key]) {
|
||||
o.chain.fail("\nexpected value for key '%s' equal to:\n%s\n\nbut got:\n%s\n\ndiff:\n%s",
|
||||
key,
|
||||
dumpValue(expected),
|
||||
dumpValue(o.value[key]),
|
||||
diffValues(expected, o.value[key]))
|
||||
}
|
||||
return o
|
||||
}
|
||||
|
||||
func (o *Object) ContainsKey(key string) *Object {
|
||||
if !o.containsKey(key) {
|
||||
o.chain.fail("\nexpected object containing key '%s', but got:\n%s",
|
||||
key,
|
||||
dumpValue(o.value))
|
||||
}
|
||||
return o
|
||||
}
|
||||
|
||||
func (o *Object) NotContainsKey(key string) *Object {
|
||||
if o.containsKey(key) {
|
||||
o.chain.fail("\nexpected object not containing key '%s', but got:\n%s",
|
||||
key, dumpValue(o.value))
|
||||
}
|
||||
return o
|
||||
}
|
||||
|
||||
func (o *Object) containsKey(key string) bool {
|
||||
for k := range o.value {
|
||||
if k == key {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func diffValues(expected, actual interface{}) string {
|
||||
differ := gojsondiff.New()
|
||||
|
||||
var diff gojsondiff.Diff
|
||||
|
||||
if ve, ok := expected.(map[string]interface{}); ok {
|
||||
if va, ok := actual.(map[string]interface{}); ok {
|
||||
diff = differ.CompareObjects(ve, va)
|
||||
} else {
|
||||
return " (unavailable)"
|
||||
}
|
||||
} else if ve, ok := expected.([]interface{}); ok {
|
||||
if va, ok := actual.([]interface{}); ok {
|
||||
diff = differ.CompareArrays(ve, va)
|
||||
} else {
|
||||
return " (unavailable)"
|
||||
}
|
||||
} else {
|
||||
return " (unavailable)"
|
||||
}
|
||||
|
||||
config := formatter.AsciiFormatterConfig{
|
||||
ShowArrayIndex: true,
|
||||
}
|
||||
f := formatter.NewAsciiFormatter(expected, config)
|
||||
|
||||
str, err := f.Format(diff)
|
||||
if err != nil {
|
||||
return " (unavailable)"
|
||||
}
|
||||
|
||||
return "--- expected\n+++ actual\n" + str
|
||||
}
|
48
test/e2e/framework/httpexpect/reporter.go
Normal file
48
test/e2e/framework/httpexpect/reporter.go
Normal file
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
Copyright 2022 The Kubernetes Authors.
|
||||
|
||||
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 httpexpect
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/onsi/ginkgo/v2"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
// Reporter is used to report failures.
|
||||
// testing.TB, AssertReporter, and RequireReporter implement this interface.
|
||||
type Reporter interface {
|
||||
// Errorf reports failure.
|
||||
// Allowed to return normally or terminate test using t.FailNow().
|
||||
Errorf(message string, args ...interface{})
|
||||
}
|
||||
|
||||
// AssertReporter implements Reporter interface using `testify/assert'
|
||||
// package. Failures are non-fatal with this reporter.
|
||||
type AssertReporter struct {
|
||||
backend *assert.Assertions
|
||||
}
|
||||
|
||||
// NewAssertReporter returns a new AssertReporter object.
|
||||
func NewAssertReporter() *AssertReporter {
|
||||
return &AssertReporter{assert.New(ginkgo.GinkgoT())}
|
||||
}
|
||||
|
||||
// Errorf implements Reporter.Errorf.
|
||||
func (r *AssertReporter) Errorf(message string, args ...interface{}) {
|
||||
r.backend.Fail(fmt.Sprintf(message, args...))
|
||||
}
|
176
test/e2e/framework/httpexpect/request.go
Normal file
176
test/e2e/framework/httpexpect/request.go
Normal file
|
@ -0,0 +1,176 @@
|
|||
/*
|
||||
Copyright 2022 The Kubernetes Authors.
|
||||
|
||||
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 httpexpect
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"path"
|
||||
)
|
||||
|
||||
type HTTPRequest struct {
|
||||
chain chain
|
||||
reporter Reporter
|
||||
baseURL string
|
||||
client *http.Client
|
||||
query url.Values
|
||||
Request *http.Request
|
||||
HTTPResponse *HTTPResponse
|
||||
}
|
||||
|
||||
// NewRequest returns an HTTPRequest object.
|
||||
func NewRequest(baseURL string, client *http.Client, reporter Reporter) *HTTPRequest {
|
||||
response := NewResponse(reporter)
|
||||
return &HTTPRequest{
|
||||
baseURL: baseURL,
|
||||
client: client,
|
||||
reporter: reporter,
|
||||
chain: makeChain(reporter),
|
||||
HTTPResponse: response,
|
||||
}
|
||||
}
|
||||
|
||||
// GET creates a new HTTP request with GET method.
|
||||
func (h *HTTPRequest) GET(rpath string) *HTTPRequest {
|
||||
if h.chain.failed() {
|
||||
return h
|
||||
}
|
||||
return h.DoRequest("GET", rpath)
|
||||
}
|
||||
|
||||
// DoRequest creates a new HTTP request object.
|
||||
func (h *HTTPRequest) DoRequest(method, rpath string) *HTTPRequest {
|
||||
uri, err := url.Parse(h.baseURL)
|
||||
if err != nil {
|
||||
h.chain.fail(err.Error())
|
||||
}
|
||||
|
||||
var request *http.Request
|
||||
uri.Path = path.Join(uri.Path, rpath)
|
||||
if request, err = http.NewRequest(method, uri.String(), nil); err != nil {
|
||||
h.chain.fail(err.Error())
|
||||
}
|
||||
|
||||
h.Request = request
|
||||
return h
|
||||
}
|
||||
|
||||
// Expect executes the request and returns an HTTP response.
|
||||
func (h *HTTPRequest) Expect() *HTTPResponse {
|
||||
if h.query != nil {
|
||||
h.Request.URL.RawQuery = h.query.Encode()
|
||||
}
|
||||
|
||||
response, err := h.client.Do(h.Request)
|
||||
if err != nil {
|
||||
h.chain.fail(err.Error())
|
||||
}
|
||||
|
||||
h.HTTPResponse.Response = response // set the HTTP response
|
||||
|
||||
var content []byte
|
||||
if content, err = getContent(response); err != nil {
|
||||
h.chain.fail(err.Error())
|
||||
}
|
||||
// set content and cookies from HTTPResponse
|
||||
h.HTTPResponse.content = content
|
||||
h.HTTPResponse.cookies = h.HTTPResponse.Response.Cookies()
|
||||
return h.HTTPResponse
|
||||
}
|
||||
|
||||
// WithURL sets the request URL appending paths when already exist.
|
||||
func (h *HTTPRequest) WithURL(urlStr string) *HTTPRequest {
|
||||
if h.chain.failed() {
|
||||
return h
|
||||
}
|
||||
if u, err := url.Parse(urlStr); err != nil {
|
||||
h.chain.fail(err.Error())
|
||||
} else {
|
||||
u.Path = path.Join(h.Request.URL.Path, u.Path)
|
||||
h.Request.URL = u
|
||||
}
|
||||
return h
|
||||
}
|
||||
|
||||
// WithHeader adds given header to request.
|
||||
func (h *HTTPRequest) WithHeader(key, value string) *HTTPRequest {
|
||||
if h.chain.failed() {
|
||||
return h
|
||||
}
|
||||
switch http.CanonicalHeaderKey(key) {
|
||||
case "Host":
|
||||
h.Request.Host = value
|
||||
default:
|
||||
h.Request.Header.Add(key, value)
|
||||
}
|
||||
return h
|
||||
}
|
||||
|
||||
// WithCookies adds given cookies to request.
|
||||
func (h *HTTPRequest) WithCookies(cookies map[string]string) *HTTPRequest {
|
||||
if h.chain.failed() {
|
||||
return h
|
||||
}
|
||||
for k, v := range cookies {
|
||||
h.WithCookie(k, v)
|
||||
}
|
||||
return h
|
||||
}
|
||||
|
||||
// WithCookie adds given single cookie to request.
|
||||
func (h *HTTPRequest) WithCookie(k, v string) *HTTPRequest {
|
||||
if h.chain.failed() {
|
||||
return h
|
||||
}
|
||||
h.Request.AddCookie(&http.Cookie{Name: k, Value: v})
|
||||
return h
|
||||
}
|
||||
|
||||
// WithBasicAuth sets the request's Authorization header to use HTTP
|
||||
// Basic Authentication with the provided username and password.
|
||||
//
|
||||
// With HTTP Basic Authentication the provided username and password
|
||||
// are not encrypted.
|
||||
func (h *HTTPRequest) WithBasicAuth(username, password string) *HTTPRequest {
|
||||
if h.chain.failed() {
|
||||
return h
|
||||
}
|
||||
h.Request.SetBasicAuth(username, password)
|
||||
return h
|
||||
}
|
||||
|
||||
// WithQuery adds query parameter to request URL.
|
||||
func (h *HTTPRequest) WithQuery(key string, value interface{}) *HTTPRequest {
|
||||
if h.chain.failed() {
|
||||
return h
|
||||
}
|
||||
if h.query == nil {
|
||||
h.query = make(url.Values)
|
||||
}
|
||||
h.query.Add(key, fmt.Sprint(value))
|
||||
return h
|
||||
}
|
||||
|
||||
// getContent returns the content from the body response.
|
||||
func getContent(resp *http.Response) ([]byte, error) {
|
||||
if resp.Body == nil {
|
||||
return []byte{}, nil
|
||||
}
|
||||
return io.ReadAll(resp.Body)
|
||||
}
|
273
test/e2e/framework/httpexpect/response.go
Normal file
273
test/e2e/framework/httpexpect/response.go
Normal file
|
@ -0,0 +1,273 @@
|
|||
/*
|
||||
Copyright 2022 The Kubernetes Authors.
|
||||
|
||||
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 httpexpect
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"mime"
|
||||
"net/http"
|
||||
"reflect"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// StatusRange is enum for response status ranges.
|
||||
type StatusRange int
|
||||
|
||||
const (
|
||||
// Status1xx defines "Informational" status codes.
|
||||
Status1xx StatusRange = 100
|
||||
|
||||
// Status2xx defines "Success" status codes.
|
||||
Status2xx StatusRange = 200
|
||||
|
||||
// Status3xx defines "Redirection" status codes.
|
||||
Status3xx StatusRange = 300
|
||||
|
||||
// Status4xx defines "Client Error" status codes.
|
||||
Status4xx StatusRange = 400
|
||||
|
||||
// Status5xx defines "Server Error" status codes.
|
||||
Status5xx StatusRange = 500
|
||||
)
|
||||
|
||||
type HTTPResponse struct {
|
||||
chain chain
|
||||
content []byte
|
||||
cookies []*http.Cookie
|
||||
Response *http.Response
|
||||
}
|
||||
|
||||
// NewResponse returns an empty HTTPResponse object.
|
||||
func NewResponse(reporter Reporter) *HTTPResponse {
|
||||
return &HTTPResponse{
|
||||
chain: makeChain(reporter),
|
||||
}
|
||||
}
|
||||
|
||||
// Body returns the body of the response.
|
||||
func (r *HTTPResponse) Body() *String {
|
||||
return &String{value: string(r.content)}
|
||||
}
|
||||
|
||||
// Raw returns the raw http response.
|
||||
func (r *HTTPResponse) Raw() *http.Response {
|
||||
return r.Response
|
||||
}
|
||||
|
||||
// Status compare the actual http response with the expected one raising and error
|
||||
// if they don't match.
|
||||
func (r *HTTPResponse) Status(status int) *HTTPResponse {
|
||||
if r.chain.failed() {
|
||||
return r
|
||||
}
|
||||
r.checkEqual("status", statusCodeText(status), statusCodeText(r.Response.StatusCode))
|
||||
return r
|
||||
}
|
||||
|
||||
// ContentEncoding succeeds if response has exactly given Content-Encoding
|
||||
func (r *HTTPResponse) ContentEncoding(encoding ...string) *HTTPResponse {
|
||||
if r.chain.failed() {
|
||||
return r
|
||||
}
|
||||
r.checkEqual("\"Content-Encoding\" header", encoding, r.Response.Header["Content-Encoding"])
|
||||
return r
|
||||
}
|
||||
|
||||
// ContentType succeeds if response contains Content-Type header with given
|
||||
// media type and charset.
|
||||
func (r *HTTPResponse) ContentType(mediaType string, charset ...string) *HTTPResponse {
|
||||
r.checkContentType(mediaType, charset...)
|
||||
return r
|
||||
}
|
||||
|
||||
// Cookies returns a new Array object with all cookie names set by this response.
|
||||
// Returned Array contains a String value for every cookie name.
|
||||
func (r *HTTPResponse) Cookies() *Array {
|
||||
if r.chain.failed() {
|
||||
return &Array{r.chain, nil}
|
||||
}
|
||||
names := []interface{}{}
|
||||
for _, c := range r.cookies {
|
||||
names = append(names, c.Name)
|
||||
}
|
||||
return &Array{r.chain, names}
|
||||
}
|
||||
|
||||
// Cookie returns a new Cookie object that may be used to inspect given cookie
|
||||
// set by this response.
|
||||
func (r *HTTPResponse) Cookie(name string) *Cookie {
|
||||
if r.chain.failed() {
|
||||
return &Cookie{r.chain, nil}
|
||||
}
|
||||
names := []string{}
|
||||
for _, c := range r.cookies {
|
||||
if c.Name == name {
|
||||
return &Cookie{r.chain, c}
|
||||
}
|
||||
names = append(names, c.Name)
|
||||
}
|
||||
r.chain.fail("\nexpected response with cookie:\n %q\n\nbut got only cookies:\n%s", name, dumpValue(names))
|
||||
return &Cookie{r.chain, nil}
|
||||
}
|
||||
|
||||
// Headers returns a new Object that may be used to inspect header map.
|
||||
func (r *HTTPResponse) Headers() *Object {
|
||||
var value map[string]interface{}
|
||||
if !r.chain.failed() {
|
||||
value, _ = canonMap(&r.chain, r.Response.Header)
|
||||
}
|
||||
return &Object{r.chain, value}
|
||||
}
|
||||
|
||||
// Header returns a new String object that may be used to inspect given header.
|
||||
func (r *HTTPResponse) Header(header string) *String {
|
||||
return &String{chain: r.chain, value: r.Response.Header.Get(header)}
|
||||
}
|
||||
|
||||
func canonMap(chain *chain, in interface{}) (map[string]interface{}, bool) {
|
||||
var out map[string]interface{}
|
||||
data, ok := canonValue(chain, in)
|
||||
if ok {
|
||||
out, ok = data.(map[string]interface{})
|
||||
if !ok {
|
||||
chain.fail("expected map, got %v", out)
|
||||
}
|
||||
}
|
||||
return out, ok
|
||||
}
|
||||
|
||||
func canonValue(chain *chain, in interface{}) (interface{}, bool) {
|
||||
b, err := json.Marshal(in)
|
||||
if err != nil {
|
||||
chain.fail(err.Error())
|
||||
return nil, false
|
||||
}
|
||||
|
||||
var out interface{}
|
||||
if err := json.Unmarshal(b, &out); err != nil {
|
||||
chain.fail(err.Error())
|
||||
return nil, false
|
||||
}
|
||||
|
||||
return out, true
|
||||
}
|
||||
|
||||
// StatusRange succeeds if response status belongs to given range.
|
||||
func (r *HTTPResponse) StatusRange(rn StatusRange) *HTTPResponse {
|
||||
if r.chain.failed() {
|
||||
return r
|
||||
}
|
||||
status := statusCodeText(r.Response.StatusCode)
|
||||
|
||||
actual := statusRangeText(r.Response.StatusCode)
|
||||
expected := statusRangeText(int(rn))
|
||||
|
||||
if actual == "" || actual != expected {
|
||||
if actual == "" {
|
||||
r.chain.fail("\nexpected status from range:\n %q\n\nbut got:\n %q",
|
||||
expected, status)
|
||||
} else {
|
||||
r.chain.fail("\nexpected status from range:\n %q\n\nbut got:\n %q (%q)",
|
||||
expected, actual, status)
|
||||
}
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
func statusCodeText(code int) string {
|
||||
if s := http.StatusText(code); s != "" {
|
||||
return strconv.Itoa(code) + " " + s
|
||||
}
|
||||
return strconv.Itoa(code)
|
||||
}
|
||||
|
||||
func statusRangeText(code int) string {
|
||||
switch {
|
||||
case code >= 100 && code < 200:
|
||||
return "1xx Informational"
|
||||
case code >= 200 && code < 300:
|
||||
return "2xx Success"
|
||||
case code >= 300 && code < 400:
|
||||
return "3xx Redirection"
|
||||
case code >= 400 && code < 500:
|
||||
return "4xx Client Error"
|
||||
case code >= 500 && code < 600:
|
||||
return "5xx Server Error"
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
func (r *HTTPResponse) checkContentType(expectedType string, expectedCharset ...string) bool {
|
||||
if r.chain.failed() {
|
||||
return false
|
||||
}
|
||||
|
||||
contentType := r.Response.Header.Get("Content-Type")
|
||||
|
||||
if expectedType == "" && len(expectedCharset) == 0 {
|
||||
if contentType == "" {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
mediaType, params, err := mime.ParseMediaType(contentType)
|
||||
if err != nil {
|
||||
r.chain.fail("\ngot invalid \"Content-Type\" header %q", contentType)
|
||||
return false
|
||||
}
|
||||
|
||||
if mediaType != expectedType {
|
||||
r.chain.fail("\nexpected \"Content-Type\" header with %q media type,"+
|
||||
"\nbut got %q", expectedType, mediaType)
|
||||
return false
|
||||
}
|
||||
|
||||
charset := params["charset"]
|
||||
|
||||
if len(expectedCharset) == 0 {
|
||||
if charset != "" && !strings.EqualFold(charset, "utf-8") {
|
||||
r.chain.fail("\nexpected \"Content-Type\" header with \"utf-8\" or empty charset,"+
|
||||
"\nbut got %q", charset)
|
||||
return false
|
||||
}
|
||||
} else {
|
||||
if !strings.EqualFold(charset, expectedCharset[0]) {
|
||||
r.chain.fail("\nexpected \"Content-Type\" header with %q charset,"+
|
||||
"\nbut got %q", expectedCharset[0], charset)
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (r *HTTPResponse) checkEqual(what string, expected, actual interface{}) {
|
||||
if !reflect.DeepEqual(expected, actual) {
|
||||
r.chain.fail("\nexpected %s equal to:\n%s\n\nbut got:\n%s",
|
||||
what, dumpValue(expected), dumpValue(actual))
|
||||
}
|
||||
}
|
||||
|
||||
func dumpValue(value interface{}) string {
|
||||
b, err := json.MarshalIndent(value, " ", " ")
|
||||
if err != nil {
|
||||
return " " + fmt.Sprintf("%#v", value)
|
||||
}
|
||||
return " " + string(b)
|
||||
}
|
120
test/e2e/framework/httpexpect/string.go
Normal file
120
test/e2e/framework/httpexpect/string.go
Normal file
|
@ -0,0 +1,120 @@
|
|||
/*
|
||||
Copyright 2022 The Kubernetes Authors.
|
||||
|
||||
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 httpexpect
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// String provides methods to inspect attached string value
|
||||
// (Go representation of JSON string).
|
||||
type String struct {
|
||||
chain chain
|
||||
value string
|
||||
}
|
||||
|
||||
// Raw returns underlying value attached to String.
|
||||
// This is the value originally passed to NewString.
|
||||
func (s *String) Raw() string {
|
||||
return s.value
|
||||
}
|
||||
|
||||
// Empty succeeds if string is empty.
|
||||
func (s *String) Empty() *String {
|
||||
return s.Equal("")
|
||||
}
|
||||
|
||||
// NotEmpty succeeds if string is non-empty.
|
||||
func (s *String) NotEmpty() *String {
|
||||
return s.NotEqual("")
|
||||
}
|
||||
|
||||
// Equal succeeds if string is equal to given Go string.
|
||||
func (s *String) Equal(value string) *String {
|
||||
if !(s.value == value) {
|
||||
s.chain.fail("\nexpected string equal to:\n %q\n\nbut got:\n %q", value, s.value)
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
// NotEqual succeeds if string is not equal to given Go string.
|
||||
func (s *String) NotEqual(value string) *String {
|
||||
if !(s.value != value) {
|
||||
s.chain.fail("\nexpected string not equal to:\n %q", value)
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
// Contains succeeds if string contains given Go string as a substring.
|
||||
func (s *String) Contains(value string) *String {
|
||||
if !strings.Contains(s.value, value) {
|
||||
s.chain.fail(
|
||||
"\nexpected string containing substring:\n %q\n\nbut got:\n %q",
|
||||
value, s.value)
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
// NotContains succeeds if string doesn't contain Go string as a substring.
|
||||
func (s *String) NotContains(value string) *String {
|
||||
if strings.Contains(s.value, value) {
|
||||
s.chain.fail("\nexpected string not containing substring:\n %q\n\nbut got:\n %q", value, s.value)
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
// ContainsFold succeeds if string contains given Go string as a substring after
|
||||
// applying Unicode case-folding (so it's a case-insensitive match).
|
||||
func (s *String) ContainsFold(value string) *String {
|
||||
if !strings.Contains(strings.ToLower(s.value), strings.ToLower(value)) {
|
||||
s.chain.fail("\nexpected string containing substring (case-insensitive):\n %q"+"\n\nbut got:\n %q", value, s.value)
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
// NotContainsFold succeeds if string doesn't contain given Go string as a substring
|
||||
// after applying Unicode case-folding (so it's a case-insensitive match).
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// str := NewString(t, "Hello")
|
||||
// str.NotContainsFold("BYE")
|
||||
func (s *String) NotContainsFold(value string) *String {
|
||||
if strings.Contains(strings.ToLower(s.value), strings.ToLower(value)) {
|
||||
s.chain.fail("\nexpected string not containing substring (case-insensitive):\n %q"+"\n\nbut got:\n %q", value, s.value)
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
// Match matches the string with given regexp and returns a new Match object
|
||||
// with found submatches.
|
||||
func (s *String) Match(re string) *Match {
|
||||
r, err := regexp.Compile(re)
|
||||
if err != nil {
|
||||
s.chain.fail(err.Error())
|
||||
return makeMatch(s.chain, nil, nil)
|
||||
}
|
||||
|
||||
m := r.FindStringSubmatch(s.value)
|
||||
if m == nil {
|
||||
s.chain.fail("\nexpected string matching regexp:\n `%s`\n\nbut got:\n %q", re, s.value)
|
||||
return makeMatch(s.chain, nil, nil)
|
||||
}
|
||||
|
||||
return makeMatch(s.chain, m, r.SubexpNames())
|
||||
}
|
33
test/e2e/framework/httpexpect/value.go
Normal file
33
test/e2e/framework/httpexpect/value.go
Normal file
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
Copyright 2022 The Kubernetes Authors.
|
||||
|
||||
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 httpexpect
|
||||
|
||||
// Value provides methods to inspect attached interface{} object
|
||||
// (Go representation of arbitrary JSON value) and cast it to
|
||||
// concrete type.
|
||||
type Value struct {
|
||||
chain chain
|
||||
value interface{}
|
||||
}
|
||||
|
||||
func (v *Value) String() *String {
|
||||
data, ok := v.value.(string)
|
||||
if !ok {
|
||||
v.chain.fail("\nexpected string value, but got:\n%s", dumpValue(v.value))
|
||||
}
|
||||
return &String{v.chain, data}
|
||||
}
|
|
@ -22,7 +22,8 @@ import (
|
|||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gavv/httpexpect/v2"
|
||||
"k8s.io/ingress-nginx/test/e2e/framework/httpexpect"
|
||||
|
||||
"github.com/onsi/ginkgo/v2"
|
||||
"github.com/stretchr/testify/assert"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
|
|
|
@ -21,7 +21,8 @@ import (
|
|||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gavv/httpexpect/v2"
|
||||
"k8s.io/ingress-nginx/test/e2e/framework/httpexpect"
|
||||
|
||||
"github.com/onsi/ginkgo/v2"
|
||||
"github.com/stretchr/testify/assert"
|
||||
appsv1 "k8s.io/api/apps/v1"
|
||||
|
|
Loading…
Reference in a new issue