-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-auth.js
More file actions
60 lines (48 loc) · 1.52 KB
/
Copy pathtest-auth.js
File metadata and controls
60 lines (48 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/**
* Test authentication with Purolator API
*/
require('dotenv').config();
// Enable SOAP debugging
process.env.DEBUG_SOAP = 'true';
const { shipmentTrackingService } = require('./dist/services/shipment-tracking.service');
async function testAuth() {
console.log('='.repeat(80));
console.log('Testing Purolator API Authentication');
console.log('='.repeat(80));
console.log();
try {
// Initialize the service
console.log('Initializing tracking service...');
await shipmentTrackingService.initialize();
console.log('✓ Service initialized\n');
// Test with a simple tracking request
console.log('Making tracking request...');
console.log();
const result = await shipmentTrackingService.track({
trackingIds: ['335701264889']
});
console.log('\n=== RESULT ===');
console.log(JSON.stringify(result, null, 2));
console.log('='.repeat(80));
if (result.success) {
console.log('\n✅ SUCCESS! Authentication working correctly.');
} else {
console.log('\n❌ Request failed. Check the error details above.');
}
} catch (error) {
console.error('\n❌ Error during test:', error.message);
if (error.response) {
console.error('\nResponse status:', error.response.status);
console.error('Response data:', error.response.data);
}
process.exit(1);
}
}
// Run the test
testAuth().then(() => {
console.log('\nTest completed!');
process.exit(0);
}).catch(error => {
console.error('\nTest failed:', error);
process.exit(1);
});