diff options
author | Cyborus <cyborus@noreply.codeberg.org> | 2024-05-31 17:24:42 +0200 |
---|---|---|
committer | Cyborus <cyborus@noreply.codeberg.org> | 2024-05-31 17:24:42 +0200 |
commit | 7fa8e0acb764e1f819ca082ad7b3b133b2882e82 (patch) | |
tree | bf27bb484e07e82d6db78eef9183eb99118be926 /tests/common/mod.rs | |
parent | add oauth2 testing (diff) | |
parent | add `/test_repos` to gitignore (diff) | |
download | forgejo-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.rs | 17 |
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() +} |