summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorCyborus <cyborus@cyborus.xyz>2023-12-20 19:51:51 +0100
committerCyborus <cyborus@cyborus.xyz>2023-12-20 19:51:51 +0100
commitdc7997beba8b24d55f43cd39e2975778e1fc219a (patch)
treedbefca01ba5117c11b93458c95b1ddd84a4c646b /tests
parentadd more auth options (diff)
downloadforgejo-api-dc7997beba8b24d55f43cd39e2975778e1fc219a.tar.xz
forgejo-api-dc7997beba8b24d55f43cd39e2975778e1fc219a.zip
add password auth testing
Diffstat (limited to 'tests')
-rw-r--r--tests/ci_test.rs18
1 files changed, 17 insertions, 1 deletions
diff --git a/tests/ci_test.rs b/tests/ci_test.rs
index e5cb1c2..3d98f71 100644
--- a/tests/ci_test.rs
+++ b/tests/ci_test.rs
@@ -5,7 +5,7 @@ use forgejo_api::Forgejo;
async fn ci() -> eyre::Result<()> {
let url = url::Url::parse(&std::env::var("FORGEJO_API_CI_INSTANCE_URL")?)?;
let token = std::env::var("FORGEJO_API_CI_TOKEN")?;
- let api = Forgejo::new(&token, url)?;
+ let api = Forgejo::new(forgejo_api::Auth::Token(&token), url)?;
let mut results = Vec::new();
@@ -54,6 +54,22 @@ async fn user(api: &forgejo_api::Forgejo) -> eyre::Result<()> {
let followers = api.get_followers("TestingAdmin").await?;
ensure!(followers == Some(Vec::new()), "follower list not empty");
+ let url = url::Url::parse(&std::env::var("FORGEJO_API_CI_INSTANCE_URL")?)?;
+ let password_api = Forgejo::new(
+ forgejo_api::Auth::Password {
+ username: "TestingAdmin",
+ password: "password",
+ mfa: None,
+ },
+ url,
+ )
+ .wrap_err("failed to log in using username and password")?;
+
+ ensure!(
+ api.myself().await? == password_api.myself().await?,
+ "users not equal comparing token-auth and pass-auth"
+ );
+
Ok(())
}