Skip to content

Commit

Permalink
Update passport test
Browse files Browse the repository at this point in the history
  • Loading branch information
pengrad committed Aug 27, 2018
1 parent 780686e commit 746d3e2
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions library/src/test/java/com/pengrad/telegrambot/TelegramBotTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1186,22 +1186,20 @@ public void setPassportDataErrors() {

@Test
public void decryptPassport() throws Exception {
List<Update> 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));
Expand All @@ -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++) {
Expand Down

0 comments on commit 746d3e2

Please sign in to comment.