From 746299c02905b8197f26093b41b85d44862261e3 Mon Sep 17 00:00:00 2001 From: bitfl0wer Date: Sun, 16 Apr 2023 12:32:49 +0200 Subject: [PATCH] Write test to check consent validation --- src/api/schemas.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/api/schemas.rs b/src/api/schemas.rs index 6eaf96e..8288ce1 100644 --- a/src/api/schemas.rs +++ b/src/api/schemas.rs @@ -75,6 +75,11 @@ pub mod schemas { message: "Password must be between 1 and 72 characters.".to_string(), }); } + if !consent { + return Err(RegisterSchemaError { + message: "Consent must be 'true' to register.".to_string(), + }); + } return Ok(RegisterSchema { username, password, @@ -195,4 +200,26 @@ mod schemas_tests { }) ); } + + #[test] + fn consent_false() { + assert_eq!( + RegisterSchema::new( + "Test".to_string(), + None, + false, + None, + None, + None, + None, + None, + None, + None, + ), + Err(RegisterSchemaError { + message: "Consent must be 'true' to register.".to_string() + }) + ); + } + }