From 746d3e2d78727fd1c5d52213cda3813ce1c28f39 Mon Sep 17 00:00:00 2001 From: Stas Parshin Date: Tue, 28 Aug 2018 00:52:42 +0700 Subject: [PATCH] Update passport test --- .../pengrad/telegrambot/TelegramBotTest.java | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/library/src/test/java/com/pengrad/telegrambot/TelegramBotTest.java b/library/src/test/java/com/pengrad/telegrambot/TelegramBotTest.java index e33c4d0c..06b6d2df 100644 --- a/library/src/test/java/com/pengrad/telegrambot/TelegramBotTest.java +++ b/library/src/test/java/com/pengrad/telegrambot/TelegramBotTest.java @@ -1186,22 +1186,20 @@ public void setPassportDataErrors() { @Test public void decryptPassport() throws Exception { - List updates = bot.execute(new GetUpdates()).updates(); - Collections.reverse(updates); - PassportData passportData = null; - for (Update update : updates) { - if (update.message() != null && update.message().passportData() != null) { - passportData = update.message().passportData(); - break; - } - } - if (passportData == null) { - passportData = BotUtils.parseUpdate(testPassportData).message().passportData(); - } + PassportData passportData = BotUtils.parseUpdate(testPassportData).message().passportData(); assertNotNull(passportData); Credentials credentials = passportData.credentials().decrypt(privateKey); System.out.println(credentials); + System.out.println("nonce: " + credentials.nonce()); + + for (EncryptedPassportElement encElement : passportData.data()) { + if (encElement.type() != EncryptedPassportElement.Type.personal_details) continue; + PersonalDetails personalDetails = (PersonalDetails) encElement.decryptData(credentials); + System.out.println(personalDetails); + } + + if (true) return; for (EncryptedPassportElement encElement : passportData.data()) { System.out.println(encElement.decryptData(credentials)); @@ -1213,6 +1211,9 @@ public void decryptPassport() throws Exception { if (encElement.files() != null) { files.addAll(Arrays.asList(encElement.files())); } + if (encElement.translation() != null) { + files.addAll(Arrays.asList(encElement.translation())); + } System.out.println("files: " + Arrays.toString(files.toArray())); for (int i = 0; i < files.size(); i++) {