Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions handlers/bandwidth/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
)

const (
configAccountID = "account_id"
configApplicationID = "application_id"
configAccountID = "account_id"
configMsgApplicationID = "messaging_application_id"

oldApplicationID = "application_id"
)

func init() {
Expand Down Expand Up @@ -177,7 +179,10 @@
username := msg.Channel().StringConfigForKey(courier.ConfigUsername, "")
password := msg.Channel().StringConfigForKey(courier.ConfigPassword, "")
accountID := msg.Channel().StringConfigForKey(configAccountID, "")
applicationID := msg.Channel().StringConfigForKey(configApplicationID, "")
applicationID := msg.Channel().StringConfigForKey(configMsgApplicationID, "")
if applicationID == "" {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To support the application_id config before the migration is applied

applicationID = msg.Channel().StringConfigForKey(oldApplicationID, "")
}

Check warning on line 185 in handlers/bandwidth/handler.go

View check run for this annotation

Codecov / codecov/patch

handlers/bandwidth/handler.go#L184-L185

Added lines #L184 - L185 were not covered by tests

if username == "" || password == "" || accountID == "" || applicationID == "" {
return courier.ErrChannelConfig
Expand Down
6 changes: 3 additions & 3 deletions handlers/bandwidth/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ func TestIncoming(t *testing.T) {
chs := []courier.Channel{
test.NewMockChannel("8eb23e93-5ecb-45ba-b726-3b064e0c56ab", "BW", "2020", "US",
[]string{urns.Phone.Prefix},
map[string]any{courier.ConfigUsername: "user1", courier.ConfigPassword: "pass1", configAccountID: "accound-id", configApplicationID: "application-id"},
map[string]any{courier.ConfigUsername: "user1", courier.ConfigPassword: "pass1", configAccountID: "accound-id", configMsgApplicationID: "application-id"},
),
}

Expand Down Expand Up @@ -357,7 +357,7 @@ var outgoingCases = []OutgoingTestCase{
func TestOutgoing(t *testing.T) {
ch := test.NewMockChannel("8eb23e93-5ecb-45ba-b726-3b064e0c56ab", "BW", "2020", "US",
[]string{urns.Phone.Prefix},
map[string]any{courier.ConfigUsername: "user1", courier.ConfigPassword: "pass1", configAccountID: "accound-id", configApplicationID: "application-id"},
map[string]any{courier.ConfigUsername: "user1", courier.ConfigPassword: "pass1", configAccountID: "accound-id", configMsgApplicationID: "application-id"},
)

RunOutgoingTestCases(t, ch, newHandler(), outgoingCases, []string{httpx.BasicAuth("user1", "pass1")}, nil)
Expand All @@ -367,7 +367,7 @@ func TestBuildAttachmentRequest(t *testing.T) {
mb := test.NewMockBackend()
ch := test.NewMockChannel("8eb23e93-5ecb-45ba-b726-3b064e0c56ab", "BW", "2020", "US",
[]string{urns.Phone.Prefix},
map[string]any{courier.ConfigUsername: "user1", courier.ConfigPassword: "pass1", configAccountID: "accound-id", configApplicationID: "application-id"},
map[string]any{courier.ConfigUsername: "user1", courier.ConfigPassword: "pass1", configAccountID: "accound-id", configMsgApplicationID: "application-id"},
)

bwHandler := &handler{NewBaseHandler(courier.ChannelType("BW"), "Bandwidth")}
Expand Down