// {{ display_name }} MCP server — generated by mcpify. Do not hand-edit.
//
// Credentials extracted from one incoming HTTP request (HTTP transport
// only) — never sourced from local config/env/keychain. Converts into the
// same `Credentials` map shape `AuthStrategy`s already produce, so
// `AuthManager::apply_auth_headers`'s header-building tail is reused
// unchanged for both transports; the header name/value are relayed
// verbatim to the facaded API, whatever they were on the way in (a
// prefixed `Authorization: Basic .../Bearer ...` value, or a bare
// `X-Api-Key`-style value).

use super::auth_strategy::Credentials;

#[derive(Debug, Clone, PartialEq)]
pub struct RequestCredentials {
    pub header_name: String,
    pub value: String,
}

impl RequestCredentials {
    pub fn into_credentials_map(self) -> Credentials {
        let mut map = Credentials::new();
        map.insert("request_header_name".to_string(), self.header_name);
        map.insert("request_header_value".to_string(), self.value);
        map
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn converts_into_the_credentials_map_shape() {
        let creds = RequestCredentials {
            header_name: "X-Api-Key".to_string(),
            value: "secret".to_string(),
        };
        let map = creds.into_credentials_map();
        assert_eq!(map.get("request_header_name").map(String::as_str), Some("X-Api-Key"));
        assert_eq!(map.get("request_header_value").map(String::as_str), Some("secret"));
    }
}
