Skip to main content

devboy_jira/
liveness.rs

1//! Jira [`LivenessProbe`] stub per [ADR-021] §6.
2//!
3//! Both Jira Cloud (API v3) and Self-Hosted/DC (API v2) expose
4//! `GET /rest/api/{2,3}/myself` for the authenticated user.
5//! Routing the response into the typed liveness shape requires
6//! handling both flavours and the email+token vs PAT auth modes.
7//! The stub uses the trait's default `test` impl (returns
8//! [`LivenessStatus::NotImplemented`]) until a real probe lands.
9//!
10//! [ADR-021]: https://github.com/meteora-pro/devboy-tools/blob/main/docs/architecture/adr/ADR-021-external-secret-sources.md
11//! [`LivenessStatus::NotImplemented`]: devboy_core::liveness::LivenessStatus
12
13use async_trait::async_trait;
14use devboy_core::LivenessProbe;
15
16use crate::client::JiraClient;
17
18#[async_trait]
19impl LivenessProbe for JiraClient {
20    fn provider_name(&self) -> &str {
21        "jira"
22    }
23}
24
25#[cfg(test)]
26mod tests {
27    use super::*;
28    use devboy_core::liveness::LivenessStatus;
29    use secrecy::SecretString;
30
31    #[tokio::test]
32    async fn provider_name_is_jira_and_default_returns_not_implemented() {
33        let client = JiraClient::new(
34            "https://example.atlassian.net",
35            "PROJ",
36            "user@example.com",
37            SecretString::from("any".to_owned()),
38        );
39        assert_eq!(client.provider_name(), "jira");
40        let r = client
41            .test(&SecretString::from("any".to_owned()))
42            .await
43            .unwrap();
44        assert_eq!(r.status, LivenessStatus::NotImplemented);
45    }
46}