mirror of
https://github.com/danbulant/Portfolio
synced 2026-06-19 06:21:15 +00:00
fix: create_candidate parameters in tests
This commit is contained in:
parent
e2d373431a
commit
e09a347d49
3 changed files with 5 additions and 21 deletions
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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!(
|
||||
|
|
|
|||
Loading…
Reference in a new issue