Write test to check consent validation

This commit is contained in:
bitfl0wer 2023-04-16 12:32:49 +02:00
parent 4e9854d46e
commit 746299c029
No known key found for this signature in database
GPG Key ID: 84BBB60DF895ABF2
1 changed files with 27 additions and 0 deletions

View File

@ -75,6 +75,11 @@ pub mod schemas {
message: "Password must be between 1 and 72 characters.".to_string(), 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 { return Ok(RegisterSchema {
username, username,
password, 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()
})
);
}
} }