Add test with large certificate

This commit is contained in:
Sosthène Guédon
2023-04-13 10:17:40 +02:00
parent ddc67d7570
commit ac6097a8d1
4 changed files with 72 additions and 2 deletions
+1 -1
View File
@@ -151,7 +151,7 @@ where
) -> Result {
info!("PIV responding to {:02x?}", command);
let parsed_command: Command = command.try_into()?;
info!("parsed: {:?}", &parsed_command);
info!("parsed: {:02x?}", &parsed_command);
let reply = Reply(reply);
match parsed_command {
Binary file not shown.
+41
View File
@@ -0,0 +1,41 @@
-----BEGIN CERTIFICATE-----
MIIHNTCCBh2gAwIBAgIUBeJLVUnOULY3fhLvjaWOZe/qWfYwDQYJKoZIhvcNAQEL
BQAwggIoMQswCQYDVQQGEwJURTGBizCBiAYDVQQIDIGAVEVTVFRFU1RURVNUVEVT
VFRFU1RURVNUVEVTVFRFU1RURVNUVEVTVFRFU1RURVNUVEVTVFRFU1RURVNUVEVT
VFRFU1RURVNUVEVTVFRFU1RURVNUVEVTVFRFU1RURVNUVEVTVFRFU1RURVNUVEVT
VFRFU1RURVNUVEVTVFRFU1QxgYswgYgGA1UEBwyBgFRFU1RURVNUVEVTVFRFU1RU
RVNUVEVTVFRFU1RURVNUVEVTVFRFU1RURVNUVEVTVFRFU1RURVNUVEVTVFRFU1RU
RVNUVEVTVFRFU1RURVNUVEVTVFRFU1RURVNUVEVTVFRFU1RURVNUVEVTVFRFU1RU
RVNUVEVTVFRFU1RURVNUMUkwRwYDVQQKDEBURVNUVEVTVFRFU1RURVNUVEVTVFRF
U1RURVNUVEVTVFRFU1RURVNUVEVTVFRFU1RURVNUVEVTVFRFU1RURVNUMUkwRwYD
VQQLDEBURVNUVEVTVFRFU1RURVNUVEVTVFRFU1RURVNUVEVTVFRFU1RURVNUVEVT
VFRFU1RURVNUVEVTVFRFU1RURVNUMUkwRwYDVQQDDEBURVNUVEVTVFRFU1RURVNU
VEVTVFRFU1RURVNUVEVTVFRFU1RURVNUVEVTVFRFU1RURVNUVEVTVFRFU1RURVNU
MRwwGgYJKoZIhvcNA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ODLDGmVkoo07U4D/7TG
nu5LgPBIRV0vmiCejMtpYhPCGAnTSdbhvKkNJAkZ8s225YlLFACgTVVmpcGb+cKu
RVXxZXFI1sWeIz9RMflobkpemKxHSUtuQJxJMDbPyOPqwd5CRFHgs7tRBwIDAQAB
o1MwUTAdBgNVHQ4EFgQUfRto8fDPPLA/ok5lgK7MypPSh54wHwYDVR0jBBgwFoAU
fRto8fDPPLA/ok5lgK7MypPSh54wDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0B
AQsFAAOCAQEAWyy0drsTRfU8/J+rrX4trDb9o6iy7dSHyrpxo/TbaxBFTH69OJGb
Q8YbutSq1a4m4UaSnGJYwarVCxmntjciz7byhfUwFEAdZ/rqwCeaqTdomGiYUisM
Dmf/WiLYxRCpxr8tkkc332OlmHeBsDHKYY0G6dpdiTAGrjGNQZJJQc1wzy/+guZE
UWr6jSVOel/u47jadbFK2/4a8ZnZEuEU0nn5h01lFY3fvrHr93Z3yzZ60LKeMszs
SmDyoVI1XfNSJd8YbshGP91CVHFnDWDqo1JWV7hRev5g3XJfobIAAAqbL/H92BCT
N4vF6RP8Ck9wj1OYq/w82MkgxOPleUju4Q==
-----END CERTIFICATE-----
+30 -1
View File
@@ -9,7 +9,8 @@ use card::with_vsc;
use expectrl::{spawn, Eof, Regex, WaitStatus};
use std::io::Write;
use std::include_str;
use std::io::{Read, Write};
use std::process::{Command, Stdio};
#[test_log::test]
@@ -76,3 +77,31 @@ fn ecdh() {
assert_eq!(p.wait().unwrap().code(), Some(0));
});
}
#[test_log::test]
fn large_cert() {
with_vsc(|| {
let mut p = Command::new("pivy-tool")
.args(["write-cert", "9A"])
.stdin(Stdio::piped())
.stdout(Stdio::piped())
.spawn()
.unwrap();
let mut stdin = p.stdin.take().unwrap();
stdin.write_all(include_bytes!("large-cert.der")).unwrap();
drop(stdin);
assert_eq!(p.wait().unwrap().code(), Some(0));
let mut p = Command::new("pivy-tool")
.args(["cert", "9A"])
.stdin(Stdio::piped())
.stdout(Stdio::piped())
.spawn()
.unwrap();
let mut stdout = p.stdout.take().unwrap();
let mut buf = String::new();
stdout.read_to_string(&mut buf).unwrap();
assert_eq!(buf, include_str!("large-cert.pem"));
assert_eq!(p.wait().unwrap().code(), Some(0));
});
}