-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-auth.ts
More file actions
43 lines (36 loc) · 1.62 KB
/
test-auth.ts
File metadata and controls
43 lines (36 loc) · 1.62 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
import { HermesAuthClient, HermesApiClient, HermesShipmentApi } from './src';
async function testAuthentication() {
console.log('Testing Hermes API Authentication...\n');
const authClient = new HermesAuthClient({
clientId: 'test-client',
clientSecret: 'test-secret',
authBaseUrl: 'https://authme-int.myhermes.de',
});
// Test 1: Authorization URL generation
console.log('1. Authorization URL Generation:');
const authUrl = authClient.getAuthorizationUrl('https://example.com/callback', 'test-state');
console.log(' Generated URL:', authUrl);
console.log(' ✓ Authorization URL generated successfully\n');
// Test 2: Token Storage
console.log('2. Token Storage:');
const mockToken = {
accessToken: 'mock-access-token',
refreshToken: 'mock-refresh-token',
expiresAt: Date.now() + 3600000,
tokenType: 'Bearer',
scope: 'full',
};
authClient.setStoredToken(mockToken);
const storedToken = authClient.getStoredToken();
console.log(' Stored token type:', storedToken?.tokenType);
console.log(' Is authenticated:', authClient.isAuthenticated());
console.log(' ✓ Token storage working correctly\n');
// Test 3: API Client initialization
console.log('3. API Client Initialization:');
const apiClient = new HermesApiClient(authClient, 'https://ws-int.myhermes.de');
const shipmentApi = new HermesShipmentApi(apiClient);
console.log(' ✓ API clients initialized successfully\n');
console.log('All tests passed! The authentication system is ready to use.');
console.log('\nNote: Actual API calls require valid credentials.');
}
testAuthentication().catch(console.error);