mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2025-11-23 22:15:46 +00:00
feat: define interface for getting user secret
This commit is contained in:
parent
f165581e17
commit
28ddadc5fe
2
Makefile
2
Makefile
@ -96,7 +96,7 @@ test: frontend-test frontend ## Run all available tests
|
|||||||
cd db/db-sqlx-postgres &&\
|
cd db/db-sqlx-postgres &&\
|
||||||
DATABASE_URL=${POSTGRES_DATABASE_URL}\
|
DATABASE_URL=${POSTGRES_DATABASE_URL}\
|
||||||
cargo test --no-fail-fast
|
cargo test --no-fail-fast
|
||||||
# ./scripts/tests.sh
|
./scripts/tests.sh
|
||||||
# cargo test --all-features --no-fail-fast
|
# cargo test --all-features --no-fail-fast
|
||||||
|
|
||||||
xml-test-coverage: migrate ## Generate code coverage report in XML format
|
xml-test-coverage: migrate ## Generate code coverage report in XML format
|
||||||
|
|||||||
@ -125,6 +125,16 @@ pub trait MCDatabase: std::marker::Send + std::marker::Sync + CloneSPDatabase {
|
|||||||
|
|
||||||
/// update username
|
/// update username
|
||||||
async fn update_username(&self, current: &str, new: &str) -> DBResult<()>;
|
async fn update_username(&self, current: &str, new: &str) -> DBResult<()>;
|
||||||
|
|
||||||
|
/// get a user's secret
|
||||||
|
async fn get_secret(&self, username: &str) -> DBResult<Secret>;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
|
/// datastructure representing a user's secret
|
||||||
|
pub struct Secret {
|
||||||
|
/// user's secret
|
||||||
|
pub secret: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Trait to clone MCDatabase
|
/// Trait to clone MCDatabase
|
||||||
|
|||||||
@ -29,6 +29,10 @@ pub async fn database_works<'a, T: MCDatabase>(db: &T, p: &Register<'a>) {
|
|||||||
}
|
}
|
||||||
db.register(p).await.unwrap();
|
db.register(p).await.unwrap();
|
||||||
|
|
||||||
|
// testing get secret
|
||||||
|
let secret = db.get_secret(&p.username).await.unwrap();
|
||||||
|
assert_eq!(secret.secret, p.secret, "user secret matches");
|
||||||
|
|
||||||
// testing get_password
|
// testing get_password
|
||||||
|
|
||||||
// with username
|
// with username
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user