fix: create_candidate parameters in tests

This commit is contained in:
Sebastian Pravda 2022-10-30 13:13:46 +01:00
parent e2d373431a
commit e09a347d49
No known key found for this signature in database
GPG key ID: F3BC84F08EFA3F57
3 changed files with 5 additions and 21 deletions

View file

@ -73,7 +73,6 @@ impl Mutation {
#[cfg(test)]
mod tests {
use sea_orm::{Database, DbConn};
use serde_json::json;
use crate::{Mutation, crypto};
@ -97,15 +96,12 @@ mod tests {
async fn test_encrypt_decrypt_private_key_with_passphrase() {
let db = get_memory_sqlite_connection().await;
let form = serde_json::from_value(json!({
"application_id": 5555555,
})).unwrap();
let plain_text_password = "test".to_string();
let secret_message = "trnka".to_string();
let candidate = Mutation::create_candidate(&db, form, &plain_text_password, "".to_string()).await.unwrap();
let candidate = Mutation::create_candidate(&db, 5555555, &plain_text_password, "".to_string()).await.unwrap();
let encrypted_message = crypto::encrypt_password_with_recipients(&secret_message, vec![&candidate.public_key]).await.unwrap();

View file

@ -50,6 +50,7 @@ mod tests {
code: Set("test".to_string()),
public_key: Set("test".to_string()),
private_key: Set("test".to_string()),
personal_identification_number: Set("test".to_string()),
created_at: Set(chrono::offset::Local::now().naive_local()),
updated_at: Set(chrono::offset::Local::now().naive_local()),
..Default::default()

View file

@ -92,7 +92,6 @@ impl CandidateService {
mod tests {
use entity::candidate;
use sea_orm::{DbConn, Database, sea_query::TableCreateStatement, DbBackend, Schema, ConnectionTrait, prelude::Uuid};
use serde_json::json;
use crate::{crypto, Mutation, services::candidate_service::CandidateService};
@ -117,11 +116,7 @@ mod tests {
let db = get_memory_sqlite_connection().await;
let form = serde_json::from_value(json!({
"application_id": 5555555,
})).unwrap();
let candidate = Mutation::create_candidate(&db, form, &SECRET.to_string(), "".to_string()).await.unwrap();
let candidate = Mutation::create_candidate(&db, 5555555, &SECRET.to_string(), "".to_string()).await.unwrap();
assert_eq!(candidate.application, 5555555);
assert_ne!(candidate.code, SECRET.to_string());
@ -132,11 +127,7 @@ mod tests {
async fn test_candidate_session_correct_password() {
let db = &get_memory_sqlite_connection().await;
let form = serde_json::from_value(json!({
"application_id": 5555555,
})).unwrap();
Mutation::create_candidate(&db, form, &"Tajny_kod".to_string(), "".to_string()).await.unwrap();
Mutation::create_candidate(&db, 5555555, &"Tajny_kod".to_string(), "".to_string()).await.unwrap();
// correct password
let session = CandidateService::new_session(
@ -159,11 +150,7 @@ mod tests {
async fn test_candidate_session_incorrect_password() {
let db = &get_memory_sqlite_connection().await;
let form = serde_json::from_value(json!({
"application_id": 5555555,
})).unwrap();
let candidate_form = Mutation::create_candidate(&db, form, &"Tajny_kod".to_string(), "".to_string()).await.unwrap();
let candidate_form = Mutation::create_candidate(&db, 5555555, &"Tajny_kod".to_string(), "".to_string()).await.unwrap();
// incorrect password
assert!(