| @@ -216,6 +216,38 @@ func TestApplyClaudeHeaders_DisableDeviceProfileStabilization(t *testing.T) { · 215 unmodified lines |
| 216 | assertClaudeFingerprint(t, lowerReq.Header, "claude-cli/2.1.61 (external, cli)", "0.73.0", "v24.2.0", "Windows", "x64") | 216 | assertClaudeFingerprint(t, lowerReq.Header, "claude-cli/2.1.61 (external, cli)", "0.73.0", "v24.2.0", "Windows", "x64") |
| 217 | } | 217 | } |
| 218 | | 218 | |
| | 219 | func TestApplyClaudeHeaders_LegacyModePreservesConfiguredUserAgentOverrideForClaudeClients(t *testing.T) { |
| | 220 | resetClaudeDeviceProfileCache() |
| | 221 | |
| | 222 | stabilize := false |
| | 223 | cfg := &config.Config{ |
| | 224 | ClaudeHeaderDefaults: config.ClaudeHeaderDefaults{ |
| | 225 | UserAgent: "claude-cli/2.1.60 (external, cli)", |
| | 226 | PackageVersion: "0.70.0", |
| | 227 | RuntimeVersion: "v22.0.0", |
| | 228 | StabilizeDeviceProfile: &stabilize, |
| | 229 | }, |
| | 230 | } |
| | 231 | auth := &cliproxyauth.Auth{ |
| | 232 | ID: "auth-legacy-ua-override", |
| | 233 | Attributes: map[string]string{ |
| | 234 | "api_key": "key-legacy-ua-override", |
| | 235 | "header:User-Agent": "config-ua/1.0", |
| | 236 | }, |
| | 237 | } |
| | 238 | |
| | 239 | req := newClaudeHeaderTestRequest(t, http.Header{ |
| | 240 | "User-Agent": []string{"claude-cli/2.1.62 (external, cli)"}, |
| | 241 | "X-Stainless-Package-Version": []string{"0.74.0"}, |
| | 242 | "X-Stainless-Runtime-Version": []string{"v24.3.0"}, |
| | 243 | "X-Stainless-Os": []string{"Linux"}, |
| | 244 | "X-Stainless-Arch": []string{"x64"}, |
| | 245 | }) |
| | 246 | applyClaudeHeaders(req, auth, "key-legacy-ua-override", false, nil, cfg) |
| | 247 | |
| | 248 | assertClaudeFingerprint(t, req.Header, "config-ua/1.0", "0.74.0", "v24.3.0", "Linux", "x64") |
| | 249 | } |
| | 250 | |
| 219 | func TestApplyClaudeHeaders_LegacyModeFallsBackToRuntimeOSArchWhenMissing(t *testing.T) { | 251 | func TestApplyClaudeHeaders_LegacyModeFallsBackToRuntimeOSArchWhenMissing(t *testing.T) { |
| 220 | resetClaudeDeviceProfileCache() | 252 | resetClaudeDeviceProfileCache() |
| 221 | | 253 | |