aKode setup: scelta di dove salvare la chiave API (portachiavi o file protetto)

- nuovo passo «Dove salvo la chiave?» dopo il campo Chiave API (solo se inserita),
  preselezionato secondo provider_api_key_store; senza portachiavi solo il file
- la scelta scrive provider_api_key_store (impostazione globale: file oppure auto),
  salva la chiave solo nel backend scelto, rimuove la copia nell'altro e sposta
  le chiavi degli altri provider
- akode-login: save_provider_api_key_to(_with_keyring), sonda del portachiavi
- test: file 0600 e nessuna chiave in config.toml, portachiavi senza file,
  cambio con rimozione della vecchia copia; snapshot 60/80/120 senza la chiave

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
andrea.difonzo
2026-11-11 13:39:19 +01:00
parent 9df212cf5e
commit 08b2c098b8
21 changed files with 562 additions and 14 deletions

View File

@@ -23,3 +23,7 @@ pub use provider_api_key::ProviderApiKeyFileStore;
pub use provider_api_key::configured_provider_api_key_store;
pub use provider_api_key::configured_provider_api_key_store_with_keyring;
pub use provider_api_key::install_provider_api_key_store;
pub use provider_api_key::provider_api_key_keyring_available;
pub use provider_api_key::provider_api_key_keyring_available_with;
pub use provider_api_key::save_provider_api_key_to;
pub use provider_api_key::save_provider_api_key_to_with_keyring;

View File

@@ -251,6 +251,82 @@ pub fn install_provider_api_key_store(codex_home: &Path, mode: AuthCredentialsSt
));
}
/// Keyring account used only to check that the system keyring answers (never written).
const KEYRING_PROBE_PROVIDER_ID: &str = "akode-keyring-probe";
/// Whether the system keyring can be used for provider keys (a read-only probe).
pub fn provider_api_key_keyring_available() -> bool {
provider_api_key_keyring_available_with(Arc::new(DefaultKeyringStore))
}
/// [`provider_api_key_keyring_available`] with an explicit keyring backend.
pub fn provider_api_key_keyring_available_with(keyring: Arc<dyn KeyringStore>) -> bool {
KeyringProviderApiKeyStore::new(keyring)
.load(KEYRING_PROBE_PROVIDER_ID)
.is_ok()
}
/// Stores `api_key` for `provider_id` only in the backend chosen by `mode` (`file`, or the
/// system keyring for any other mode) and removes the copy left in the other backend. The
/// keys of `other_providers` found in the other backend move to the chosen one, so a global
/// mode switch keeps them readable.
pub fn save_provider_api_key_to(
codex_home: &Path,
mode: AuthCredentialsStoreMode,
provider_id: &str,
api_key: &str,
other_providers: &[String],
) -> Result<ProviderApiKeyLocation, String> {
save_provider_api_key_to_with_keyring(
codex_home,
mode,
provider_id,
api_key,
other_providers,
Arc::new(DefaultKeyringStore),
)
}
/// [`save_provider_api_key_to`] with an explicit keyring backend.
pub fn save_provider_api_key_to_with_keyring(
codex_home: &Path,
mode: AuthCredentialsStoreMode,
provider_id: &str,
api_key: &str,
other_providers: &[String],
keyring: Arc<dyn KeyringStore>,
) -> Result<ProviderApiKeyLocation, String> {
if api_key.trim().is_empty() {
return Err("API key must not be empty".to_string());
}
let keyring = KeyringProviderApiKeyStore::new(keyring);
let file = ProviderApiKeyFileStore::new(codex_home);
let (target, other): (&dyn ProviderApiKeyStore, &dyn ProviderApiKeyStore) = match mode {
AuthCredentialsStoreMode::File => (&file, &keyring),
_ => (&keyring, &file),
};
for id in other_providers
.iter()
.filter(|id| id.as_str() != provider_id)
{
// An unreadable keyring simply has nothing to move.
let Ok(Some(key)) = other.load(id) else {
continue;
};
if !matches!(target.load(id), Ok(Some(_))) {
target.save(id, &key)?;
}
if let Err(error) = other.delete(id) {
warn!("could not remove the old copy of a provider API key: {error}");
}
}
let location = target.save(provider_id, api_key)?;
if let Err(error) = other.delete(provider_id) {
warn!("could not remove the old copy of a provider API key: {error}");
}
Ok(location)
}
#[cfg(test)]
#[path = "provider_api_key_tests.rs"]
mod tests;

View File

@@ -141,3 +141,112 @@ fn ephemeral_mode_keeps_keys_in_memory() {
assert!(!home.path().join(PROVIDER_API_KEYS_FILE).exists());
assert!(!format!("{store:?}").contains(SECRET));
}
#[test]
fn chosen_file_backend_is_private_and_skips_the_keyring() {
let home = TempDir::new().unwrap();
let keyring = MockKeyringStore::default();
let location = save_provider_api_key_to_with_keyring(
home.path(),
AuthCredentialsStoreMode::File,
"imeai",
SECRET,
&[],
Arc::new(keyring.clone()),
)
.unwrap();
assert!(matches!(location, ProviderApiKeyLocation::File { .. }));
assert!(!location.to_string().contains(SECRET));
assert!(keyring.saved_value(ACCOUNT).is_none());
let path = home.path().join(PROVIDER_API_KEYS_FILE);
#[cfg(unix)]
{
use std::os::unix::fs::PermissionsExt;
let mode = std::fs::metadata(&path).unwrap().permissions().mode();
assert_eq!(mode & 0o777, 0o600);
}
assert_eq!(
ProviderApiKeyFileStore::new(home.path())
.load("imeai")
.unwrap()
.as_deref(),
Some(SECRET)
);
}
#[test]
fn chosen_keyring_backend_creates_no_file() {
let home = TempDir::new().unwrap();
let keyring = MockKeyringStore::default();
let location = save_provider_api_key_to_with_keyring(
home.path(),
AuthCredentialsStoreMode::Keyring,
"imeai",
SECRET,
&[],
Arc::new(keyring.clone()),
)
.unwrap();
assert!(matches!(location, ProviderApiKeyLocation::Keyring { .. }));
assert_eq!(keyring.saved_value(ACCOUNT).as_deref(), Some(SECRET));
assert!(!home.path().join(PROVIDER_API_KEYS_FILE).exists());
}
#[test]
fn switching_backend_removes_the_old_copy_and_moves_other_keys() {
let home = TempDir::new().unwrap();
let keyring = MockKeyringStore::default();
let other = "model-provider:altro";
for (id, key) in [("imeai", "old-key"), ("altro", "other-key")] {
save_provider_api_key_to_with_keyring(
home.path(),
AuthCredentialsStoreMode::Keyring,
id,
key,
&[],
Arc::new(keyring.clone()),
)
.unwrap();
}
// Keyring -> file: nothing stays in the keyring.
save_provider_api_key_to_with_keyring(
home.path(),
AuthCredentialsStoreMode::File,
"imeai",
SECRET,
&["altro".to_string(), "ollama".to_string()],
Arc::new(keyring.clone()),
)
.unwrap();
assert!(keyring.saved_value(ACCOUNT).is_none());
assert!(keyring.saved_value(other).is_none());
let file = ProviderApiKeyFileStore::new(home.path());
assert_eq!(file.load("imeai").unwrap().as_deref(), Some(SECRET));
assert_eq!(file.load("altro").unwrap().as_deref(), Some("other-key"));
// File -> keyring: the file goes away with its last key.
save_provider_api_key_to_with_keyring(
home.path(),
AuthCredentialsStoreMode::Keyring,
"imeai",
SECRET,
&["altro".to_string()],
Arc::new(keyring.clone()),
)
.unwrap();
assert_eq!(keyring.saved_value(ACCOUNT).as_deref(), Some(SECRET));
assert_eq!(keyring.saved_value(other).as_deref(), Some("other-key"));
assert!(!home.path().join(PROVIDER_API_KEYS_FILE).exists());
}
#[test]
fn keyring_probe_reports_an_unusable_keyring() {
assert!(provider_api_key_keyring_available_with(Arc::new(
MockKeyringStore::default()
)));
let keyring = MockKeyringStore::default();
keyring.set_error(
"model-provider:akode-keyring-probe",
keyring::Error::NoStorageAccess(std::io::Error::other("no secret service").into()),
);
assert!(!provider_api_key_keyring_available_with(Arc::new(keyring)));
}

View File

@@ -40,8 +40,10 @@ pub use auth::install_provider_api_key_store;
pub use auth::load_auth_dot_json;
pub use auth::login_with_api_key;
pub use auth::logout;
pub use auth::provider_api_key_keyring_available;
pub use auth::read_openai_api_key_from_env;
pub use auth::save_auth;
pub use auth::save_provider_api_key_to;
pub use auth_env_telemetry::AuthEnvTelemetry;
pub use auth_env_telemetry::collect_auth_env_telemetry;
pub use oauth::OAuthDeviceCodePrompt;

View File

@@ -37,3 +37,22 @@
{"run_id":"1794396553-913336000","line":5563,"new":null,"old":null}
{"run_id":"1794396553-913336000","line":5948,"new":null,"old":null}
{"run_id":"1794396553-913336000","line":5902,"new":null,"old":null}
{"run_id":"1794400489-559704000","line":406,"new":null,"old":null}
{"run_id":"1794400489-559704000","line":427,"new":null,"old":null}
{"run_id":"1794400489-559704000","line":446,"new":null,"old":null}
{"run_id":"1794400489-559704000","line":468,"new":null,"old":null}
{"run_id":"1794400489-559704000","line":4851,"new":null,"old":null}
{"run_id":"1794400489-559704000","line":4947,"new":null,"old":null}
{"run_id":"1794400489-559704000","line":4949,"new":null,"old":null}
{"run_id":"1794400489-559704000","line":4990,"new":null,"old":null}
{"run_id":"1794400489-559704000","line":4990,"new":null,"old":null}
{"run_id":"1794400489-559704000","line":5285,"new":null,"old":null}
{"run_id":"1794400489-559704000","line":4330,"new":null,"old":null}
{"run_id":"1794400489-559704000","line":5062,"new":null,"old":null}
{"run_id":"1794400489-559704000","line":5902,"new":null,"old":null}
{"run_id":"1794400489-559704000","line":5948,"new":null,"old":null}
{"run_id":"1794400489-559704000","line":3067,"new":null,"old":null}
{"run_id":"1794400489-559704000","line":5485,"new":null,"old":null}
{"run_id":"1794400489-559704000","line":5563,"new":null,"old":null}
{"run_id":"1794400489-559704000","line":5948,"new":null,"old":null}
{"run_id":"1794400489-559704000","line":5902,"new":null,"old":null}

View File

@@ -739,6 +739,9 @@ pub(crate) fn setup_context(
lmstudio_base_url: base_url(akode_model_provider_info::LMSTUDIO_OSS_PROVIDER_ID),
request_handle,
include_theme,
codex_home: config.codex_home.as_path().to_path_buf(),
key_store_mode: config.provider_api_key_store_mode,
keyring_available: akode_login::provider_api_key_keyring_available(),
}
}

View File

@@ -1,11 +1,14 @@
//! First-run setup (Italian UI): welcome, interface theme, provider, endpoint, model,
//! connection test and optional SearXNG web search. The result is written to config.toml;
//! API keys go to the provider key store (`api_key = "keyring"`), never to config.toml.
//! API keys go to the provider key store (`api_key = "keyring"`), never to config.toml; the
//! user picks the system keyring or the private file (`provider_api_key_store`, a global
//! setting: switching it moves the keys already stored).
//!
//! The wizard runs as an onboarding step at startup when no provider is configured, and again
//! from `/setup`, where it adds another provider.
use std::collections::BTreeSet;
use std::path::PathBuf;
use akode_app_server_client::AppServerRequestHandle;
use crossterm::event::KeyCode;
@@ -41,6 +44,7 @@ use crate::ui_theme::UiPalette;
use crate::ui_theme::truncate_line;
use crate::width::display_width;
use akode_app_server_protocol::ConfigEdit;
use akode_config::types::AuthCredentialsStoreMode;
const STEP_COUNT: usize = 6;
const INDENT: &str = " ";
@@ -118,6 +122,7 @@ pub(crate) enum Page {
Theme,
Provider,
Endpoint,
KeyStore,
Model,
Test,
WebSearch,
@@ -131,6 +136,7 @@ impl Page {
Self::Theme => "Tema dell'interfaccia",
Self::Provider => "Provider del modello",
Self::Endpoint => "Endpoint personalizzato",
Self::KeyStore => "Dove salvo la chiave?",
Self::Model => "Modello",
Self::Test => "Prova della connessione",
Self::WebSearch => "Ricerca web (facoltativa)",
@@ -143,7 +149,7 @@ impl Page {
Self::Welcome | Self::Saving => None,
Self::Theme => Some(1),
Self::Provider => Some(2),
Self::Endpoint => Some(3),
Self::Endpoint | Self::KeyStore => Some(3),
Self::Model => Some(4),
Self::Test => Some(5),
Self::WebSearch => Some(6),
@@ -201,6 +207,12 @@ pub(crate) struct SetupContext {
pub request_handle: Option<AppServerRequestHandle>,
/// Show the theme step (always at first run).
pub include_theme: bool,
/// AKODE_HOME, where the private key file lives.
pub codex_home: PathBuf,
/// Current `provider_api_key_store` (default auto).
pub key_store_mode: AuthCredentialsStoreMode,
/// Whether the system keyring answers; without it only the file is offered.
pub keyring_available: bool,
}
pub(crate) struct SetupWizard {
@@ -213,6 +225,8 @@ pub(crate) struct SetupWizard {
name: ProviderInput,
url: ProviderInput,
key: ProviderInput,
/// Store the key in the private file instead of the system keyring.
key_in_file: bool,
form_focus: usize,
form_error: Option<String>,
/// Base URL used for the model list and test (custom URL or the local default).
@@ -244,6 +258,8 @@ impl SetupWizard {
.iter()
.position(|palette| *palette == initial)
.unwrap_or(0);
let key_in_file =
ctx.key_store_mode == AuthCredentialsStoreMode::File || !ctx.keyring_available;
Self {
request_frame,
ctx,
@@ -254,6 +270,7 @@ impl SetupWizard {
name: ProviderInput::default(),
url: ProviderInput::default(),
key: ProviderInput::default(),
key_in_file,
form_focus: 0,
form_error: None,
base_url: String::new(),
@@ -480,6 +497,13 @@ impl SetupWizard {
serde_json::json!(provider_id),
));
edits.push(replace_config_value("model", serde_json::json!(self.model)));
let key_store_mode = self.key_store_mode();
if has_key && key_store_mode != self.ctx.key_store_mode {
edits.push(replace_config_value(
"provider_api_key_store",
serde_json::json!(key_store_mode),
));
}
if let Some(url) = &self.searx_verified {
edits.push(replace_config_value(
"web_search",
@@ -495,6 +519,19 @@ impl SetupWizard {
edits
}
/// `provider_api_key_store` after the setup: the current mode when it already uses the
/// chosen backend, otherwise `file` or `auto` (keyring first).
fn key_store_mode(&self) -> AuthCredentialsStoreMode {
match (self.key_in_file, self.ctx.key_store_mode) {
(true, _) => AuthCredentialsStoreMode::File,
(
false,
mode @ (AuthCredentialsStoreMode::Auto | AuthCredentialsStoreMode::Keyring),
) => mode,
(false, _) => AuthCredentialsStoreMode::Auto,
}
}
fn start_save(&mut self) {
self.go(Page::Saving);
self.save = CheckState::Running;
@@ -511,13 +548,18 @@ impl SetupWizard {
let key = self.api_key();
let edits = self.config_edits(&provider_id, &name, key.is_some());
let handle = self.ctx.request_handle.clone();
let store = KeyStoreTarget {
codex_home: self.ctx.codex_home.clone(),
mode: self.key_store_mode(),
other_providers: self.ctx.existing_provider_ids.iter().cloned().collect(),
};
self.outcome = Some(SetupOutcome {
provider_id: provider_id.clone(),
model: self.model.clone(),
palette: self.palette(),
});
self.pending = Some(Box::pin(async move {
Outcome::Saved(save(handle, provider_id, key, edits).await)
Outcome::Saved(save(handle, provider_id, key, store, edits).await)
}));
}
@@ -533,7 +575,11 @@ impl SetupWizard {
Ok(url) => {
self.form_error = None;
self.base_url = url;
self.start_models();
if self.key.value().is_some() {
self.go(Page::KeyStore);
} else {
self.start_models();
}
}
Err(error) => {
self.form_error = Some(error);
@@ -624,6 +670,21 @@ impl SetupWizard {
}
}
fn handle_key_store_key(&mut self, key: KeyEvent) {
if self.ctx.keyring_available {
let mut index = usize::from(self.key_in_file);
if Self::move_index(key, &mut index, 2) {
self.key_in_file = index == 1;
return;
}
}
match key.code {
KeyCode::Enter => self.start_models(),
KeyCode::Esc => self.go(Page::Endpoint),
_ => {}
}
}
fn form_input_mut(&mut self) -> Option<&mut ProviderInput> {
match self.form_focus {
0 => Some(&mut self.name),
@@ -816,20 +877,40 @@ pub(crate) async fn fetch_provider_models(
.map(|list| list.models)
}
/// Where the setup stores the API key.
struct KeyStoreTarget {
codex_home: PathBuf,
mode: AuthCredentialsStoreMode,
/// Providers whose keys follow a global mode switch.
other_providers: Vec<String>,
}
async fn save(
handle: Option<AppServerRequestHandle>,
provider_id: String,
api_key: Option<String>,
store: KeyStoreTarget,
edits: Vec<ConfigEdit>,
) -> Result<(), String> {
let handle = handle.ok_or_else(|| "Server dell'app non disponibile.".to_string())?;
if let Some(key) = api_key.as_deref() {
akode_model_provider_info::save_provider_api_key(&provider_id, key)
.map_err(|err| format!("Impossibile salvare la chiave API: {err}"))?;
akode_login::save_provider_api_key_to(
&store.codex_home,
store.mode,
&provider_id,
key,
&store.other_providers,
)
.map_err(|err| format!("Impossibile salvare la chiave API: {err}"))?;
}
crate::config_update::write_config_batch(handle, edits)
.await
.map(|_| ())
.map(|_| {
if api_key.is_some() {
// Read keys from the backend just chosen, without waiting for a reload.
akode_login::install_provider_api_key_store(&store.codex_home, store.mode);
}
})
.map_err(|err| {
setup_net::redact(
&format!(
@@ -879,6 +960,7 @@ impl KeyboardHandler for SetupWizard {
}
}
Page::Endpoint => self.handle_endpoint_key(key),
Page::KeyStore => self.handle_key_store_key(key),
Page::Model => self.handle_model_key(key),
Page::Test => self.handle_test_key(key),
Page::WebSearch => self.handle_searx_key(key),
@@ -1055,7 +1137,10 @@ impl SetupWizard {
fn hints(&self) -> Vec<(&'static str, &'static str)> {
match self.page {
Page::Welcome => vec![("invio", "inizia"), ("ctrl+c", "esci")],
Page::Theme | Page::Provider => {
Page::KeyStore if !self.ctx.keyring_available => {
vec![("invio", "conferma"), ("esc", "indietro")]
}
Page::Theme | Page::Provider | Page::KeyStore => {
vec![
("↑/↓", "scegli"),
("invio", "conferma"),
@@ -1157,7 +1242,7 @@ impl SetupWizard {
}
Page::Endpoint => {
lines.extend(wrap_text(
"Chiave facoltativa: va nel portachiavi del sistema, mai in config.toml.",
"Chiave facoltativa: non finisce mai in config.toml.",
w,
Style::default().dim(),
));
@@ -1193,6 +1278,42 @@ impl SetupWizard {
lines.extend(wrap_text(error, w, Style::default().red()));
}
}
Page::KeyStore => {
let file_detail = if cfg!(windows) {
"(solo il tuo utente)"
} else {
"(solo il tuo utente, permessi 600)"
};
let intro = if self.ctx.keyring_available {
"La chiave API non finisce mai in config.toml."
} else {
"Portachiavi del sistema non disponibile: uso il file."
};
lines.extend(wrap_text(intro, w, Style::default().dim()));
lines.push(Line::default());
let mut choices = Vec::new();
if self.ctx.keyring_available {
choices.push(("Portachiavi del sistema", "(consigliato)", false));
}
choices.push(("File protetto", file_detail, true));
for (index, (label, detail, file)) in choices.into_iter().enumerate() {
lines.push(option_line(
index + 1,
&format!("{label:<23}"),
Some(detail),
file == self.key_in_file,
w,
));
}
if self.key_store_mode() != self.ctx.key_store_mode {
lines.push(Line::default());
lines.extend(wrap_text(
"Vale per tutti i provider: le altre chiavi si spostano.",
w,
Style::default().dim(),
));
}
}
Page::Model => {
lines.push(truncate_line(
Line::from(vec!["Server: ".dim(), self.base_url.clone().into()]),

View File

@@ -8,6 +8,8 @@ const SECRET: &str = "sk-akode-test-secret-0123456789";
fn wizard() -> SetupWizard {
let mut ctx = SetupContext {
include_theme: true,
key_store_mode: AuthCredentialsStoreMode::Auto,
keyring_available: true,
..Default::default()
};
ctx.existing_provider_ids
@@ -146,6 +148,9 @@ fn model_list_screen() {
let mut wizard = endpoint_wizard();
wizard.form_focus = 3;
wizard.handle_key_event(key(KeyCode::Enter));
// A key was entered: choose where to store it first.
assert_eq!(wizard.page, Page::KeyStore);
wizard.handle_key_event(key(KeyCode::Enter));
assert_eq!(wizard.page, Page::Model);
assert!(wizard.pending.is_some());
insta::assert_snapshot!("setup_model_loading_80", render(&wizard, 80, 12));
@@ -370,3 +375,87 @@ fn long_model_list_filters_by_text_and_free_toggle() {
wizard.handle_key_event(key(KeyCode::Enter));
assert_eq!(wizard.model, "m-1");
}
/// The endpoint form with a key, confirmed: the key storage choice follows.
fn key_store_wizard(configure: impl FnOnce(&mut SetupContext)) -> SetupWizard {
let mut ctx = wizard().ctx.clone();
configure(&mut ctx);
let mut wizard = SetupWizard::new(FrameRequester::test_dummy(), ctx);
wizard.go(Page::Endpoint);
type_text(&mut wizard, "imeAI");
wizard.handle_key_event(key(KeyCode::Tab));
type_text(&mut wizard, "http://192.168.40.25:8080/v1");
wizard.handle_key_event(key(KeyCode::Tab));
type_text(&mut wizard, SECRET);
wizard.handle_key_event(key(KeyCode::Tab));
wizard.handle_key_event(key(KeyCode::Enter));
assert_eq!(wizard.page, Page::KeyStore);
wizard
}
fn key_store_edit(wizard: &SetupWizard) -> Option<serde_json::Value> {
let edits = wizard.config_edits("imeai", "imeAI", /*has_key*/ true);
let rendered = serde_json::to_string(
&edits
.iter()
.map(|edit| (edit.key_path.clone(), edit.value.clone()))
.collect::<Vec<_>>(),
)
.expect("json");
assert!(!rendered.contains(SECRET));
edits
.into_iter()
.find(|edit| edit.key_path == "provider_api_key_store")
.map(|edit| edit.value)
}
#[test]
fn key_store_choice_defaults_to_the_keyring() {
let mut wizard = key_store_wizard(|_| {});
snapshot_all_widths("setup_key_store", &wizard, 12);
assert!(!wizard.key_in_file);
assert_eq!(key_store_edit(&wizard), None);
wizard.handle_key_event(key(KeyCode::Down));
assert!(wizard.key_in_file);
snapshot_all_widths("setup_key_store_file", &wizard, 14);
assert_eq!(key_store_edit(&wizard), Some(serde_json::json!("file")));
for width in [40u16, 60, 80, 120] {
assert!(!render(&wizard, width, 14).contains("sk-akode"));
}
wizard.handle_key_event(key(KeyCode::Esc));
assert_eq!(wizard.page, Page::Endpoint);
}
#[test]
fn key_store_choice_preselects_the_configured_file() {
let mut wizard = key_store_wizard(|ctx| ctx.key_store_mode = AuthCredentialsStoreMode::File);
assert!(wizard.key_in_file);
assert_eq!(key_store_edit(&wizard), None);
wizard.handle_key_event(key(KeyCode::Char('1')));
assert!(!wizard.key_in_file);
assert_eq!(key_store_edit(&wizard), Some(serde_json::json!("auto")));
wizard.handle_key_event(key(KeyCode::Enter));
assert_eq!(wizard.page, Page::Model);
}
#[test]
fn key_store_choice_offers_only_the_file_without_a_keyring() {
let mut wizard = key_store_wizard(|ctx| ctx.keyring_available = false);
assert!(wizard.key_in_file);
wizard.handle_key_event(key(KeyCode::Up));
assert!(wizard.key_in_file);
snapshot_all_widths("setup_key_store_no_keyring", &wizard, 14);
assert_eq!(key_store_edit(&wizard), Some(serde_json::json!("file")));
}
#[test]
fn endpoint_without_a_key_skips_the_storage_choice() {
let mut wizard = wizard();
wizard.go(Page::Endpoint);
type_text(&mut wizard, "imeAI");
wizard.handle_key_event(key(KeyCode::Tab));
type_text(&mut wizard, "http://192.168.40.25:8080/v1");
wizard.form_focus = 3;
wizard.handle_key_event(key(KeyCode::Enter));
assert_eq!(wizard.page, Page::Model);
}

View File

@@ -5,7 +5,7 @@ expression: rendered
Endpoint personalizzato passo 3 di 6
Chiave facoltativa: va nel portachiavi del sistema, mai in config.toml.
Chiave facoltativa: non finisce mai in config.toml.
Nome imeAI
URL http://192.168.40.25:8080/v1

View File

@@ -5,8 +5,7 @@ expression: rendered
Endpoint personalizzato passo 3 di 6
Chiave facoltativa: va nel portachiavi del sistema, mai
in config.toml.
Chiave facoltativa: non finisce mai in config.toml.
Nome imeAI
URL http://192.168.40.25:8080/v1

View File

@@ -5,7 +5,7 @@ expression: rendered
Endpoint personalizzato passo 3 di 6
Chiave facoltativa: va nel portachiavi del sistema, mai in config.toml.
Chiave facoltativa: non finisce mai in config.toml.
Nome imeAI
URL http://192.168.40.25:8080/v1

View File

@@ -5,7 +5,7 @@ expression: "render(&wizard, 80, 18)"
Endpoint personalizzato passo 3 di 6
Chiave facoltativa: va nel portachiavi del sistema, mai in config.toml.
Chiave facoltativa: non finisce mai in config.toml.
Nome x
› URL ftp://nope

View File

@@ -0,0 +1,13 @@
---
source: tui/src/onboarding/setup_wizard_tests.rs
expression: rendered
---
Dove salvo la chiave? passo 3 di 6
La chiave API non finisce mai in config.toml.
› 1. Portachiavi del sistema (consigliato)
2. File protetto (solo il tuo utente, permessi 600)
↑/↓ scegli · invio conferma · esc indietro

View File

@@ -0,0 +1,13 @@
---
source: tui/src/onboarding/setup_wizard_tests.rs
expression: rendered
---
Dove salvo la chiave? passo 3 di 6
La chiave API non finisce mai in config.toml.
› 1. Portachiavi del sistema (consigliato)
2. File protetto (solo il tuo utente, perm…
↑/↓ scegli · invio conferma · esc indietro

View File

@@ -0,0 +1,13 @@
---
source: tui/src/onboarding/setup_wizard_tests.rs
expression: rendered
---
Dove salvo la chiave? passo 3 di 6
La chiave API non finisce mai in config.toml.
› 1. Portachiavi del sistema (consigliato)
2. File protetto (solo il tuo utente, permessi 600)
↑/↓ scegli · invio conferma · esc indietro

View File

@@ -0,0 +1,15 @@
---
source: tui/src/onboarding/setup_wizard_tests.rs
expression: rendered
---
Dove salvo la chiave? passo 3 di 6
La chiave API non finisce mai in config.toml.
1. Portachiavi del sistema (consigliato)
› 2. File protetto (solo il tuo utente, permessi 600)
Vale per tutti i provider: le altre chiavi si spostano.
↑/↓ scegli · invio conferma · esc indietro

View File

@@ -0,0 +1,15 @@
---
source: tui/src/onboarding/setup_wizard_tests.rs
expression: rendered
---
Dove salvo la chiave? passo 3 di 6
La chiave API non finisce mai in config.toml.
1. Portachiavi del sistema (consigliato)
› 2. File protetto (solo il tuo utente, perm…
Vale per tutti i provider: le altre chiavi si spostano.
↑/↓ scegli · invio conferma · esc indietro

View File

@@ -0,0 +1,15 @@
---
source: tui/src/onboarding/setup_wizard_tests.rs
expression: rendered
---
Dove salvo la chiave? passo 3 di 6
La chiave API non finisce mai in config.toml.
1. Portachiavi del sistema (consigliato)
› 2. File protetto (solo il tuo utente, permessi 600)
Vale per tutti i provider: le altre chiavi si spostano.
↑/↓ scegli · invio conferma · esc indietro

View File

@@ -0,0 +1,14 @@
---
source: tui/src/onboarding/setup_wizard_tests.rs
expression: rendered
---
Dove salvo la chiave? passo 3 di 6
Portachiavi del sistema non disponibile: uso il file.
› 1. File protetto (solo il tuo utente, permessi 600)
Vale per tutti i provider: le altre chiavi si spostano.
invio conferma · esc indietro

View File

@@ -0,0 +1,14 @@
---
source: tui/src/onboarding/setup_wizard_tests.rs
expression: rendered
---
Dove salvo la chiave? passo 3 di 6
Portachiavi del sistema non disponibile: uso il file.
› 1. File protetto (solo il tuo utente, perm…
Vale per tutti i provider: le altre chiavi si spostano.
invio conferma · esc indietro

View File

@@ -0,0 +1,14 @@
---
source: tui/src/onboarding/setup_wizard_tests.rs
expression: rendered
---
Dove salvo la chiave? passo 3 di 6
Portachiavi del sistema non disponibile: uso il file.
› 1. File protetto (solo il tuo utente, permessi 600)
Vale per tutti i provider: le altre chiavi si spostano.
invio conferma · esc indietro