Skip to main content

github_mcp/auth/strategies/
stub.rs

1// GitHub v3 REST API MCP server — generated by mcpify. Do not hand-edit.
2
3use async_trait::async_trait;
4
5use super::super::auth_strategy::{AuthConfig, AuthStrategy, Credentials};
6
7/// No-op fallback strategy — the safe default when the target API requires
8/// no authentication, or before `github-mcp setup` has configured a
9/// real scheme. Always present so `AuthManager` never has to special-case a
10/// missing strategy.
11#[derive(Debug, Default)]
12pub struct StubAuthStrategy;
13
14#[async_trait]
15impl AuthStrategy for StubAuthStrategy {
16    async fn authenticate(&self, _config: &AuthConfig) -> anyhow::Result<Credentials> {
17        Ok(Credentials::new())
18    }
19
20    fn validate_credentials(&self, _credentials: &Credentials) -> bool {
21        true
22    }
23}
24
25#[cfg(test)]
26mod tests {
27    use super::*;
28
29    #[tokio::test]
30    async fn always_authenticates_with_empty_credentials() {
31        let strategy = StubAuthStrategy;
32        let credentials = strategy.authenticate(&AuthConfig::new()).await.unwrap();
33        assert!(credentials.is_empty());
34    }
35
36    #[test]
37    fn always_validates() {
38        let strategy = StubAuthStrategy;
39        assert!(strategy.validate_credentials(&Credentials::new()));
40    }
41}