diff --git a/src/lib/constants/icon-map.ts b/src/lib/constants/icon-map.ts index 596d58d..1329a75 100644 --- a/src/lib/constants/icon-map.ts +++ b/src/lib/constants/icon-map.ts @@ -258,26 +258,28 @@ export const iconMap: Record = { building: ``, map: ``, signpost: ``, + wifi: ``, // '': ``, + circle: ``, - // 'pie-chart': ``, - // 'help-circle': ``, - // 'balance-scale': ``, - // 'code': ``, - // 'test': ``, - // 'performance': ``, - // 'security': ``, - // 'users': ``, - // 'list-ordered': ``, - // 'tunnel': ``, - // 'user': ``, - // 'flag': ``, - // 'book-open': ``, - // 'shuffle': ``, + 'pie-chart': ``, + 'help-circle': ``, + 'balance-scale': ``, + code: ``, + test: ``, + performance: ``, + security: ``, + users: ``, + 'list-ordered': ``, + tunnel: ``, + user: ``, + flag: ``, + 'book-open': ``, + shuffle: ``, // 'template': ``, - // 'share': ``, - // 'list-checks': ``, - // 'clipboard-list': ``, + share: ``, + 'list-checks': ``, + 'clipboard-list': ``, // 'edit-3': ``, // 'mail-check': ``, // 'eye': ``, diff --git a/src/lib/constants/nav.ts b/src/lib/constants/nav.ts index ec80147..b16d090 100644 --- a/src/lib/constants/nav.ts +++ b/src/lib/constants/nav.ts @@ -1425,6 +1425,27 @@ export const SUB_NAV: Record = { 'internet routing', ], }, + { + href: makePath('/diagnostics/network/asn-geo-lookup'), + label: 'ASN & Geolocation Lookup', + description: 'Look up IP address geolocation, ISP, and autonomous system information', + icon: 'map-pin', + keywords: [ + 'asn', + 'geolocation', + 'ip', + 'lookup', + 'location', + 'isp', + 'organization', + 'country', + 'city', + 'coordinates', + 'autonomous system', + 'network', + 'provider', + ], + }, ], }, { diff --git a/src/lib/content/asn-geo.ts b/src/lib/content/asn-geo.ts new file mode 100644 index 0000000..283d38d --- /dev/null +++ b/src/lib/content/asn-geo.ts @@ -0,0 +1,221 @@ +export const asnGeoContent = { + title: 'ASN & Geolocation Lookup', + description: 'Look up IP address geolocation, ISP, and autonomous system information', + sections: { + whatIsGeoIP: { + title: 'What is IP Geolocation?', + content: + 'IP geolocation is the mapping of an IP address to its real-world geographic location. Combined with ASN (Autonomous System Number) data, it provides comprehensive information about the network ownership, ISP, and approximate physical location of an IP address.', + }, + howItWorks: { + title: 'How Geolocation Works', + content: 'Geolocation databases map IP address ranges to locations by combining data from:', + steps: [ + 'Regional Internet Registries (RIRs) - Provide IP allocation data', + 'ISP registration records - Organization and network details', + 'User-submitted data - Crowdsourced location corrections', + 'Active probing - Latency measurements and traceroutes', + 'Wi-Fi and mobile data - Location signals from devices', + ], + }, + dataProvided: { + title: 'Information Provided', + categories: [ + { + category: 'Network Information', + fields: [ + { field: 'ASN', description: 'Autonomous System Number of the network' }, + { field: 'Organization', description: 'Network owner or operator' }, + { field: 'ISP', description: 'Internet Service Provider name' }, + ], + }, + { + category: 'Geographic Location', + fields: [ + { field: 'Country', description: 'Country name and code' }, + { field: 'Region/State', description: 'Administrative region' }, + { field: 'City', description: 'City name (approximate)' }, + { field: 'Coordinates', description: 'Latitude and longitude' }, + { field: 'Timezone', description: 'Local timezone identifier' }, + ], + }, + { + category: 'Connection Type', + fields: [ + { field: 'Mobile', description: 'Whether the IP is from a mobile network' }, + { field: 'Proxy', description: 'If the IP is a known proxy/VPN' }, + { field: 'Hosting', description: 'If the IP belongs to a datacenter/hosting provider' }, + ], + }, + ], + }, + accuracy: { + title: 'Accuracy Considerations', + levels: [ + { + level: 'Country', + accuracy: '95-99%', + description: 'Very high accuracy for country-level identification', + }, + { + level: 'Region/State', + accuracy: '75-85%', + description: 'Good accuracy but can vary by country and ISP', + }, + { + level: 'City', + accuracy: '50-75%', + description: 'Moderate accuracy; actual location may be in nearby cities', + }, + { + level: 'Coordinates', + accuracy: '10-50 km radius', + description: 'Approximate location; not precise enough for exact addresses', + }, + ], + }, + useCases: { + title: 'Common Use Cases', + cases: [ + { + scenario: 'Content Localization', + use: 'Serve region-appropriate content and language', + action: 'Check country and timezone for automatic localization', + }, + { + scenario: 'Fraud Detection', + use: 'Identify suspicious access patterns', + action: 'Compare login location with user profile and detect proxies', + }, + { + scenario: 'Analytics & Insights', + use: 'Understand user demographics and traffic sources', + action: 'Analyze geographic distribution of visitors', + }, + { + scenario: 'Compliance & Restrictions', + use: 'Enforce geographic access policies', + action: 'Block or allow access based on country or region', + }, + { + scenario: 'Network Troubleshooting', + use: 'Identify network path and routing issues', + action: 'Check ISP, ASN, and location of problem connections', + }, + { + scenario: 'Security Analysis', + use: 'Detect datacenter/proxy usage', + action: 'Flag hosting and proxy IPs for additional verification', + }, + ], + }, + limitations: { + title: 'Limitations & Privacy', + points: [ + { + limitation: 'Not Precise Location', + description: + 'IP geolocation cannot pinpoint exact addresses or buildings. Accuracy is typically at city level or broader.', + }, + { + limitation: 'VPNs and Proxies', + description: + 'Users with VPNs or proxies will appear to be in the VPN server location, not their actual location.', + }, + { + limitation: 'Mobile Networks', + description: + 'Mobile IPs may show central office locations rather than user location due to carrier-grade NAT.', + }, + { + limitation: 'Dynamic IPs', + description: 'IP addresses can be reassigned, so historical data may not reflect current location.', + }, + { + limitation: 'Privacy Concerns', + description: 'Geolocation can reveal general location; always handle with appropriate privacy safeguards.', + }, + ], + }, + asnExplained: { + title: 'Understanding ASN Data', + content: + 'An Autonomous System Number (ASN) identifies a network on the Internet. Each ASN represents a collection of IP prefixes under common administrative control.', + aspects: [ + { + aspect: 'Network Ownership', + description: 'ASN reveals which organization operates the network', + example: 'AS15169 belongs to Google LLC', + }, + { + aspect: 'ISP Identification', + description: 'Identifies the Internet Service Provider', + example: 'Residential users typically share ISP ASN', + }, + { + aspect: 'Routing Analysis', + description: 'ASN is crucial for BGP routing and peering', + example: 'Large networks may have multiple ASNs', + }, + { + aspect: 'Network Type', + description: 'ASN can indicate hosting, residential, or mobile networks', + example: 'Datacenter ASNs often host multiple services', + }, + ], + }, + bestPractices: { + title: 'Best Practices', + practices: [ + { + practice: 'Never Rely Solely on Geolocation', + description: 'Use as one signal among many, not the sole decision factor', + reason: 'Accuracy varies and can be circumvented', + }, + { + practice: 'Cache Results Appropriately', + description: 'Cache geolocation data but refresh periodically', + reason: 'IP allocations change over time', + }, + { + practice: 'Handle Privacy Responsibly', + description: 'Be transparent about geolocation usage', + reason: 'Users have privacy expectations and legal rights', + }, + { + practice: 'Consider Proxy Detection', + description: 'Check hosting and proxy flags for security decisions', + reason: 'Helps identify potentially suspicious traffic', + }, + { + practice: 'Combine Multiple Data Points', + description: 'Use geolocation with other signals (browser, language, etc.)', + reason: 'Improves accuracy and reduces false positives', + }, + ], + }, + dataSource: { + title: 'About IP-API', + content: + 'This tool uses IP-API.com, a free geolocation API that provides accurate location data sourced from multiple regional registries and ISP databases.', + features: [ + 'Supports both IPv4 and IPv6 addresses', + 'Country, region, city, and coordinate data', + 'ISP, organization, and ASN information', + 'Mobile, proxy, and hosting detection', + 'Timezone identification', + 'No authentication required for basic usage', + ], + }, + }, + quickTips: [ + 'City-level accuracy is approximate; actual location may vary by 10-50km', + 'VPN users will appear in the VPN server location, not their real location', + 'Mobile IPs often show carrier hub locations due to CGNAT', + 'Hosting flag indicates datacenter IPs (servers, cloud instances)', + 'Proxy flag helps identify VPN, proxy, and anonymization services', + 'ASN reveals network ownership; same ASN often means same organization', + 'Coordinates are based on IP allocation, not GPS or device location', + 'Timezone data is useful for scheduling and displaying local times', + ], +}; diff --git a/src/routes/api/internal/diagnostics/asn-geo/+server.ts b/src/routes/api/internal/diagnostics/asn-geo/+server.ts new file mode 100644 index 0000000..6606105 --- /dev/null +++ b/src/routes/api/internal/diagnostics/asn-geo/+server.ts @@ -0,0 +1,121 @@ +import { json, error } from '@sveltejs/kit'; +import type { RequestHandler } from './$types'; + +interface ASNGeoRequest { + ip: string; +} + +interface ASNGeoResponse { + ip: string; + asn?: number; + asnOrg?: string; + isp?: string; + organization?: string; + country?: string; + countryCode?: string; + region?: string; + regionName?: string; + city?: string; + zip?: string; + latitude?: number; + longitude?: number; + timezone?: string; + mobile?: boolean; + proxy?: boolean; + hosting?: boolean; + timestamp: string; +} + +async function lookupIPAPI(ip: string): Promise { + const controller = new AbortController(); + const timeoutId = setTimeout(() => controller.abort(), 10000); + + try { + // Using ip-api.com (free, no auth required, allows HTTPS) + const url = `http://ip-api.com/json/${encodeURIComponent(ip)}?fields=status,message,country,countryCode,region,regionName,city,zip,lat,lon,timezone,isp,org,as,asname,mobile,proxy,hosting,query`; + const response = await fetch(url, { + headers: { Accept: 'application/json' }, + signal: controller.signal, + }); + + clearTimeout(timeoutId); + + if (!response.ok) { + throw new Error(`IP-API failed: ${response.status}`); + } + + return await response.json(); + } catch (err) { + clearTimeout(timeoutId); + throw err; + } +} + +export const POST: RequestHandler = async ({ request }) => { + try { + const body: ASNGeoRequest = await request.json(); + const { ip } = body; + + if (!ip || typeof ip !== 'string' || !ip.trim()) { + throw error(400, 'IP address is required'); + } + + const trimmedIP = ip.trim(); + + // Basic IP validation + const ipv4Regex = /^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.?\b){4}$/; + const ipv6Regex = + /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/; + + if (!ipv4Regex.test(trimmedIP) && !ipv6Regex.test(trimmedIP)) { + throw error(400, 'Invalid IP address format'); + } + + // Lookup IP information + const data = await lookupIPAPI(trimmedIP); + + if (data.status === 'fail') { + throw error(404, data.message || 'IP lookup failed'); + } + + // Parse ASN from the 'as' field (format: "AS15169 Google LLC") + let asn: number | undefined; + let asnOrg: string | undefined; + if (data.as) { + const asParts = data.as.match(/^AS(\d+)\s*(.*)$/); + if (asParts) { + asn = parseInt(asParts[1], 10); + asnOrg = asParts[2] || data.asname; + } + } + + const response: ASNGeoResponse = { + ip: data.query || trimmedIP, + asn, + asnOrg, + isp: data.isp, + organization: data.org, + country: data.country, + countryCode: data.countryCode, + region: data.region, + regionName: data.regionName, + city: data.city, + zip: data.zip, + latitude: data.lat, + longitude: data.lon, + timezone: data.timezone, + mobile: data.mobile || false, + proxy: data.proxy || false, + hosting: data.hosting || false, + timestamp: new Date().toISOString(), + }; + + return json(response); + } catch (err) { + console.error('ASN/Geo lookup error:', err); + if (err && typeof err === 'object' && 'status' in err) { + throw err; + } + throw error(500, `ASN/Geo lookup failed: ${err instanceof Error ? err.message : 'Unknown error'}`); + } +}; diff --git a/src/routes/diagnostics/network/asn-geo-lookup/+page.svelte b/src/routes/diagnostics/network/asn-geo-lookup/+page.svelte new file mode 100644 index 0000000..d157e1a --- /dev/null +++ b/src/routes/diagnostics/network/asn-geo-lookup/+page.svelte @@ -0,0 +1,625 @@ + + +
+
+

{asnGeoContent.title}

+

{asnGeoContent.description}

+
+ + +
+
+ + +

Example Lookups

+
+
+ {#each examples as example, i (i)} + + {/each} +
+
+
+ + +
+
+

IP Lookup

+
+
+
+
+ + { + clearExampleSelection(); + if (ip.trim()) lookupIP(); + }} + /> +
+ +
+
+
+ + + {#if results} +
+
+

Results for {results.ip}

+ +
+
+
+ +
+

Network Information

+
+ {#if results.asn} +
+ +
+ ASN + AS{results.asn} +
+
+ {/if} + {#if results.asnOrg} +
+ +
+ Organization + {results.asnOrg} +
+
+ {/if} + {#if results.isp} +
+ +
+ ISP + {results.isp} +
+
+ {/if} +
+
+ + +
+

Geographic Location

+
+ {#if results.country} +
+ +
+ Country + {results.country} ({results.countryCode}) +
+
+ {/if} + {#if results.regionName} +
+ +
+ Region + {results.regionName} +
+
+ {/if} + {#if results.city} +
+ +
+ City + {results.city} +
+
+ {/if} + {#if results.timezone} +
+ +
+ Timezone + {results.timezone} +
+
+ {/if} +
+
+ + + {#if results.latitude !== undefined && results.longitude !== undefined} +
+

Coordinates

+
+
+
+ +
+
+ Latitude: + {results.latitude.toFixed(4)}° +
+
+ Longitude: + {results.longitude.toFixed(4)}° +
+
+
+ + + View full map + +
+
+ +
+
+
+ {/if} + + +
+

Connection Type

+
+
+ + Mobile Network +
+
+ + Proxy/VPN +
+
+ + Hosting/Datacenter +
+
+
+
+
+
+ {/if} + + {#if error} +
+
+
+ +
+ Lookup Failed +

{error}

+
+
+
+
+ {/if} + + +
+
+

About ASN & Geolocation

+
+
+
+
+

{asnGeoContent.sections.whatIsGeoIP.title}

+

{asnGeoContent.sections.whatIsGeoIP.content}

+
+ +
+

{asnGeoContent.sections.accuracy.title}

+
    + {#each asnGeoContent.sections.accuracy.levels as level (level.level)} +
  • + {level.level} ({level.accuracy}): + {level.description} +
  • + {/each} +
+
+ +
+

{asnGeoContent.sections.asnExplained.title}

+

{asnGeoContent.sections.asnExplained.content}

+
+ +
+

{asnGeoContent.sections.dataSource.title}

+

{asnGeoContent.sections.dataSource.content}

+
+
+ +
+

Quick Tips

+
    + {#each asnGeoContent.quickTips as tip, idx (idx)} +
  • {tip}
  • + {/each} +
+
+
+
+
+ + diff --git a/tests/unit/content/asn-geo.test.ts b/tests/unit/content/asn-geo.test.ts new file mode 100644 index 0000000..ca67ff5 --- /dev/null +++ b/tests/unit/content/asn-geo.test.ts @@ -0,0 +1,112 @@ +import { describe, it, expect } from 'vitest'; +import { asnGeoContent } from '$lib/content/asn-geo'; + +describe('ASN Geo Content', () => { + it('should have valid structure', () => { + expect(asnGeoContent).toBeDefined(); + expect(asnGeoContent.title).toBe('ASN & Geolocation Lookup'); + expect(asnGeoContent.description).toBeTruthy(); + expect(asnGeoContent.sections).toBeDefined(); + }); + + it('should have all required sections', () => { + const sections = asnGeoContent.sections; + expect(sections.whatIsGeoIP).toBeDefined(); + expect(sections.howItWorks).toBeDefined(); + expect(sections.dataProvided).toBeDefined(); + expect(sections.accuracy).toBeDefined(); + expect(sections.useCases).toBeDefined(); + expect(sections.limitations).toBeDefined(); + expect(sections.asnExplained).toBeDefined(); + expect(sections.bestPractices).toBeDefined(); + expect(sections.dataSource).toBeDefined(); + }); + + it('should have data provided categories', () => { + const categories = asnGeoContent.sections.dataProvided.categories; + expect(categories).toHaveLength(3); + expect(categories[0].category).toBe('Network Information'); + expect(categories[1].category).toBe('Geographic Location'); + expect(categories[2].category).toBe('Connection Type'); + categories.forEach((cat) => { + expect(cat.fields).toBeDefined(); + expect(cat.fields.length).toBeGreaterThan(0); + }); + }); + + it('should have accuracy levels', () => { + const levels = asnGeoContent.sections.accuracy.levels; + expect(levels).toHaveLength(4); + expect(levels[0].level).toBe('Country'); + expect(levels[1].level).toBe('Region/State'); + expect(levels[2].level).toBe('City'); + expect(levels[3].level).toBe('Coordinates'); + levels.forEach((level) => { + expect(level.accuracy).toBeTruthy(); + expect(level.description).toBeTruthy(); + }); + }); + + it('should have use cases', () => { + const cases = asnGeoContent.sections.useCases.cases; + expect(cases.length).toBeGreaterThan(0); + cases.forEach((useCase) => { + expect(useCase.scenario).toBeTruthy(); + expect(useCase.use).toBeTruthy(); + expect(useCase.action).toBeTruthy(); + }); + }); + + it('should have limitations', () => { + const limitations = asnGeoContent.sections.limitations.points; + expect(limitations.length).toBeGreaterThan(0); + limitations.forEach((limit) => { + expect(limit.limitation).toBeTruthy(); + expect(limit.description).toBeTruthy(); + }); + }); + + it('should have ASN explained aspects', () => { + const aspects = asnGeoContent.sections.asnExplained.aspects; + expect(aspects).toHaveLength(4); + aspects.forEach((aspect) => { + expect(aspect.aspect).toBeTruthy(); + expect(aspect.description).toBeTruthy(); + expect(aspect.example).toBeTruthy(); + }); + }); + + it('should have best practices', () => { + const practices = asnGeoContent.sections.bestPractices.practices; + expect(practices.length).toBeGreaterThan(0); + practices.forEach((practice) => { + expect(practice.practice).toBeTruthy(); + expect(practice.description).toBeTruthy(); + expect(practice.reason).toBeTruthy(); + }); + }); + + it('should have data source features', () => { + const features = asnGeoContent.sections.dataSource.features; + expect(features.length).toBeGreaterThan(0); + features.forEach((feature) => { + expect(feature).toBeTruthy(); + }); + }); + + it('should have quick tips', () => { + const tips = asnGeoContent.quickTips; + expect(tips.length).toBeGreaterThan(0); + tips.forEach((tip) => { + expect(tip).toBeTruthy(); + }); + }); + + it('should have how it works steps', () => { + const steps = asnGeoContent.sections.howItWorks.steps; + expect(steps).toHaveLength(5); + steps.forEach((step) => { + expect(step).toBeTruthy(); + }); + }); +}); diff --git a/tests/unit/routes/api/internal/diagnostics/asn-geo/server.test.ts b/tests/unit/routes/api/internal/diagnostics/asn-geo/server.test.ts new file mode 100644 index 0000000..918c5d0 --- /dev/null +++ b/tests/unit/routes/api/internal/diagnostics/asn-geo/server.test.ts @@ -0,0 +1,67 @@ +import { describe, it, expect } from 'vitest'; +import { POST } from '../../../../../../../src/routes/api/internal/diagnostics/asn-geo/+server'; + +describe('ASN Geo API Endpoint', () => { + it('should reject requests without ip', async () => { + const request = new Request('http://localhost', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({}), + }); + + await expect(POST({ request } as any)).rejects.toThrow(); + }); + + it('should reject requests with empty ip', async () => { + const request = new Request('http://localhost', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ ip: '' }), + }); + + await expect(POST({ request } as any)).rejects.toThrow(); + }); + + it('should reject invalid IP format', async () => { + const request = new Request('http://localhost', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ ip: 'invalid-ip' }), + }); + + await expect(POST({ request } as any)).rejects.toThrow(); + }); + + it('should accept valid IPv4 format', async () => { + const request = new Request('http://localhost', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ ip: '1.2.3.4' }), + }); + + // Note: This will attempt to call the external API, which may be blocked in tests + // We're just validating the request format is accepted, not the full response + try { + await POST({ request } as any); + } catch (err: any) { + // External API call may fail in test environment, that's ok + // We just want to ensure it didn't reject the request format + expect(err.status).not.toBe(400); + } + }); + + it('should accept valid IPv6 format', async () => { + const request = new Request('http://localhost', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ ip: '2001:db8::1' }), + }); + + try { + await POST({ request } as any); + } catch (err: any) { + // External API call may fail in test environment, that's ok + expect(err.status).not.toBe(400); + } + }); +}); diff --git a/tests/unit/routes/api/internal/diagnostics/bgp/server.test.ts b/tests/unit/routes/api/internal/diagnostics/bgp/server.test.ts new file mode 100644 index 0000000..5d572c2 --- /dev/null +++ b/tests/unit/routes/api/internal/diagnostics/bgp/server.test.ts @@ -0,0 +1,54 @@ +import { describe, it, expect } from 'vitest'; +import { POST } from '../../../../../../../src/routes/api/internal/diagnostics/bgp/+server'; + +describe('BGP API Endpoint', () => { + it('should reject requests without resource', async () => { + const request = new Request('http://localhost', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({}), + }); + + await expect(POST({ request } as any)).rejects.toThrow(); + }); + + it('should reject requests with empty resource', async () => { + const request = new Request('http://localhost', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ resource: '' }), + }); + + await expect(POST({ request } as any)).rejects.toThrow(); + }); + + it('should accept valid IP address', async () => { + const request = new Request('http://localhost', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ resource: '8.8.8.8' }), + }); + + // This will make an actual API call to RIPE RIS + const response = await POST({ request } as any); + const data = await response.json(); + + expect(data).toHaveProperty('resource'); + expect(data).toHaveProperty('timestamp'); + expect(data.resource).toBe('8.8.8.8'); + }); + + it('should accept valid CIDR prefix', async () => { + const request = new Request('http://localhost', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ resource: '8.8.8.0/24' }), + }); + + const response = await POST({ request } as any); + const data = await response.json(); + + expect(data).toHaveProperty('resource'); + expect(data).toHaveProperty('announced'); + }); +});