Skip to content

Commit

Permalink
Merge d3ee82d into d5157a5
Browse files Browse the repository at this point in the history
  • Loading branch information
pshopper committed May 16, 2019
2 parents d5157a5 + d3ee82d commit bac0807
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 4 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,10 @@ func (c *Client) PushWithContext(ctx Context, n *Notification) (*Response, error
}

url := fmt.Sprintf("%v/3/device/%v", c.Host, n.DeviceToken)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(payload))
req, err := http.NewRequest("POST", url, bytes.NewBuffer(payload))
if err != nil {
return nil, err
}

if c.Token != nil {
c.setTokenHeader(req)
Expand Down
9 changes: 9 additions & 0 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,15 @@ func TestClientBadTransportError(t *testing.T) {
assert.Nil(t, res)
}

func TestClientBadDeviceToken(t *testing.T) {
n := &apns.Notification{}
n.DeviceToken = "DGw\aOoD+HwSroh#Ug]%xzd]"
n.Payload = []byte(`{"aps":{"alert":"Hello!"}}`)
res, err := mockClient("https://api.push.apple.com").Push(n)
assert.Error(t, err)
assert.Nil(t, res)
}

func TestClientNameToCertificate(t *testing.T) {
crt, _ := certificate.FromP12File("certificate/_fixtures/certificate-valid.p12", "")
client := apns.NewClient(crt)
Expand Down

0 comments on commit bac0807

Please sign in to comment.