Skip to content

Commit 19c3d0b

Browse files
rcourtmanclaude
andcommitted
fix: improve test connections to use existing token secrets
- Allow testing with existing saved token secrets when not provided in form - Improve error messages to indicate what fields are missing - Fall back to existing .env file for token secrets during testing - Handle both new secrets and existing configuration testing scenarios 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 594d1dc commit 19c3d0b

File tree

1 file changed

+49
-22
lines changed

1 file changed

+49
-22
lines changed

server/configApi.js

Lines changed: 49 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -243,36 +243,63 @@ class ConfigApi {
243243
const testPbsConfigs = [];
244244

245245
// Test Proxmox endpoint if configured
246-
if (proxmoxHost && proxmoxTokenId && proxmoxTokenSecret) {
247-
testEndpoints.push({
248-
id: 'test-primary',
249-
name: 'Test Primary',
250-
host: proxmoxHost,
251-
port: parseInt(proxmoxPort) || 8006,
252-
tokenId: proxmoxTokenId,
253-
tokenSecret: proxmoxTokenSecret,
254-
enabled: true,
255-
allowSelfSignedCerts: true
256-
});
246+
if (proxmoxHost && proxmoxTokenId) {
247+
// If no token secret provided, try to get it from existing config
248+
let tokenSecret = proxmoxTokenSecret;
249+
if (!tokenSecret) {
250+
const existingConfig = await this.readEnvFile();
251+
tokenSecret = existingConfig.PROXMOX_TOKEN_SECRET;
252+
}
253+
254+
if (tokenSecret) {
255+
testEndpoints.push({
256+
id: 'test-primary',
257+
name: 'Test Primary',
258+
host: proxmoxHost,
259+
port: parseInt(proxmoxPort) || 8006,
260+
tokenId: proxmoxTokenId,
261+
tokenSecret: tokenSecret,
262+
enabled: true,
263+
allowSelfSignedCerts: true
264+
});
265+
}
257266
}
258267

259268
// Test PBS endpoint if configured
260-
if (pbsHost && pbsTokenId && pbsTokenSecret) {
261-
testPbsConfigs.push({
262-
id: 'test-pbs',
263-
name: 'Test PBS',
264-
host: pbsHost,
265-
port: parseInt(pbsPort) || 8007,
266-
tokenId: pbsTokenId,
267-
tokenSecret: pbsTokenSecret,
268-
allowSelfSignedCerts: true
269-
});
269+
if (pbsHost && pbsTokenId) {
270+
// If no token secret provided, try to get it from existing config
271+
let tokenSecret = pbsTokenSecret;
272+
if (!tokenSecret) {
273+
const existingConfig = await this.readEnvFile();
274+
tokenSecret = existingConfig.PBS_TOKEN_SECRET;
275+
}
276+
277+
if (tokenSecret) {
278+
testPbsConfigs.push({
279+
id: 'test-pbs',
280+
name: 'Test PBS',
281+
host: pbsHost,
282+
port: parseInt(pbsPort) || 8007,
283+
tokenId: pbsTokenId,
284+
tokenSecret: tokenSecret,
285+
allowSelfSignedCerts: true
286+
});
287+
}
270288
}
271289

272290
if (testEndpoints.length === 0) {
291+
let errorMessage = 'No Proxmox server configured to test. ';
292+
if (!proxmoxHost) {
293+
errorMessage += 'Missing host address.';
294+
} else if (!proxmoxTokenId) {
295+
errorMessage += 'Missing API token ID.';
296+
} else {
297+
errorMessage += 'Missing API token secret (enter a new one or save existing configuration first).';
298+
}
299+
273300
return {
274301
success: false,
275-
error: 'No Proxmox server configured to test'
302+
error: errorMessage
276303
};
277304
}
278305

0 commit comments

Comments
 (0)