@@ -1305,12 +1305,12 @@ var SendTestCasesWAC = []OutgoingTestCase{
1305
1305
Label : "Audio Send" ,
1306
1306
MsgText : "audio caption" ,
1307
1307
MsgURN : "whatsapp:250788123123" ,
1308
- MsgAttachments : []string {"audio/mpeg:https ://foo.bar/audio .mp3" },
1308
+ MsgAttachments : []string {"audio/mpeg:http ://mock.com/3456/test .mp3" },
1309
1309
MockResponses : map [MockedRequest ]* httpx.MockResponse {
1310
1310
{
1311
1311
Method : "POST" ,
1312
1312
Path : "/12345_ID/messages" ,
1313
- Body : `{"messaging_product":"whatsapp","recipient_type":"individual","to":"250788123123","type":"audio","audio":{"link":"https ://foo.bar/audio .mp3"}}` ,
1313
+ Body : `{"messaging_product":"whatsapp","recipient_type":"individual","to":"250788123123","type":"audio","audio":{"link":"http ://mock.com/3456/test .mp3"}}` ,
1314
1314
}: httpx .NewMockResponse (201 , nil , []byte (`{ "messages": [{"id": "157b5e14568e8"}] }` )),
1315
1315
{
1316
1316
Method : "POST" ,
@@ -1326,10 +1326,10 @@ var SendTestCasesWAC = []OutgoingTestCase{
1326
1326
Label : "Document Send" ,
1327
1327
MsgText : "document caption" ,
1328
1328
MsgURN : "whatsapp:250788123123" ,
1329
- MsgAttachments : []string {"application/pdf:https ://foo.bar/document .pdf" },
1329
+ MsgAttachments : []string {"application/pdf:http ://mock.com/7890/test .pdf" },
1330
1330
MockResponseBody : `{ "messages": [{"id": "157b5e14568e8"}] }` ,
1331
1331
MockResponseStatus : 201 ,
1332
- ExpectedRequestBody : `{"messaging_product":"whatsapp","recipient_type":"individual","to":"250788123123","type":"document","document":{"link":"https ://foo.bar/document .pdf","caption":"document caption","filename":"document .pdf"}}` ,
1332
+ ExpectedRequestBody : `{"messaging_product":"whatsapp","recipient_type":"individual","to":"250788123123","type":"document","document":{"link":"http ://mock.com/7890/test .pdf","caption":"document caption","filename":"test .pdf"}}` ,
1333
1333
ExpectedRequestPath : "/12345_ID/messages" ,
1334
1334
ExpectedMsgStatus : "W" ,
1335
1335
ExpectedExternalID : "157b5e14568e8" ,
@@ -1339,10 +1339,10 @@ var SendTestCasesWAC = []OutgoingTestCase{
1339
1339
Label : "Image Send" ,
1340
1340
MsgText : "image caption" ,
1341
1341
MsgURN : "whatsapp:250788123123" ,
1342
- MsgAttachments : []string {"image/jpeg:https ://foo.bar/image .jpg" },
1342
+ MsgAttachments : []string {"image/jpeg:http ://mock.com/1234/test .jpg" },
1343
1343
MockResponseBody : `{ "messages": [{"id": "157b5e14568e8"}] }` ,
1344
1344
MockResponseStatus : 201 ,
1345
- ExpectedRequestBody : `{"messaging_product":"whatsapp","recipient_type":"individual","to":"250788123123","type":"image","image":{"link":"https ://foo.bar/image .jpg","caption":"image caption"}}` ,
1345
+ ExpectedRequestBody : `{"messaging_product":"whatsapp","recipient_type":"individual","to":"250788123123","type":"image","image":{"link":"http ://mock.com/1234/test .jpg","caption":"image caption"}}` ,
1346
1346
ExpectedRequestPath : "/12345_ID/messages" ,
1347
1347
ExpectedMsgStatus : "W" ,
1348
1348
ExpectedExternalID : "157b5e14568e8" ,
@@ -1352,10 +1352,10 @@ var SendTestCasesWAC = []OutgoingTestCase{
1352
1352
Label : "Sticker Send" ,
1353
1353
MsgText : "sticker caption" ,
1354
1354
MsgURN : "whatsapp:250788123123" ,
1355
- MsgAttachments : []string {"image/webp:https ://foo.bar/sticker .webp" },
1355
+ MsgAttachments : []string {"image/webp:http ://mock.com/8901/test .webp" },
1356
1356
MockResponseBody : `{ "messages": [{"id": "157b5e14568e8"}] }` ,
1357
1357
MockResponseStatus : 201 ,
1358
- ExpectedRequestBody : `{"messaging_product":"whatsapp","recipient_type":"individual","to":"250788123123","type":"sticker","sticker":{"link":"https ://foo.bar/sticker .webp","caption":"sticker caption"}}` ,
1358
+ ExpectedRequestBody : `{"messaging_product":"whatsapp","recipient_type":"individual","to":"250788123123","type":"sticker","sticker":{"link":"http ://mock.com/8901/test .webp","caption":"sticker caption"}}` ,
1359
1359
ExpectedRequestPath : "/12345_ID/messages" ,
1360
1360
ExpectedMsgStatus : "W" ,
1361
1361
ExpectedExternalID : "157b5e14568e8" ,
@@ -1365,10 +1365,10 @@ var SendTestCasesWAC = []OutgoingTestCase{
1365
1365
Label : "Video Send" ,
1366
1366
MsgText : "video caption" ,
1367
1367
MsgURN : "whatsapp:250788123123" ,
1368
- MsgAttachments : []string {"video/mp4:https ://foo.bar/video .mp4" },
1368
+ MsgAttachments : []string {"video/mp4:http ://mock.com/5678/test .mp4" },
1369
1369
MockResponseBody : `{ "messages": [{"id": "157b5e14568e8"}] }` ,
1370
1370
MockResponseStatus : 201 ,
1371
- ExpectedRequestBody : `{"messaging_product":"whatsapp","recipient_type":"individual","to":"250788123123","type":"video","video":{"link":"https ://foo.bar/video .mp4","caption":"video caption"}}` ,
1371
+ ExpectedRequestBody : `{"messaging_product":"whatsapp","recipient_type":"individual","to":"250788123123","type":"video","video":{"link":"http ://mock.com/5678/test .mp4","caption":"video caption"}}` ,
1372
1372
ExpectedRequestPath : "/12345_ID/messages" ,
1373
1373
ExpectedMsgStatus : "W" ,
1374
1374
ExpectedExternalID : "157b5e14568e8" ,
@@ -1455,10 +1455,10 @@ var SendTestCasesWAC = []OutgoingTestCase{
1455
1455
MsgText : "Interactive Button Msg" ,
1456
1456
MsgURN : "whatsapp:250788123123" ,
1457
1457
MsgQuickReplies : []string {"BUTTON1" },
1458
- MsgAttachments : []string {"image/jpeg:https ://foo.bar/image .jpg" },
1458
+ MsgAttachments : []string {"image/jpeg:http ://mock.com/1234/test .jpg" },
1459
1459
MockResponseBody : `{ "messages": [{"id": "157b5e14568e8"}] }` ,
1460
1460
MockResponseStatus : 201 ,
1461
- ExpectedRequestBody : `{"messaging_product":"whatsapp","recipient_type":"individual","to":"250788123123","type":"interactive","interactive":{"type":"button","header":{"type":"image","image":{"link":"https ://foo.bar/image .jpg"}},"body":{"text":"Interactive Button Msg"},"action":{"buttons":[{"type":"reply","reply":{"id":"0","title":"BUTTON1"}}]}}}` ,
1461
+ ExpectedRequestBody : `{"messaging_product":"whatsapp","recipient_type":"individual","to":"250788123123","type":"interactive","interactive":{"type":"button","header":{"type":"image","image":{"link":"http ://mock.com/1234/test .jpg"}},"body":{"text":"Interactive Button Msg"},"action":{"buttons":[{"type":"reply","reply":{"id":"0","title":"BUTTON1"}}]}}}` ,
1462
1462
ExpectedRequestPath : "/12345_ID/messages" ,
1463
1463
ExpectedMsgStatus : "W" ,
1464
1464
ExpectedExternalID : "157b5e14568e8" ,
@@ -1469,10 +1469,10 @@ var SendTestCasesWAC = []OutgoingTestCase{
1469
1469
MsgText : "Interactive Button Msg" ,
1470
1470
MsgURN : "whatsapp:250788123123" ,
1471
1471
MsgQuickReplies : []string {"BUTTON1" },
1472
- MsgAttachments : []string {"video/mp4:https ://foo.bar/video .mp4" },
1472
+ MsgAttachments : []string {"video/mp4:http ://mock.com/5678/test .mp4" },
1473
1473
MockResponseBody : `{ "messages": [{"id": "157b5e14568e8"}] }` ,
1474
1474
MockResponseStatus : 201 ,
1475
- ExpectedRequestBody : `{"messaging_product":"whatsapp","recipient_type":"individual","to":"250788123123","type":"interactive","interactive":{"type":"button","header":{"type":"video","video":{"link":"https ://foo.bar/video .mp4"}},"body":{"text":"Interactive Button Msg"},"action":{"buttons":[{"type":"reply","reply":{"id":"0","title":"BUTTON1"}}]}}}` ,
1475
+ ExpectedRequestBody : `{"messaging_product":"whatsapp","recipient_type":"individual","to":"250788123123","type":"interactive","interactive":{"type":"button","header":{"type":"video","video":{"link":"http ://mock.com/5678/test .mp4"}},"body":{"text":"Interactive Button Msg"},"action":{"buttons":[{"type":"reply","reply":{"id":"0","title":"BUTTON1"}}]}}}` ,
1476
1476
ExpectedRequestPath : "/12345_ID/messages" ,
1477
1477
ExpectedMsgStatus : "W" ,
1478
1478
ExpectedExternalID : "157b5e14568e8" ,
@@ -1483,10 +1483,10 @@ var SendTestCasesWAC = []OutgoingTestCase{
1483
1483
MsgText : "Interactive Button Msg" ,
1484
1484
MsgURN : "whatsapp:250788123123" ,
1485
1485
MsgQuickReplies : []string {"BUTTON1" },
1486
- MsgAttachments : []string {"document/pdf:https ://foo.bar/document .pdf" },
1486
+ MsgAttachments : []string {"document/pdf:http ://mock.com/7890/test .pdf" },
1487
1487
MockResponseBody : `{ "messages": [{"id": "157b5e14568e8"}] }` ,
1488
1488
MockResponseStatus : 201 ,
1489
- ExpectedRequestBody : `{"messaging_product":"whatsapp","recipient_type":"individual","to":"250788123123","type":"interactive","interactive":{"type":"button","header":{"type":"document","document":{"link":"https ://foo.bar/document .pdf","filename":"document .pdf"}},"body":{"text":"Interactive Button Msg"},"action":{"buttons":[{"type":"reply","reply":{"id":"0","title":"BUTTON1"}}]}}}` ,
1489
+ ExpectedRequestBody : `{"messaging_product":"whatsapp","recipient_type":"individual","to":"250788123123","type":"interactive","interactive":{"type":"button","header":{"type":"document","document":{"link":"http ://mock.com/7890/test .pdf","filename":"test .pdf"}},"body":{"text":"Interactive Button Msg"},"action":{"buttons":[{"type":"reply","reply":{"id":"0","title":"BUTTON1"}}]}}}` ,
1490
1490
ExpectedRequestPath : "/12345_ID/messages" ,
1491
1491
ExpectedMsgStatus : "W" ,
1492
1492
ExpectedExternalID : "157b5e14568e8" ,
@@ -1497,12 +1497,12 @@ var SendTestCasesWAC = []OutgoingTestCase{
1497
1497
MsgText : "Interactive Button Msg" ,
1498
1498
MsgURN : "whatsapp:250788123123" ,
1499
1499
MsgQuickReplies : []string {"ROW1" , "ROW2" , "ROW3" },
1500
- MsgAttachments : []string {"audio/mp3:https ://foo.bar/audio .mp3" },
1500
+ MsgAttachments : []string {"audio/mp3:http ://mock.com/3456/test .mp3" },
1501
1501
MockResponses : map [MockedRequest ]* httpx.MockResponse {
1502
1502
{
1503
1503
Method : "POST" ,
1504
1504
Path : "/12345_ID/messages" ,
1505
- Body : `{"messaging_product":"whatsapp","recipient_type":"individual","to":"250788123123","type":"audio","audio":{"link":"https ://foo.bar/audio .mp3"}}` ,
1505
+ Body : `{"messaging_product":"whatsapp","recipient_type":"individual","to":"250788123123","type":"audio","audio":{"link":"http ://mock.com/3456/test .mp3"}}` ,
1506
1506
}: httpx .NewMockResponse (201 , nil , []byte (`{ "messages": [{"id": "157b5e14568e8"}] }` )),
1507
1507
{
1508
1508
Method : "POST" ,
@@ -1519,12 +1519,12 @@ var SendTestCasesWAC = []OutgoingTestCase{
1519
1519
MsgText : "Interactive List Msg" ,
1520
1520
MsgURN : "whatsapp:250788123123" ,
1521
1521
MsgQuickReplies : []string {"ROW1" , "ROW2" , "ROW3" , "ROW4" },
1522
- MsgAttachments : []string {"image/jpeg:https ://foo.bar/image .jpg" },
1522
+ MsgAttachments : []string {"image/jpeg:http ://mock.com/1234/test .jpg" },
1523
1523
MockResponses : map [MockedRequest ]* httpx.MockResponse {
1524
1524
{
1525
1525
Method : "POST" ,
1526
1526
Path : "/12345_ID/messages" ,
1527
- Body : `{"messaging_product":"whatsapp","recipient_type":"individual","to":"250788123123","type":"image","image":{"link":"https ://foo.bar/image .jpg"}}` ,
1527
+ Body : `{"messaging_product":"whatsapp","recipient_type":"individual","to":"250788123123","type":"image","image":{"link":"http ://mock.com/1234/test .jpg"}}` ,
1528
1528
}: httpx .NewMockResponse (201 , nil , []byte (`{ "messages": [{"id": "157b5e14568e8"}] }` )),
1529
1529
{
1530
1530
Method : "POST" ,
@@ -1570,7 +1570,32 @@ var SendTestCasesWAC = []OutgoingTestCase{
1570
1570
},
1571
1571
}
1572
1572
1573
+ // setupMedia takes care of having the media files needed to our test server host
1574
+ func setupMedia (mb * test.MockBackend ) {
1575
+ imageJPG := test .NewMockMedia ("test.jpg" , "image/jpeg" , "http://mock.com/1234/test.jpg" , 1024 * 1024 , 640 , 480 , 0 , nil )
1576
+
1577
+ audioM4A := test .NewMockMedia ("test.m4a" , "audio/mp4" , "http://mock.com/2345/test.m4a" , 1024 * 1024 , 0 , 0 , 200 , nil )
1578
+ audioMP3 := test .NewMockMedia ("test.mp3" , "audio/mpeg" , "http://mock.com/3456/test.mp3" , 1024 * 1024 , 0 , 0 , 200 , []courier.Media {audioM4A })
1579
+
1580
+ thumbJPG := test .NewMockMedia ("test.jpg" , "image/jpeg" , "http://mock.com/4567/test.jpg" , 1024 * 1024 , 640 , 480 , 0 , nil )
1581
+ videoMP4 := test .NewMockMedia ("test.mp4" , "video/mp4" , "http://mock.com/5678/test.mp4" , 1024 * 1024 , 0 , 0 , 1000 , []courier.Media {thumbJPG })
1582
+
1583
+ videoMOV := test .NewMockMedia ("test.mov" , "video/quicktime" , "http://mock.com/6789/test.mov" , 100 * 1024 * 1024 , 0 , 0 , 2000 , nil )
1584
+
1585
+ filePDF := test .NewMockMedia ("test.pdf" , "application/pdf" , "http://mock.com/7890/test.pdf" , 100 * 1024 * 1024 , 0 , 0 , 0 , nil )
1586
+
1587
+ stickerWEBP := test .NewMockMedia ("test.webp" , "image/webp" , "http://mock.com/8901/test.webp" , 50 * 1024 , 480 , 480 , 0 , nil )
1588
+
1589
+ mb .MockMedia (imageJPG )
1590
+ mb .MockMedia (audioMP3 )
1591
+ mb .MockMedia (videoMP4 )
1592
+ mb .MockMedia (videoMOV )
1593
+ mb .MockMedia (filePDF )
1594
+ mb .MockMedia (stickerWEBP )
1595
+ }
1596
+
1573
1597
func TestOutgoing (t * testing.T ) {
1598
+
1574
1599
// shorter max msg length for testing
1575
1600
maxMsgLength = 100
1576
1601
@@ -1582,7 +1607,7 @@ func TestOutgoing(t *testing.T) {
1582
1607
1583
1608
RunOutgoingTestCases (t , ChannelFBA , newHandler ("FBA" , "Facebook" , false ), SendTestCasesFBA , checkRedacted , nil )
1584
1609
RunOutgoingTestCases (t , ChannelIG , newHandler ("IG" , "Instagram" , false ), SendTestCasesIG , checkRedacted , nil )
1585
- RunOutgoingTestCases (t , ChannelWAC , newHandler ("WAC" , "Cloud API WhatsApp" , false ), SendTestCasesWAC , checkRedacted , nil )
1610
+ RunOutgoingTestCases (t , ChannelWAC , newHandler ("WAC" , "Cloud API WhatsApp" , false ), SendTestCasesWAC , checkRedacted , setupMedia )
1586
1611
}
1587
1612
1588
1613
func TestSigning (t * testing.T ) {
0 commit comments