Skip to content

Commit

Permalink
Merge pull request #156 from sgdesmet/fix/dependency_vulnerability
Browse files Browse the repository at this point in the history
Bump `com.squareup.okhttp3.version` to `5.0.0-alpha.12` + migration
  • Loading branch information
Bindambc authored May 6, 2024
2 parents 073ba19 + d2277a3 commit f000f9d
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 83 deletions.
3 changes: 2 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
<com.squareup.retrofit2.version>2.9.0</com.squareup.retrofit2.version>
<org.mockito.version>5.2.0</org.mockito.version>
<org.junit.jupiter.version>5.10.1</org.junit.jupiter.version>
<com.squareup.okhttp3.version>5.0.0-alpha.11</com.squareup.okhttp3.version>
<com.squareup.okhttp3.version>5.0.0-alpha.12</com.squareup.okhttp3.version>

</properties>

<distributionManagement>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public class WhatsappBusinessCloudApiTest extends MockServerUtilsTest {

@Test
void testSendMessageError() throws InterruptedException {
mockWebServer.enqueue(new MockResponse().setResponseCode(500).setBody("{" +//
mockWebServer.enqueue(new MockResponse().newBuilder().code(500).body("{" +//
" \"error\": {\n" +//
" \"message\": \"(#130429) Rate limit hit\",\n" +//
" \"type\": \"OAuthException\",\n" +//
Expand All @@ -111,7 +111,7 @@ void testSendMessageError() throws InterruptedException {
" \"error_subcode\": 2494055,\n" +//
" \"fbtrace_id\": \"Az8or2yhqkZfEZ-_4Qn_Bam\"\n" +//
" }\n" +//
"}"));
"}").build());


var message = MessageBuilder.builder()//
Expand All @@ -135,7 +135,7 @@ void testSendMessageError() throws InterruptedException {

@Test
void testSendTextMessage() throws IOException, URISyntaxException, InterruptedException, JSONException {
mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(DEFAULT_SEND_MESSAGE_RESPONSE));
mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(DEFAULT_SEND_MESSAGE_RESPONSE).build());

var expectedJson = fromResource(EXPECTED_FOLDER + "expectedMessage1.json");

Expand All @@ -159,7 +159,7 @@ void testSendTextMessage() throws IOException, URISyntaxException, InterruptedEx

@Test
void testSendContactMessage() throws IOException, URISyntaxException, InterruptedException, JSONException {
mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(DEFAULT_SEND_MESSAGE_RESPONSE));
mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(DEFAULT_SEND_MESSAGE_RESPONSE).build());

var expectedJson = fromResource(EXPECTED_FOLDER + "expectedMessage10.json");

Expand Down Expand Up @@ -211,7 +211,7 @@ void testSendContactMessage() throws IOException, URISyntaxException, Interrupte

@Test
void testSendContactMessage2() throws IOException, URISyntaxException, InterruptedException, JSONException {
mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(DEFAULT_SEND_MESSAGE_RESPONSE));
mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(DEFAULT_SEND_MESSAGE_RESPONSE).build());

var expectedJson = fromResource(EXPECTED_FOLDER + "expectedMessage10.json");

Expand Down Expand Up @@ -263,7 +263,7 @@ void testSendContactMessage2() throws IOException, URISyntaxException, Interrupt

@Test
void testSendTemplateTextMessage() throws IOException, URISyntaxException, InterruptedException, JSONException {
mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(DEFAULT_SEND_MESSAGE_RESPONSE));
mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(DEFAULT_SEND_MESSAGE_RESPONSE).build());

var expectedJson = fromResource(EXPECTED_FOLDER + "expectedMessage2.json");

Expand All @@ -288,7 +288,7 @@ void testSendTemplateTextMessage() throws IOException, URISyntaxException, Inter

@Test
void testSendTemplateButtonMessage() throws IOException, URISyntaxException, InterruptedException, JSONException {
mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(DEFAULT_SEND_MESSAGE_RESPONSE));
mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(DEFAULT_SEND_MESSAGE_RESPONSE).build());

var expectedJson = fromResource(EXPECTED_FOLDER + "expectedMessage3.json");

Expand Down Expand Up @@ -327,7 +327,7 @@ void testSendTemplateButtonMessage() throws IOException, URISyntaxException, Int

@Test
void testSendTemplateButtonMessageWithDateTimeParam() throws IOException, URISyntaxException, InterruptedException, JSONException {
mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(DEFAULT_SEND_MESSAGE_RESPONSE));
mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(DEFAULT_SEND_MESSAGE_RESPONSE).build());

var expectedJson = fromResource(EXPECTED_FOLDER + "expectedMessage4.json");

Expand Down Expand Up @@ -380,7 +380,7 @@ void testSendTemplateButtonMessageWithDateTimeParam() throws IOException, URISyn

@Test
void testSendTemplateButtonMessageMarketing() throws IOException, URISyntaxException, InterruptedException, JSONException {
mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(DEFAULT_SEND_MESSAGE_RESPONSE));
mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(DEFAULT_SEND_MESSAGE_RESPONSE).build());

var expectedJson = fromResource(EXPECTED_FOLDER + "expectedMessage5.json");

Expand Down Expand Up @@ -430,7 +430,7 @@ void testSendTemplateButtonMessageMarketing() throws IOException, URISyntaxExcep

@Test
void testSendTemplateDocumentPdfMessage() throws IOException, URISyntaxException, InterruptedException, JSONException {
mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(DEFAULT_SEND_MESSAGE_RESPONSE));
mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(DEFAULT_SEND_MESSAGE_RESPONSE).build());

var expectedJson = fromResource(EXPECTED_FOLDER + "expectedMessage6.json");

Expand Down Expand Up @@ -467,7 +467,7 @@ void testSendTemplateDocumentPdfMessage() throws IOException, URISyntaxException

@Test
void testSendTemplateVideoMessage() throws IOException, URISyntaxException, InterruptedException, JSONException {
mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(DEFAULT_SEND_MESSAGE_RESPONSE));
mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(DEFAULT_SEND_MESSAGE_RESPONSE).build());

var expectedJson = fromResource(EXPECTED_FOLDER + "expectedMessage8.json");

Expand Down Expand Up @@ -500,7 +500,7 @@ void testSendTemplateVideoMessage() throws IOException, URISyntaxException, Inte

@Test
void testSendTemplateAuthMessage() throws IOException, URISyntaxException, InterruptedException, JSONException {
mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(DEFAULT_SEND_MESSAGE_RESPONSE));
mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(DEFAULT_SEND_MESSAGE_RESPONSE).build());

var expectedJson = fromResource(EXPECTED_FOLDER + "expectedMessage9.json");

Expand Down Expand Up @@ -533,7 +533,7 @@ void testSendTemplateAuthMessage() throws IOException, URISyntaxException, Inter

@Test
void testSendAudioMessage() throws IOException, URISyntaxException, InterruptedException, JSONException {
mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(DEFAULT_SEND_MESSAGE_RESPONSE));
mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(DEFAULT_SEND_MESSAGE_RESPONSE).build());

var expectedJson = fromResource(EXPECTED_FOLDER + "expectedMessage7.json");

Expand All @@ -556,7 +556,7 @@ void testSendAudioMessage() throws IOException, URISyntaxException, InterruptedE

@Test
void testSendAudioLinkMessage() throws InterruptedException, JSONException {
mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(DEFAULT_SEND_MESSAGE_RESPONSE));
mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(DEFAULT_SEND_MESSAGE_RESPONSE).build());

var expectedJson = """
{
Expand Down Expand Up @@ -591,7 +591,7 @@ void testSendAudioLinkMessage() throws InterruptedException, JSONException {

@Test
void testSendVideoMessage() throws InterruptedException, JSONException {
mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(DEFAULT_SEND_MESSAGE_RESPONSE));
mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(DEFAULT_SEND_MESSAGE_RESPONSE).build());

var expectedJson = """
{
Expand Down Expand Up @@ -625,7 +625,7 @@ void testSendVideoMessage() throws InterruptedException, JSONException {

@Test
void testSendImageMessage() throws InterruptedException, JSONException {
mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(DEFAULT_SEND_MESSAGE_RESPONSE));
mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(DEFAULT_SEND_MESSAGE_RESPONSE).build());

var expectedJson = """
{
Expand Down Expand Up @@ -657,7 +657,7 @@ void testSendImageMessage() throws InterruptedException, JSONException {

@Test
void testSendDocumentMessage() throws InterruptedException, JSONException {
mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(DEFAULT_SEND_MESSAGE_RESPONSE));
mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(DEFAULT_SEND_MESSAGE_RESPONSE).build());

var expectedJson = """
{
Expand Down Expand Up @@ -691,7 +691,7 @@ void testSendDocumentMessage() throws InterruptedException, JSONException {

@Test
void testSendStickerMessage() throws InterruptedException, JSONException {
mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(DEFAULT_SEND_MESSAGE_RESPONSE));
mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(DEFAULT_SEND_MESSAGE_RESPONSE).build());

var expectedJson = """
{
Expand Down Expand Up @@ -723,7 +723,7 @@ void testSendStickerMessage() throws InterruptedException, JSONException {

@Test
void testSendInteractiveMessageWithButtons() throws InterruptedException, JSONException, IOException, URISyntaxException {
mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(DEFAULT_SEND_MESSAGE_RESPONSE));
mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(DEFAULT_SEND_MESSAGE_RESPONSE).build());

var expectedJson = fromResource(EXPECTED_FOLDER + "expectedMessage11.json");

Expand Down Expand Up @@ -767,7 +767,7 @@ void testSendInteractiveMessageWithButtons() throws InterruptedException, JSONEx

@Test
void testSendInteractiveMessageWithImageHeader() throws InterruptedException, JSONException, IOException, URISyntaxException {
mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(DEFAULT_SEND_MESSAGE_RESPONSE));
mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(DEFAULT_SEND_MESSAGE_RESPONSE).build());

var expectedJson = fromResource(EXPECTED_FOLDER + "expectedMessage14.json");

Expand Down Expand Up @@ -810,7 +810,7 @@ void testSendInteractiveMessageWithImageHeader() throws InterruptedException, JS

@Test
void testSendInteractiveMessageWithVideoHeader() throws InterruptedException, JSONException, IOException, URISyntaxException {
mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(DEFAULT_SEND_MESSAGE_RESPONSE));
mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(DEFAULT_SEND_MESSAGE_RESPONSE).build());

var expectedJson = fromResource(EXPECTED_FOLDER + "expectedMessage15.json");

Expand Down Expand Up @@ -849,7 +849,7 @@ void testSendInteractiveMessageWithVideoHeader() throws InterruptedException, JS

@Test
void testSendInteractiveMessageWithDocumentHeader() throws InterruptedException, JSONException, IOException, URISyntaxException {
mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(DEFAULT_SEND_MESSAGE_RESPONSE));
mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(DEFAULT_SEND_MESSAGE_RESPONSE).build());

var expectedJson = fromResource(EXPECTED_FOLDER + "expectedMessage16.json");

Expand Down Expand Up @@ -893,7 +893,7 @@ void testSendInteractiveMessageWithDocumentHeader() throws InterruptedException,

@Test
void testSendInteractiveMessageWithList() throws InterruptedException, JSONException, IOException, URISyntaxException {
mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(DEFAULT_SEND_MESSAGE_RESPONSE));
mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(DEFAULT_SEND_MESSAGE_RESPONSE).build());

var expectedJson = fromResource(EXPECTED_FOLDER + "expectedMessage12.json");

Expand Down Expand Up @@ -955,7 +955,7 @@ void testSendInteractiveMessageWithList() throws InterruptedException, JSONExcep

@Test
void testSendReactionMessage() throws InterruptedException, JSONException {
mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(DEFAULT_SEND_MESSAGE_RESPONSE));
mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(DEFAULT_SEND_MESSAGE_RESPONSE).build());
var emojiThumbsUp = "\uD83D\uDC4D";
var expectedJson = """
{
Expand Down Expand Up @@ -990,7 +990,7 @@ void testSendReactionMessage() throws InterruptedException, JSONException {

@Test
void testSendReactionMessage2() throws InterruptedException, JSONException {
mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(DEFAULT_SEND_MESSAGE_RESPONSE));
mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(DEFAULT_SEND_MESSAGE_RESPONSE).build());
var emojiThumbsUp = "\uD83D\uDC4D";
var expectedJson = """
{
Expand Down Expand Up @@ -1023,7 +1023,7 @@ void testSendReactionMessage2() throws InterruptedException, JSONException {

@Test
void testUploadMedia() throws IOException, URISyntaxException, InterruptedException {
mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(fromResource("/uploadResponse.json")));
mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(fromResource("/uploadResponse.json")).build());

var fileContent = bytesFromResource("/starwars.png");

Expand All @@ -1039,7 +1039,7 @@ void testUploadMedia() throws IOException, URISyntaxException, InterruptedExcept

@Test
void testRetrieveMediaUrl() throws IOException, URISyntaxException, InterruptedException {
mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(fromResource("/media.json")));
mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(fromResource("/media.json")).build());

var response = whatsappBusinessCloudApi.retrieveMediaUrl("1227829768162607");

Expand All @@ -1057,7 +1057,7 @@ void testRetrieveMediaUrl() throws IOException, URISyntaxException, InterruptedE

@Test
void testDownloadMediaFile() throws InterruptedException, IOException, URISyntaxException {
mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(fromResource("/starwars.png")).setResponseCode(200).addHeader("Content-Disposition", "inline;filename=starwars.png"));
mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(fromResource("/starwars.png")).addHeader("Content-Disposition", "inline;filename=starwars.png").build());

var response = whatsappBusinessCloudApi.downloadMediaFile(baseUrl + "/whatsapp_business/attachments/?mid=1228169767822607&ext=16772107977&hash=ATs5BiSbLTZzCFh73M16stmnUK2UV6NBqChXB4WWC21sw");

Expand All @@ -1073,7 +1073,7 @@ void testDownloadMediaFile() throws InterruptedException, IOException, URISyntax

@Test
void testDownloadMediaFileNotFound() throws InterruptedException {
mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody("<html>.</html>").setResponseCode(404));
mockWebServer.enqueue(new MockResponse().newBuilder().body("<html>.</html>").code(404).build());

var exception = Assertions.assertThrows(WhatsappApiException.class, () -> whatsappBusinessCloudApi.downloadMediaFile(baseUrl + "/whatsapp_business/attachments/?mid=1228169767822607&ext=16772107977&hash=ATs5BiSbLTZzCFh73M16stmnUK2UV6NBqChXB4WWC21sw"));

Expand All @@ -1087,7 +1087,7 @@ void testDownloadMediaFileNotFound() throws InterruptedException {

@Test
void testDeleteMedia() throws IOException, URISyntaxException, InterruptedException {
mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(fromResource("/reponse.json")));
mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(fromResource("/reponse.json")).build());

var response = whatsappBusinessCloudApi.deleteMedia("1227829768162607");

Expand All @@ -1101,7 +1101,7 @@ void testDeleteMedia() throws IOException, URISyntaxException, InterruptedExcept

@Test
void testLocationMessage() throws IOException, URISyntaxException, InterruptedException, JSONException {
mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(DEFAULT_SEND_MESSAGE_RESPONSE));
mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(DEFAULT_SEND_MESSAGE_RESPONSE).build());

var expectedJson = fromResource(EXPECTED_FOLDER + "expectedMessage13.json");

Expand Down Expand Up @@ -1133,7 +1133,7 @@ void testMarkAsReadMessage() throws IOException, URISyntaxException, Interrupted
"success": true
}
""";
mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(responseBody));
mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(responseBody).build());

var expectedJson = fromResource(EXPECTED_FOLDER + "expectedMessage17.json");

Expand All @@ -1158,7 +1158,7 @@ void testTwoStepVerification() throws IOException, URISyntaxException, Interrupt
"success": true
}
""";
mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(responseBody));
mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(responseBody).build());

var expectedJson = fromResource(EXPECTED_FOLDER + "expectedMessage18.json");

Expand Down
Loading

0 comments on commit f000f9d

Please sign in to comment.