feat: define captcha_exists interface
This commit is contained in:
parent
2f924607ab
commit
55518ef650
3 changed files with 13 additions and 4 deletions
2
Makefile
2
Makefile
|
@ -96,7 +96,7 @@ test: frontend-test frontend ## Run all available tests
|
|||
cd db/db-sqlx-postgres &&\
|
||||
DATABASE_URL=${POSTGRES_DATABASE_URL}\
|
||||
cargo test --no-fail-fast
|
||||
#./scripts/tests.sh
|
||||
./scripts/tests.sh
|
||||
# cargo test --all-features --no-fail-fast
|
||||
|
||||
xml-test-coverage: migrate ## Generate code coverage report in XML format
|
||||
|
|
|
@ -144,6 +144,13 @@ pub trait MCDatabase: std::marker::Send + std::marker::Sync + CloneSPDatabase {
|
|||
captcha_key: &str,
|
||||
levels: &[Level],
|
||||
) -> DBResult<()>;
|
||||
|
||||
/// check if captcha exists
|
||||
async fn captcha_exists(
|
||||
&self,
|
||||
username: Option<&str>,
|
||||
captcha_key: &str,
|
||||
) -> DBResult<bool>;
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
||||
|
|
|
@ -35,12 +35,12 @@ pub async fn database_works<'a, T: MCDatabase>(
|
|||
db.register(p).await.unwrap();
|
||||
|
||||
// testing get secret
|
||||
let secret = db.get_secret(&p.username).await.unwrap();
|
||||
let secret = db.get_secret(p.username).await.unwrap();
|
||||
assert_eq!(secret.secret, p.secret, "user secret matches");
|
||||
|
||||
// testing update secret: setting secret = username
|
||||
db.update_secret(p.username, p.username).await.unwrap();
|
||||
let secret = db.get_secret(&p.username).await.unwrap();
|
||||
let secret = db.get_secret(p.username).await.unwrap();
|
||||
assert_eq!(
|
||||
secret.secret, p.username,
|
||||
"user secret matches username; as set by previous step"
|
||||
|
@ -131,6 +131,8 @@ pub async fn database_works<'a, T: MCDatabase>(
|
|||
"user was with empty email but email is set; so email should exsit"
|
||||
);
|
||||
|
||||
db.create_captcha(&p.username, c).await.unwrap();
|
||||
db.create_captcha(p.username, c).await.unwrap();
|
||||
assert!(db.captcha_exists(None, c.key).await.unwrap());
|
||||
assert!(db.captcha_exists(Some(p.username), c.key).await.unwrap());
|
||||
db.add_captcha_levels(p.username, c.key, l).await.unwrap();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue