diff --git a/crates/claude-connector/src/config.rs b/crates/claude-connector/src/config.rs index 6586d16..6e8d95f 100644 --- a/crates/claude-connector/src/config.rs +++ b/crates/claude-connector/src/config.rs @@ -11,10 +11,9 @@ pub(crate) const PROVIDER: &str = "claude-code"; /// connector; the credential itself is the systemd credential /// [`ClaudeCodeConfig::token_credential`] names, and it reaches the child on a /// pipe whichever this is. -#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] pub enum ClaudeAuth { /// The subscription's OAuth token. The plan's usage is metered. - #[default] OAuthToken, /// An Anthropic API key. Nothing is metered: a key has no subscription plan. ApiKey, diff --git a/crates/claude-connector/src/daemon.rs b/crates/claude-connector/src/daemon.rs index 3bf4287..5502eac 100644 --- a/crates/claude-connector/src/daemon.rs +++ b/crates/claude-connector/src/daemon.rs @@ -108,8 +108,9 @@ pub struct ClaudeConnectorConfig { #[cultcache(key = 22)] pub handle_secret_credential: String, /// Which credential `token_credential` holds: the subscription token, or an - /// Anthropic API key. A document without this field is the token. - #[cultcache(key = 23, default)] + /// Anthropic API key. A document written before this field existed is refused at + /// load (the canonical-form check): the installer authors the document again. + #[cultcache(key = 23)] pub auth: ClaudeAuth, } diff --git a/crates/claude-connector/tests/config_document.rs b/crates/claude-connector/tests/config_document.rs index e57d0e6..d96583d 100644 --- a/crates/claude-connector/tests/config_document.rs +++ b/crates/claude-connector/tests/config_document.rs @@ -298,10 +298,9 @@ fn serve_refuses_a_document_that_is_not_there() { } #[test] -fn the_auth_choice_round_trips_and_defaults_to_the_token() { +fn the_auth_choice_round_trips() { let scratch = Scratch::new(); let path = scratch.path("connector.cc"); - assert_eq!(valid().auth, ClaudeAuth::OAuthToken); let keyed = ClaudeConnectorConfig { auth: ClaudeAuth::ApiKey, ..valid() @@ -361,7 +360,7 @@ struct BeforeAuth { } #[test] -fn a_document_without_the_auth_field_is_the_token() { +fn a_document_from_before_the_auth_field_is_refused_until_it_is_authored_again() { let scratch = Scratch::new(); let path = scratch.path("before.cc"); let now = valid(); @@ -401,7 +400,7 @@ fn a_document_without_the_auth_field_is_the_token() { ) .unwrap(); } - assert_eq!(load_config(&path).unwrap(), now); + assert!(matches!(load_config(&path), Err(ConfigError::Store))); } #[test]