Rinomina: crate akode-*, cartelle akode-rs/ e akode-cli/, binario akode, ~/.akode, AKODE_* (A)
Riapplica la fase 5 di aKode (86e7c72e) sulla base ripulita:
- crate codex-* -> akode-*, codex-rs -> akode-rs, codex-cli -> akode-cli, binario e ausiliari akode;
- ~/.codex -> ~/.akode, CODEX_HOME -> AKODE_HOME, variabili CODEX_* -> AKODE_*, .codex/ -> .akode/ di progetto;
nessun fallback a ~/.codex o a CODEX_*;
- testi per l'utente "Codex" -> "aKode"; testi verso il modello e istruzioni di sistema invariati;
- snapshot insta rinominati (non ancora rigenerati).
I conflitti con la base ripulita sono stati risolti riapplicando la rinomina ai file senza le
funzioni di imeAI (script di mappa dei token per file).
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
162
akode-rs/exec-server/src/environment_bootstrap_tests.rs
Normal file
162
akode-rs/exec-server/src/environment_bootstrap_tests.rs
Normal file
@@ -0,0 +1,162 @@
|
||||
use akode_http_client::HttpClientFactory;
|
||||
use akode_http_client::OutboundProxyPolicy;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
use super::PreparedEnvironmentManager;
|
||||
use super::PreparedEnvironmentSource;
|
||||
use crate::DefaultEnvironmentProvider;
|
||||
use crate::LOCAL_ENVIRONMENT_ID;
|
||||
use crate::REMOTE_ENVIRONMENT_ID;
|
||||
use crate::client_api::DEFAULT_REMOTE_EXEC_SERVER_CONNECT_TIMEOUT;
|
||||
use crate::client_api::ExecServerTransportParams;
|
||||
use crate::environment_provider::EnvironmentDefault;
|
||||
use crate::environment_provider::EnvironmentProviderEntry;
|
||||
use crate::environment_provider::EnvironmentProviderSnapshot;
|
||||
use crate::remote::NoiseRendezvousEnvironmentConfig;
|
||||
|
||||
#[test]
|
||||
fn prepared_remote_environment_is_detected_without_constructing_a_connection() {
|
||||
let prepared = PreparedEnvironmentManager {
|
||||
source: PreparedEnvironmentSource::Snapshot(EnvironmentProviderSnapshot {
|
||||
environments: vec![EnvironmentProviderEntry {
|
||||
id: REMOTE_ENVIRONMENT_ID.to_string(),
|
||||
transport: ExecServerTransportParams::websocket_url(
|
||||
"ws://username:password@executor.example/private?token=secret".to_string(),
|
||||
DEFAULT_REMOTE_EXEC_SERVER_CONNECT_TIMEOUT,
|
||||
),
|
||||
skills: Default::default(),
|
||||
}],
|
||||
default: EnvironmentDefault::EnvironmentId(REMOTE_ENVIRONMENT_ID.to_string()),
|
||||
include_local: false,
|
||||
}),
|
||||
};
|
||||
|
||||
assert!(prepared.default_environment_is_remote());
|
||||
|
||||
let debug = format!("{prepared:?}");
|
||||
assert!(!debug.contains("username"));
|
||||
assert!(!debug.contains("password"));
|
||||
assert!(!debug.contains("executor.example"));
|
||||
assert!(!debug.contains("secret"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn prepared_noise_environment_is_detected_before_http_policy_is_resolved() {
|
||||
let config = NoiseRendezvousEnvironmentConfig::new(
|
||||
"https://registry-user:registry-password@registry.example/api?access_token=query-secret#fragment-secret"
|
||||
.to_string(),
|
||||
"environment-requested".to_string(),
|
||||
"registry-token".to_string(),
|
||||
Some("workspace-123".to_string()),
|
||||
)
|
||||
.expect("Noise environment configuration");
|
||||
let prepared = PreparedEnvironmentManager {
|
||||
source: PreparedEnvironmentSource::Noise(config),
|
||||
};
|
||||
|
||||
assert!(prepared.default_environment_is_remote());
|
||||
|
||||
let debug = format!("{prepared:?}");
|
||||
assert!(debug.contains("<redacted>"));
|
||||
assert!(!debug.contains("registry-token"));
|
||||
assert!(!debug.contains("workspace-123"));
|
||||
assert!(!debug.contains("registry-user"));
|
||||
assert!(!debug.contains("registry-password"));
|
||||
assert!(!debug.contains("registry.example"));
|
||||
assert!(!debug.contains("query-secret"));
|
||||
assert!(!debug.contains("fragment-secret"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn prepared_noise_environment_rejects_invalid_configuration() {
|
||||
let invalid_configs = [
|
||||
("", "environment-requested", "registry-token", None),
|
||||
("https://registry.example", "", "registry-token", None),
|
||||
(
|
||||
"https://registry.example",
|
||||
"environment-requested",
|
||||
"",
|
||||
None,
|
||||
),
|
||||
(
|
||||
"https://registry.example",
|
||||
"environment-requested",
|
||||
"registry\ntoken",
|
||||
None,
|
||||
),
|
||||
(
|
||||
"https://registry.example",
|
||||
"environment-requested",
|
||||
"registry-token",
|
||||
Some("workspace\n123"),
|
||||
),
|
||||
];
|
||||
|
||||
for (registry_url, environment_id, auth_token, chatgpt_account_id) in invalid_configs {
|
||||
let result = NoiseRendezvousEnvironmentConfig::new(
|
||||
registry_url.to_string(),
|
||||
environment_id.to_string(),
|
||||
auth_token.to_string(),
|
||||
chatgpt_account_id.map(str::to_string),
|
||||
);
|
||||
|
||||
assert!(result.is_err());
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn prepared_local_and_disabled_environments_are_not_remote() {
|
||||
let local = PreparedEnvironmentManager {
|
||||
source: PreparedEnvironmentSource::Snapshot(EnvironmentProviderSnapshot {
|
||||
environments: Vec::new(),
|
||||
default: EnvironmentDefault::EnvironmentId(LOCAL_ENVIRONMENT_ID.to_string()),
|
||||
include_local: true,
|
||||
}),
|
||||
};
|
||||
let disabled = PreparedEnvironmentManager {
|
||||
source: PreparedEnvironmentSource::Snapshot(EnvironmentProviderSnapshot {
|
||||
environments: Vec::new(),
|
||||
default: EnvironmentDefault::Disabled,
|
||||
include_local: false,
|
||||
}),
|
||||
};
|
||||
|
||||
assert_eq!(
|
||||
[
|
||||
local.default_environment_is_remote(),
|
||||
disabled.default_environment_is_remote()
|
||||
],
|
||||
[false, false]
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn prepared_environment_manager_builds_with_the_explicit_http_policy() {
|
||||
let prepared = PreparedEnvironmentManager {
|
||||
source: PreparedEnvironmentSource::Snapshot(
|
||||
DefaultEnvironmentProvider::new(Some("ws://127.0.0.1:8765".to_string()))
|
||||
.snapshot_inner(),
|
||||
),
|
||||
};
|
||||
let manager = prepared
|
||||
.build(
|
||||
/*local_runtime_paths*/ None,
|
||||
HttpClientFactory::new(OutboundProxyPolicy::RespectSystemProxy),
|
||||
)
|
||||
.expect("environment manager");
|
||||
|
||||
assert_eq!(
|
||||
manager.default_environment_id(),
|
||||
Some(REMOTE_ENVIRONMENT_ID)
|
||||
);
|
||||
assert!(
|
||||
manager
|
||||
.default_environment()
|
||||
.expect("remote environment")
|
||||
.is_remote()
|
||||
);
|
||||
assert_eq!(
|
||||
manager.http_client_factory().outbound_proxy_policy(),
|
||||
OutboundProxyPolicy::RespectSystemProxy
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user