forked from Mirrors/go-iap
Bring tests back up to 100%
Make a new method called parseResponse which essentially allows us to feed it our own response so that we can feed it bad body so that it cannot unmarshal or even read it.
This commit is contained in:
@@ -115,7 +115,10 @@ func (c *Client) Verify(req IAPRequest, result interface{}) error {
|
||||
return err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
return c.parseResponse(resp, result, client, req)
|
||||
}
|
||||
|
||||
func (c *Client) parseResponse(resp *http.Response, result interface{}, client http.Client, req IAPRequest) error {
|
||||
// Read the body now so that we can unmarshal it twice
|
||||
buf, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
@@ -134,7 +137,7 @@ func (c *Client) Verify(req IAPRequest, result interface{}) error {
|
||||
return err
|
||||
}
|
||||
if r.Status == 21007 {
|
||||
b = new(bytes.Buffer)
|
||||
b := new(bytes.Buffer)
|
||||
json.NewEncoder(b).Encode(req)
|
||||
resp, err := client.Post(c.SandboxURL, "application/json; charset=utf-8", b)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user