Skip to content

Commit

Permalink
Add test for wrong authorization from YO! API
Browse files Browse the repository at this point in the history
  • Loading branch information
norkans7 committed Aug 9, 2017
1 parent e263e31 commit f1d2cf3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 4 additions & 2 deletions handlers/yo/yo.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ func (h *handler) SendMsg(msg courier.Msg) (courier.MsgStatus, error) {
"password": []string{password},
}

var status courier.MsgStatus
encodedForm := form.Encode()
sendURLs := []string{sendURL1, sendURL2, sendURL3}

Expand All @@ -206,7 +207,7 @@ func (h *handler) SendMsg(msg courier.Msg) (courier.MsgStatus, error) {
failed = true
}
// record our status and log
status := h.Backend().NewMsgStatusForID(msg.Channel(), msg.ID(), courier.MsgErrored)
status = h.Backend().NewMsgStatusForID(msg.Channel(), msg.ID(), courier.MsgErrored)
status.AddLog(courier.NewChannelLogFromRR(msg.Channel(), msg.ID(), rr))
if err != nil {
return status, err
Expand Down Expand Up @@ -242,12 +243,13 @@ func (h *handler) SendMsg(msg courier.Msg) (courier.MsgStatus, error) {
h.Backend().StopMsgContact(msg)
return status, nil
}

if failed == false {
status.SetStatus(courier.MsgWired)
return status, nil
}

}

return nil, errors.Errorf("Received error from Yo! API")
return status, errors.Errorf("Received error from Yo! API")
}
7 changes: 7 additions & 0 deletions handlers/yo/yo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ var getSendTestCases = []ChannelSendTestCase{
URLParams: map[string]string{"sms_content": "Simple Message", "destinations": string("250788383383"), "origin": "2020"},
SendPrep: setSendURL,
Stopped: true},
{Label: "Errored wrong authorization",
Text: "Simple Message", URN: "tel:+250788383383",
Status: "E",
Error: "Received error from Yo! API",
ResponseBody: "ybs_autocreate_status=ERROR&ybs_autocreate_message=YBS+AutoCreate+Subsystem%3A+Access+denied+due+to+wrong+authorization+code", ResponseStatus: 200,
URLParams: map[string]string{"sms_content": "Simple Message", "destinations": string("250788383383"), "origin": "2020"},
SendPrep: setSendURL},
{Label: "Unicode Send",
Text: "☺", URN: "tel:+250788383383",
Status: "W",
Expand Down

0 comments on commit f1d2cf3

Please sign in to comment.