Geert Rademakes 218046ec4f webdav setup
2025-09-17 10:55:35 +02:00

62 lines
1.8 KiB
JavaScript

#!/usr/bin/env node
/**
* WebDAV Integration Test
*
* This script tests the WebDAV service integration with a sample Nextcloud instance.
* Update the configuration below to match your Nextcloud setup.
*/
import { WebDAVService } from './dist/services/webdavService.js';
// Test configuration - update these values for your Nextcloud instance
const testConfig = {
provider: 'webdav',
url: 'https://your-nextcloud.com/remote.php/dav/files/username/',
username: 'your-username',
password: 'your-password-or-app-password',
basePath: '/music-files'
};
async function testWebDAVConnection() {
console.log('🧪 Testing WebDAV connection...');
console.log('📋 Configuration:', {
...testConfig,
password: '***' // Hide password in logs
});
try {
// Create WebDAV service
const webdavService = new WebDAVService(testConfig);
// Test connection
console.log('🔗 Testing connection...');
const isConnected = await webdavService.testConnection();
if (isConnected) {
console.log('✅ WebDAV connection successful!');
// Test listing files
console.log('📁 Testing file listing...');
const files = await webdavService.listAllFiles();
console.log(`📊 Found ${files.length} files`);
// Test listing folders
console.log('📂 Testing folder listing...');
const folders = await webdavService.listAllFolders();
console.log(`📊 Found ${folders.length} folders:`, folders);
console.log('🎉 All WebDAV tests passed!');
} else {
console.log('❌ WebDAV connection failed');
}
} catch (error) {
console.error('❌ WebDAV test failed:', error.message);
console.error('💡 Make sure to update the configuration in this file with your Nextcloud details');
}
}
// Run the test
testWebDAVConnection().catch(console.error);