-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-cname.js
More file actions
58 lines (46 loc) · 1.37 KB
/
Copy pathtest-cname.js
File metadata and controls
58 lines (46 loc) · 1.37 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
#!/usr/bin/env node
/**
* Test script for CNAME record functionality
*/
// Set required environment variables for testing
process.env.DOMAIN_FILTER = 'test.local';
process.env.SHARED_SECRET = 'test-secret';
// Mock config for testing
const config = {
dnsTTL: 300,
dryRun: true,
dnsmasqDir: '/tmp/test-dnsmasq'
};
// Mock logger
const logger = {
debug: console.log,
info: console.log,
warn: console.warn,
error: console.error
};
// Import validator
const validator = require('./src/utils/validator');
// Test CNAME validation
console.log('Testing CNAME validation...');
// Test valid CNAME endpoint
const validCnameEndpoint = {
dnsName: 'api.example.com',
targets: ['service.example.com'],
recordType: 'CNAME'
};
console.log('Valid CNAME endpoint:', validator.isValidEndpoint(validCnameEndpoint));
// Test invalid CNAME endpoint (invalid target)
const invalidCnameEndpoint = {
dnsName: 'api.example.com',
targets: ['invalid..domain'],
recordType: 'CNAME'
};
console.log('Invalid CNAME endpoint:', validator.isValidEndpoint(invalidCnameEndpoint));
// Test multiple CNAME targets
const multiCnameEndpoint = {
dnsName: 'api.example.com',
targets: ['service1.example.com', 'service2.example.com'],
recordType: 'CNAME'
};
console.log('Multiple CNAME targets:', validator.isValidEndpoint(multiCnameEndpoint));
console.log('CNAME validation tests completed.');