diff options
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() +} |