use chrono::prelude::*; use greenpass::{CertInfo, GreenPass, HealthCert, Recovery, Signature, Test, TestName, Vaccine}; // Quick and dirty validation tests const RECOVERY_SAMPLE_PAYLOAD : &str = "HC1:NCFOXN%TS3DH3ZSUZK+.V0ETD%65NL-AH-XIIOOA+IWBCNQ5GJL-XVRJAKD93B4:ZH6I1$4JF 2K%5+G9F.PNF67J6UW6LEQV46PK9E:00$4*2DN43U*0CEBQ/GXQFY73CIBC:GVEBBIBBL7BIB4UNAWNJKBOJJ5PNT53/FJ8FN96B2M3-6BHI7UG55:44$28A9H0D3ZCL4JMYAZ+S-A5$XKX6T2YC 35H/ITX8GL2TK96L6SR9MU9DV5 R1BPIZKH03RW63LD3LS4JYK9EFH78$ZJ*DJ3Q4+Y5V$K2:6.77/Z6KZ5LD6E6P 9SH87/YQJ/RL35+Y5P Q*8D$JD IBCLCK5MJMS68H36DH.K:Z28AL**I3DN3F7MHFEVV%*4HBTSCNT 4C%C47TO*47*KB*KYQT3LT+*4.$S6ZC0JB%JBK:TBSH6FN-G6N%VPJ13M9K9J8*TPB12-VRSQ8XMA6EBNVC28:APQ71K:ON4K25A:I9/-HUZGOZFB04YME%6DAUNO2B+TQG/2I0A4Z5NDROBVKS0J$28XG"; const PCR_TEST_SAMPLE_PAYLOAD : &str = "HC1:NCFOXN%TS3DH3ZSUZK+.V0ETD%65NL-AHBP1IOOA+IS7C$068WAD1W7:BAT4V22F/8X*G3M9BM9Z0BFU2P4JY73JC3KD34LT7A3-4386BXSJ$IJGX8.+IIYC6Q0ZIJPKJ+LJ%2TK/IS/SR4DKJ5QWCB4DN57E-4LXKV85HZ0T+0K%I17JLXKB6J57TJK57ALT$I/+GDG6Z$U*C2OQ1:PIGEGEV4*2DN43U*0CEBQ/GXQFY73CIBC:GUC7QHBN83GG3NQN%976FNXEB.FJN83HB3EG3CAJTA3ANBXEBGM5J%44$28A9H0D3ZCL4JMYAZ+S-A5$XKX6T2YC 35H/ITX8GL2TK96L6SR9MU9DV5 R1JN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MZ8DC8COVD9VC/MJK.A+ C/8DXED%JCC8C62KXJAUYCOS2QW6%PQRZMPK9I+0MCIKYJGCC:H3J1D1I3-*TW CXBDW33+ CD8CQ8C0EC%*TGHD1KT0NDPST7KDQHDN8TSVD2NDB*S6ECX%LBZI+PB/VSQOL9DLKWCZ3EBKD8IIGDB0D48UJ06J9UBSVAXCIF4LEIIPBJ7OICWK%5BBS22T9UF5LDCPF5RBQ746B46JZ0V-OEA7IB6$C94JB2E9Z3E8AE-QD+PB.QCD-H/8O3BEQ8L9VN.6A4JBLHLM7A$JD IBCLCK5MJMS68H36DH.K:Z28AL**I3DN3F7MHFEVV%*4HBTSCNT 4C%C47TO*47*KB*KYQT3LT+*4.$S6ZC0JB%JB% NHTC:OS6K7C*M9$4HOUJJ8BZR+AB9MRX.JK/DXQC*%ESNO3VVS$EO:9-14:6VEVUOEKF4PSTT:L9HRJKP4H6RAOV%Q7RB1P 9OG2O%LAULC97*JLUEH"; // This certificate is taken from the German CovPass app // https://raw.githubusercontent.com/Digitaler-Impfnachweis/covpass-android/0ef39462ba162303a156942aedb468c7de353ba7/covpass-sdk/src/test/resources/vaccination-cert.txt // It stores the KID in the unprotected properties const VACCINE_SAMPLE_PAYLOAD_UNPROTECTED_KID : &str = "HC1:6BFOXN*TS0BI$ZD4N9:9S6RCVN5+O30K3/XIV0W23NTDEXWK G2EP4J0BGJLOFJEIKVGAE%9ETMSA3/-2E%5VR5VVBJZILDBZ8D%JTQOL0EC7KD/ZL/8D:8DQVDLED0AC2AU/B2/+3HN2HPCT12IID*2T$/TVPTM*SQYDLADYR3JZIM-1U96UX4795L*KDYPWGO+9AKCO.BHOH63K5 *JAYUQJAGPENXUJRHQJA5G6VOE:OQPAU:IAJ0AZZ0OWCR/C+T4D-4HRVUMNMD3323R1392VC-4A+2XEN QT QTHC31M3+E3CP456L X4CZKHKB-43:C3J:R90JK.A5*G%DBZI9$JAQJKKIJX2MM+GWHKSKE MCAOI8%MQQK8+S4-R:KIIX0VJA$:O3HH:EF9NT6D7.Z8OMR-C137HZW2$XK6AL4%IYT0BUF1MFXZG$IV6$0+BN$MVYWV9Y4KCT7-S$ 0GKFCTR0KV4$0RCNV7J$%25I3HC3X83P47YOR40F80U8EHL%BP0CC9R$SEN59KYL 2O1/7*HVNY6:W0..DXJ5YKV4/J/JVZPRD*S0ZV+IR5H7*QS7%JX7HU0PA0PLY705JM/RA73CE3FBI"; #[test] fn parse_recovery() { let rec_hc = HealthCert { some_issuer: Some("AT".into()), created: Utc.ymd(2021, 07, 02).and_hms(21, 24, 42), expires: Utc.ymd(2022, 07, 02).and_hms(21, 24, 42), passes: vec![GreenPass { date_of_birth: "1998-02-26".into(), surname: "Musterfrau-Gößinger".into(), givenname: "Gabriele".into(), std_surname: "MUSTERFRAU