claude-connector: an old document is refused at load, the installer authors it again
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
af087128e6
commit
b0ac65edde
3 changed files with 7 additions and 8 deletions
|
|
@ -11,10 +11,9 @@ pub(crate) const PROVIDER: &str = "claude-code";
|
||||||
/// connector; the credential itself is the systemd credential
|
/// connector; the credential itself is the systemd credential
|
||||||
/// [`ClaudeCodeConfig::token_credential`] names, and it reaches the child on a
|
/// [`ClaudeCodeConfig::token_credential`] names, and it reaches the child on a
|
||||||
/// pipe whichever this is.
|
/// pipe whichever this is.
|
||||||
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
pub enum ClaudeAuth {
|
pub enum ClaudeAuth {
|
||||||
/// The subscription's OAuth token. The plan's usage is metered.
|
/// The subscription's OAuth token. The plan's usage is metered.
|
||||||
#[default]
|
|
||||||
OAuthToken,
|
OAuthToken,
|
||||||
/// An Anthropic API key. Nothing is metered: a key has no subscription plan.
|
/// An Anthropic API key. Nothing is metered: a key has no subscription plan.
|
||||||
ApiKey,
|
ApiKey,
|
||||||
|
|
|
||||||
|
|
@ -108,8 +108,9 @@ pub struct ClaudeConnectorConfig {
|
||||||
#[cultcache(key = 22)]
|
#[cultcache(key = 22)]
|
||||||
pub handle_secret_credential: String,
|
pub handle_secret_credential: String,
|
||||||
/// Which credential `token_credential` holds: the subscription token, or an
|
/// Which credential `token_credential` holds: the subscription token, or an
|
||||||
/// Anthropic API key. A document without this field is the token.
|
/// Anthropic API key. A document written before this field existed is refused at
|
||||||
#[cultcache(key = 23, default)]
|
/// load (the canonical-form check): the installer authors the document again.
|
||||||
|
#[cultcache(key = 23)]
|
||||||
pub auth: ClaudeAuth,
|
pub auth: ClaudeAuth,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -298,10 +298,9 @@ fn serve_refuses_a_document_that_is_not_there() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn the_auth_choice_round_trips_and_defaults_to_the_token() {
|
fn the_auth_choice_round_trips() {
|
||||||
let scratch = Scratch::new();
|
let scratch = Scratch::new();
|
||||||
let path = scratch.path("connector.cc");
|
let path = scratch.path("connector.cc");
|
||||||
assert_eq!(valid().auth, ClaudeAuth::OAuthToken);
|
|
||||||
let keyed = ClaudeConnectorConfig {
|
let keyed = ClaudeConnectorConfig {
|
||||||
auth: ClaudeAuth::ApiKey,
|
auth: ClaudeAuth::ApiKey,
|
||||||
..valid()
|
..valid()
|
||||||
|
|
@ -361,7 +360,7 @@ struct BeforeAuth {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[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 scratch = Scratch::new();
|
||||||
let path = scratch.path("before.cc");
|
let path = scratch.path("before.cc");
|
||||||
let now = valid();
|
let now = valid();
|
||||||
|
|
@ -401,7 +400,7 @@ fn a_document_without_the_auth_field_is_the_token() {
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
assert_eq!(load_config(&path).unwrap(), now);
|
assert!(matches!(load_config(&path), Err(ConfigError::Store)));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue