Add e2e tests

This commit is contained in:
Manuel de Brito Fontes 2017-10-17 19:50:27 -03:00
parent 99a355f25d
commit 601fb7dacf
1163 changed files with 289217 additions and 14195 deletions

24
vendor/github.com/parnurzeal/gorequest/.gitignore generated vendored Normal file
View file

@ -0,0 +1,24 @@
# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
*.so
# Folders
_obj
_test
.idea
# Architecture specific extensions/prefixes
*.[568vq]
[568vq].out
*.cgo1.go
*.cgo2.c
_cgo_defun.c
_cgo_gotypes.go
_cgo_export.*
_testmain.go
*.exe
tags

15
vendor/github.com/parnurzeal/gorequest/.travis.yml generated vendored Normal file
View file

@ -0,0 +1,15 @@
language: go
go:
- 1.7
- 1.6
- 1.5
- 1.4
- 1.3
- 1.2
install:
- go get -t -v ./...
notifications:
email:
recipients: parnurzeal@gmail.com
on_success: change
on_failure: always

123
vendor/github.com/parnurzeal/gorequest/CHANGELOG generated vendored Normal file
View file

@ -0,0 +1,123 @@
Changelog
=========
v0.2.15 (2016-08-30)
Features
* Allow float and boolean in Query()'s queryStruct @davyzhang
* Support Map in Query() @yangmls
* Support Map in Send() @longlongh4
* Document RedirectPolicy @codegoalie
* Enable Debug mode by ENV variable @heytitle
* Add Retry() @xild
Bug/Fixes
* Allow bodies with all methods @pkopac
* Change std "errors" pkg to "github.com/pkg/errors" @pkopac
v0.2.14 (2016-08-30)
Features
* Support multipart @fraenky8
* Support OPTIONS request @coderhaoxin
* Add EndStruct method @franciscocpg
* Add AsCurlCommand @jaytaylor
* Add CustomMethod @WaveCutz
* Add MakeRequest @quangbuule
Bug/Fixes
* Disable keep alive by default
v0.2.13 (2015-11-21)
Features
* Add DisableTransportSwap to stop gorequest from modifying Transport settings.
Note that this will effect many functions that modify gorequest's
tranport. (So, use with caution.) (Bug #47, PR #59 by @piotrmiskiewicz)
v0.2.12 (2015-11-21)
Features
* Add SetCurlCommand for printing comparable CURL command of the request
(PR #60 by @QuentinPerez)
v0.2.11 (2015-10-24)
Bug/Fixes
* Add support to Slice data structure (Bug #40, #42)
* Refactor sendStruct to be public function SendStruct
v0.2.10 (2015-10-24)
Bug/Fixes
* Fix incorrect text output in tests (PR #52 by @QuentinPerez)
* Fix Panic and runtime error properly (PR #53 by @QuentinPerez)
* Add support for "text/plain" and "application/xml" (PR #51 by
@smallnest)
* Content-Type header is also equivalent with Type function to identify
supported Gorequest's Target Type
v0.2.9 (2015-08-16)
Bug/Fixes
* ParseQuery accepts ; as a synonym for &. thus Gorequest Query won't
accept ; as in a query string. We add additional Param to solve this (PR
#43 by @6david9)
* AddCookies for bulk adding cookies (PR #46 by @pencil001)
v0.2.8 (2015-08-10)
Bug/Fixes
* Added SetDebug and SetLogger for debug mode (PR #28 by @dafang)
* Ensure the response Body is reusable (PR #37 by alaingilbert)
v0.2.7 (2015-07-11)
Bug/Fixes
* Incorrectly reset "Authentication" header (Hot fix by @na-ga PR #38 & Issue #39)
v0.2.6 (2015-07-10)
Features
* Added EndBytes (PR #30 by @jaytaylor)
v0.2.5 (2015-07-01)
Features
* Added Basic Auth support (pull request #24 by @dickeyxxx)
Bug/Fixes
* Fix #31 incorrect number conversion (PR #34 by @killix)
v0.2.4 (2015-04-13)
Features
* Query() now supports Struct as same as Send() (pull request #25 by @figlief)
v0.2.3 (2015-02-08)
Features
* Added Patch HTTP Method
Bug/Fixes
* Refactored testing code
v0.2.2 (2015-01-03)
Features
* Added TLSClientConfig for better control over tls
* Added AddCookie func to set "Cookie" field in request (pull request #17 by @austinov) - Issue #7
* Added CookieJar (pull request #15 by @kemadz)
v0.2.1 (2014-07-06)
Features
* Implemented timeout test
Bugs/Fixes
* Improved timeout feature by control over both dial + read/write timeout compared to previously controlling only dial connection timeout.
v0.2.0 (2014-06-13) - Send is now supporting Struct type as a parameter
v0.1.0 (2014-04-14) - Finished release with enough rich functions to do get, post, json and redirectpolicy

73
vendor/github.com/parnurzeal/gorequest/CONTRIBUTING.md generated vendored Normal file
View file

@ -0,0 +1,73 @@
# Contributing to GoRequest
Thanks for taking the time to contribute!!
GoRequest welcomes any kind of contributions including documentation, bug reports,
issues, feature requests, feature implementations, pull requests, helping to manage and answer issues, etc.
### Code Guidelines
To make the contribution process as seamless as possible, we ask for the following:
* Go ahead and fork the project and make your changes. We encourage pull requests to allow for review and discussion of code changes.
* When youre ready to create a pull request, be sure to:
* Have test cases for the new code.
* Follow [GoDoc](https://blog.golang.org/godoc-documenting-go-code) guideline and always add documentation for new function/variable definitions.
* Run `go fmt`.
* Additonally, add documentation to README.md if you are adding new features or changing functionality.
* Squash your commits into a single commit. `git rebase -i`. Its okay to force update your pull request with `git push -f`.
* Make sure `go test ./...` passes, and `go build` completes.
* Follow the **Git Commit Message Guidelines** below.
### Writing Commit Message
Follow this [blog article](http://chris.beams.io/posts/git-commit/). It is a good resource for learning how to write good commit messages,
the most important part being that each commit message should have a title/subject in imperative mood starting with a capital letter and no trailing period:
*"Return error when sending incorrect JSON format"*, **NOT** *"returning some error."*
Also, if your commit references one or more GitHub issues, always end your commit message body with *See #1234* or *Fixes #1234*.
Replace *1234* with the GitHub issue ID. The last example will close the issue when the commit is merged into *master*.
### Sending a Pull Request
Due to the way Go handles package imports, the best approach for working on a
fork is to use Git Remotes. You can follow the instructions below:
1. Get the latest sources:
```
go get -u -t github.com/parnurzeal/gorequest/...
```
1. Change to the GoRequest source directory:
```
cd $GOPATH/src/github.com/parnurzeal/gorequest
```
1. Create a new branch for your changes (the branch name is arbitrary):
```
git checkout -b issue_1234
```
1. After making your changes, commit them to your new branch:
```
git commit -a -v
```
1. Fork GoRequest in Github.
1. Add your fork as a new remote (the remote name, "fork" in this example, is arbitrary):
```
git remote add fork git://github.com/USERNAME/gorequest.git
```
1. Push the changes to your new remote:
```
git push --set-upstream fork issue_1234
```
1. You're now ready to submit a PR based upon the new branch in your forked repository.

20
vendor/github.com/parnurzeal/gorequest/LICENSE generated vendored Normal file
View file

@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) 2014 Theeraphol Wattanavekin
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

328
vendor/github.com/parnurzeal/gorequest/README.md generated vendored Normal file
View file

@ -0,0 +1,328 @@
GoRequest
=========
GoRequest -- Simplified HTTP client ( inspired by famous SuperAgent lib in Node.js )
![GopherGoRequest](https://raw.githubusercontent.com/parnurzeal/gorequest/gh-pages/images/Gopher_GoRequest_400x300.jpg)
#### "Shooting Requests like a Machine Gun" - Gopher
Sending request would never been fun and easier than this. It comes with lots of feature:
* Get/Post/Put/Head/Delete/Patch/Options
* Set - simple header setting
* JSON - made it simple with JSON string as a parameter
* Multipart-Support - send data and files as multipart request
* Proxy - sending request via proxy
* Timeout - setting timeout for a request
* TLSClientConfig - taking control over tls where at least you can disable security check for https
* RedirectPolicy
* Cookie - setting cookies for your request
* CookieJar - automatic in-memory cookiejar
* BasicAuth - setting basic authentication header
* more to come..
## Installation
```bash
$ go get github.com/parnurzeal/gorequest
```
## Documentation
See [Go Doc](http://godoc.org/github.com/parnurzeal/gorequest) or [Go Walker](http://gowalker.org/github.com/parnurzeal/gorequest) for usage and details.
## Status
[![Drone Build Status](https://drone.io/github.com/jmcvetta/restclient/status.png)](https://drone.io/github.com/parnurzeal/gorequest/latest)
[![Travis Build Status](https://travis-ci.org/parnurzeal/gorequest.svg?branch=master)](https://travis-ci.org/parnurzeal/gorequest)
## Why should you use GoRequest?
GoRequest makes thing much more simple for you, making http client more awesome and fun like SuperAgent + golang style usage.
This is what you normally do for a simple GET without GoRequest:
```go
resp, err := http.Get("http://example.com/")
```
With GoRequest:
```go
request := gorequest.New()
resp, body, errs := request.Get("http://example.com/").End()
```
Or below if you don't want to reuse it for other requests.
```go
resp, body, errs := gorequest.New().Get("http://example.com/").End()
```
How about getting control over HTTP client headers, redirect policy, and etc. Things is getting more complicated in golang. You need to create a Client, setting header in different command, ... to do just only one __GET__
```go
client := &http.Client{
CheckRedirect: redirectPolicyFunc,
}
req, err := http.NewRequest("GET", "http://example.com", nil)
req.Header.Add("If-None-Match", `W/"wyzzy"`)
resp, err := client.Do(req)
```
Why making things ugly while you can just do as follows:
```go
request := gorequest.New()
resp, body, errs := request.Get("http://example.com").
RedirectPolicy(redirectPolicyFunc).
Set("If-None-Match", `W/"wyzzy"`).
End()
```
__DELETE__, __HEAD__, __POST__, __PUT__, __PATCH__ are now supported and can be used the same way as __GET__:
```go
request := gorequest.New()
resp, body, errs := request.Post("http://example.com").End()
// PUT -> request.Put("http://example.com").End()
// DELETE -> request.Delete("http://example.com").End()
// HEAD -> request.Head("http://example.com").End()
// ANYTHING -> request.CustomMethod("TRACE", "http://example.com").End()
```
### JSON
For a __JSON POST__ with standard libraries, you might need to marshal map data structure to json format, setting header to 'application/json' (and other headers if you need to) and declare http.Client. So, you code become longer and hard to maintain:
```go
m := map[string]interface{}{
"name": "backy",
"species": "dog",
}
mJson, _ := json.Marshal(m)
contentReader := bytes.NewReader(mJson)
req, _ := http.NewRequest("POST", "http://example.com", contentReader)
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Notes","GoRequest is coming!")
client := &http.Client{}
resp, _ := client.Do(req)
```
Compared to our GoRequest version, JSON is for sure a default. So, it turns out to be just one simple line!:
```go
request := gorequest.New()
resp, body, errs := request.Post("http://example.com").
Set("Notes","gorequst is coming!").
Send(`{"name":"backy", "species":"dog"}`).
End()
```
Moreover, it also supports struct type. So, you can have a fun __Mix & Match__ sending the different data types for your request:
```go
type BrowserVersionSupport struct {
Chrome string
Firefox string
}
ver := BrowserVersionSupport{ Chrome: "37.0.2041.6", Firefox: "30.0" }
request := gorequest.New()
resp, body, errs := request.Post("http://version.com/update").
Send(ver).
Send(`{"Safari":"5.1.10"}`).
End()
```
Not only for Send() but Query() is also supported. Just give it a try! :)
## Callback
Moreover, GoRequest also supports callback function. This gives you much more flexibility on using it. You can use it any way to match your own style!
Let's see a bit of callback example:
```go
func printStatus(resp gorequest.Response, body string, errs []error){
fmt.Println(resp.Status)
}
gorequest.New().Get("http://example.com").End(printStatus)
```
## Multipart/Form-Data
You can specify the content-type of the request to type `multipart` to send all data as `multipart/form-data`. This feature also allows you to send (multiple) files! Check the examples below!
```go
gorequest.New().Post("http://example.com/").
Type("multipart").
Send(`{"query1":"test"}`).
End()
```
The `SendFile` function accepts `strings` as path to a file, `[]byte` slice or even a `os.File`! You can also combine them to send multiple files with either custom name and/or custom fieldname:
```go
f, _ := filepath.Abs("./file2.txt")
bytesOfFile, _ := ioutil.ReadFile(f)
gorequest.New().Post("http://example.com/").
Type("multipart").
SendFile("./file1.txt").
SendFile(bytesOfFile, "file2.txt", "my_file_fieldname").
End()
```
Check the docs for `SendFile` to get more information about the types of arguments.
## Proxy
In the case when you are behind proxy, GoRequest can handle it easily with Proxy func:
```go
request := gorequest.New().Proxy("http://proxy:999")
resp, body, errs := request.Get("http://example-proxy.com").End()
// To reuse same client with no_proxy, use empty string:
resp, body, errs = request.Proxy("").Get("http://example-no-proxy.com").End()
```
## Basic Authentication
To add a basic authentication header:
```go
request := gorequest.New().SetBasicAuth("username", "password")
resp, body, errs := request.Get("http://example-proxy.com").End()
```
## Timeout
Timeout can be set in any time duration using time package:
```go
request := gorequest.New().Timeout(2*time.Millisecond)
resp, body, errs:= request.Get("http://example.com").End()
```
Timeout func defines both dial + read/write timeout to the specified time parameter.
## EndBytes
Thanks to @jaytaylor, we now have EndBytes to use when you want the body as bytes.
The callbacks work the same way as with `End`, except that a byte array is used instead of a string.
```go
resp, bodyBytes, errs := gorequest.New().Get("http://example.com/").EndBytes()
```
## EndStruct
We now have EndStruct to use when you want the body as struct.
The callbacks work the same way as with `End`, except that a struct is used instead of a string.
Supposing the URL **http://example.com/** returns the body `{"hey":"you"}`
```go
heyYou struct {
Hey string `json:"hey"`
}
var heyYou heyYou
resp, _, errs := gorequest.New().Get("http://example.com/").EndStruct(&heyYou)
```
## Retry
Supposing you need retry 3 times, with 5 seconds between each attempt when gets a BadRequest or a InternalServerError
```go
request := gorequest.New()
resp, body, errs := request.Get("http://example.com/").
Retry(3, 5 * time.seconds, http.StatusBadRequest, http.StatusInternalServerError).
End()
```
## Handling Redirects
Redirects can be handled with RedirectPolicy which behaves similarly to
net/http Client's [CheckRedirect
function](https://golang.org/pkg/net/http#Client). Simply specify a function
which takes the Request about to be made and a slice of previous Requests in
order of oldest first. When this function returns an error, the Request is not
made.
For example to redirect only to https endpoints:
```go
request := gorequest.New()
resp, body, errs := request.Get("http://example.com/").
RedirectPolicy(func(req Request, via []*Request) error {
if req.URL.Scheme != "https" {
return http.ErrUseLastResponse
}
}).
End()
```
## Debug
For debugging, GoRequest leverages `httputil` to dump details of every request/response. (Thanks to @dafang)
You can just use `SetDebug` or environment variable `GOREQUEST_DEBUG=0|1` to enable/disable debug mode and `SetLogger` to set your own choice of logger.
Thanks to @QuentinPerez, we can see even how gorequest is compared to CURL by using `SetCurlCommand`.
## Noted
As the underlying gorequest is based on http.Client in most use cases, gorequest.New() should be called once and reuse gorequest as much as possible.
## Contributing to GoRequest:
If you find any improvement or issue you want to fix, feel free to send me a pull request with testing.
Thanks to all contributors thus far:
| Contributors |
|---------------------------------------|
| https://github.com/alaingilbert |
| https://github.com/austinov |
| https://github.com/coderhaoxin |
| https://github.com/codegoalie |
| https://github.com/dafang |
| https://github.com/davyzhang |
| https://github.com/dickeyxxx |
| https://github.com/figlief |
| https://github.com/fraenky8 |
| https://github.com/franciscocpg |
| https://github.com/heytitle |
| https://github.com/hownowstephen |
| https://github.com/kemadz |
| https://github.com/killix |
| https://github.com/jaytaylor |
| https://github.com/na-ga |
| https://github.com/piotrmiskiewicz |
| https://github.com/pencil001 |
| https://github.com/pkopac |
| https://github.com/quangbuule |
| https://github.com/QuentinPerez |
| https://github.com/smallnest |
| https://github.com/WaveCutz |
| https://github.com/xild |
| https://github.com/yangmls |
| https://github.com/6david9 |
Also, co-maintainer is needed here. If anyone is interested, please email me (parnurzeal at gmail.com)
## Credits
* Renee French - the creator of Gopher mascot
* [Wisi Mongkhonsrisawat](https://www.facebook.com/puairw) for providing an awesome GoRequest's Gopher image :)
## License
GoRequest is MIT License.

1238
vendor/github.com/parnurzeal/gorequest/gorequest.go generated vendored Normal file

File diff suppressed because it is too large Load diff

1776
vendor/github.com/parnurzeal/gorequest/gorequest_test.go generated vendored Normal file

File diff suppressed because it is too large Load diff