summaryrefslogtreecommitdiffstats
path: root/tests/common/mod.rs
diff options
context:
space:
mode:
authorCyborus <cyborus@noreply.codeberg.org>2024-05-31 17:24:42 +0200
committerCyborus <cyborus@noreply.codeberg.org>2024-05-31 17:24:42 +0200
commit7fa8e0acb764e1f819ca082ad7b3b133b2882e82 (patch)
treebf27bb484e07e82d6db78eef9183eb99118be926 /tests/common/mod.rs
parentadd oauth2 testing (diff)
parentadd `/test_repos` to gitignore (diff)
downloadforgejo-api-7fa8e0acb764e1f819ca082ad7b3b133b2882e82.tar.xz
forgejo-api-7fa8e0acb764e1f819ca082ad7b3b133b2882e82.zip
Merge pull request 'improve integration tests' (#56) from improve-tests into main
Reviewed-on: https://codeberg.org/Cyborus/forgejo-api/pulls/56
Diffstat (limited to 'tests/common/mod.rs')
-rw-r--r--tests/common/mod.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/common/mod.rs b/tests/common/mod.rs
new file mode 100644
index 0000000..63ae02c
--- /dev/null
+++ b/tests/common/mod.rs
@@ -0,0 +1,17 @@
+use forgejo_api::Forgejo;
+
+pub fn login() -> Forgejo {
+ let url = url::Url::parse(&std::env::var("FORGEJO_API_CI_INSTANCE_URL").unwrap()).unwrap();
+ let token = std::env::var("FORGEJO_API_CI_TOKEN").unwrap();
+ Forgejo::new(forgejo_api::Auth::Token(&token), url).unwrap()
+}
+
+pub fn login_pass(username: &str, password: &str) -> Forgejo {
+ let url = url::Url::parse(&std::env::var("FORGEJO_API_CI_INSTANCE_URL").unwrap()).unwrap();
+ let auth = forgejo_api::Auth::Password {
+ username,
+ password,
+ mfa: None,
+ };
+ Forgejo::new(auth, url).unwrap()
+}