From f49f5f16367a49c3991ec2c23da6ab2f4f98f883 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Thu, 20 May 2021 14:04:40 +0200 Subject: [PATCH] qrcode: Add some more tests --- matrix_qrcode/src/lib.rs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/matrix_qrcode/src/lib.rs b/matrix_qrcode/src/lib.rs index ada9bdad..a297e908 100644 --- a/matrix_qrcode/src/lib.rs +++ b/matrix_qrcode/src/lib.rs @@ -197,8 +197,27 @@ mod test { #[test] fn decode_short_secret() { - let data = b"MATRIX\x02\x02\x00\x07FLOW_IDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBSECRET"; + let data = b"MATRIX\ + \x02\x02\x00\x07\ + FLOW_ID\ + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\ + BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\ + SECRET"; + let result = QrVerification::from_bytes(data); assert!(matches!(result, Err(DecodingError::SharedSecret(_)))) } + + #[test] + fn decode_invalid_room_id() { + let data = b"MATRIX\ + \x02\x00\x00\x0f\ + test:localhost\ + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\ + BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\ + SECRETISLONGENOUGH"; + + let result = QrVerification::from_bytes(data); + assert!(matches!(result, Err(DecodingError::Identifier(_)))) + } }