mirror of
https://github.com/zyycn/codex-proxy-rs.git
synced 2026-11-20 08:01:46 +00:00
Add Chinese responsibility summaries to every backend Rust source, test, and build script. Remove sentence-ending periods from comments while preserving meaningful dots in URLs, versions, identifiers, and examples. Keep generated SDK documentation in sync with its contract generator, group middleware module declarations and exports, and record the comment conventions in the development skill. Validated with Rustfmt, strict Clippy, backend tests, documentation tests, and skill validation. Database-backed integration cases were skipped because dedicated PostgreSQL and Redis test services were not configured. Co-authored-by: Codex <noreply@openai.com>
56 lines
1.5 KiB
Rust
56 lines
1.5 KiB
Rust
//! 插件分发测试入口,以及共用下载环境与摘要辅助
|
|
|
|
mod github;
|
|
mod http;
|
|
mod lifecycle;
|
|
|
|
use std::sync::Arc;
|
|
|
|
use gateway_admin::model::plugins::distribution::{
|
|
DownloadPurpose, SourceAuthentication, SourceCredential, SourceCredentialInfo,
|
|
};
|
|
use gateway_host::plugin_distribution::HttpPluginDistribution;
|
|
use sha2::{Digest as _, Sha256};
|
|
use wiremock::MockServer;
|
|
|
|
fn transport(server: &MockServer) -> HttpPluginDistribution {
|
|
HttpPluginDistribution::with_transport(
|
|
&format!("{}/", server.uri()),
|
|
Arc::new(gateway_host::outbound::HttpClient::new().unwrap()),
|
|
gateway_host::outbound::NetworkPolicy::new(&["127.0.0.0/8".into(), "::1/128".into()])
|
|
.unwrap(),
|
|
)
|
|
.unwrap()
|
|
}
|
|
|
|
fn digest(body: &[u8]) -> String {
|
|
hex::encode(Sha256::digest(body))
|
|
}
|
|
|
|
fn credential(server: &MockServer, prefix: &str) -> SourceCredential {
|
|
credential_with(
|
|
server,
|
|
prefix,
|
|
SourceAuthentication::Bearer {
|
|
token: "test-token".into(),
|
|
},
|
|
)
|
|
}
|
|
|
|
fn credential_with(
|
|
server: &MockServer,
|
|
prefix: &str,
|
|
authentication: SourceAuthentication,
|
|
) -> SourceCredential {
|
|
SourceCredential {
|
|
info: SourceCredentialInfo {
|
|
id: "test-credential".into(),
|
|
name: "Test".into(),
|
|
origin: server.uri(),
|
|
path_prefix: prefix.into(),
|
|
purposes: vec![DownloadPurpose::Metadata, DownloadPurpose::Artifact],
|
|
},
|
|
authentication,
|
|
}
|
|
}
|