make kestrel a tak server, so that it can send and receive pois as cots data
Some checks failed
ci/woodpecker/pr/pr Pipeline failed
Some checks failed
ci/woodpecker/pr/pr Pipeline failed
This commit is contained in:
@@ -40,6 +40,13 @@ describe('deviceUtils', () => {
|
||||
expect(rowToDevice({ id: 'd1', name: 'x', device_type: 'feed', lat: Number.NaN, lng: 0, stream_url: '', source_type: 'mjpeg' })).toBe(null)
|
||||
})
|
||||
|
||||
it('coerces string lat/lng to numbers', () => {
|
||||
const row = { id: 'd1', name: 'x', device_type: 'feed', lat: '37.5', lng: '-122.0', stream_url: '', source_type: 'mjpeg', config: null }
|
||||
const out = rowToDevice(row)
|
||||
expect(out?.lat).toBe(37.5)
|
||||
expect(out?.lng).toBe(-122)
|
||||
})
|
||||
|
||||
it('coerces non-string vendor, stream_url, config to null or empty', () => {
|
||||
const row = {
|
||||
id: 'd1',
|
||||
@@ -92,6 +99,21 @@ describe('deviceUtils', () => {
|
||||
}
|
||||
expect(sanitizeDeviceForResponse(device).streamUrl).toBe('')
|
||||
})
|
||||
|
||||
it('sanitizes stream_url to empty when not http(s)', () => {
|
||||
const device = {
|
||||
id: 'd1',
|
||||
name: 'x',
|
||||
device_type: 'feed',
|
||||
vendor: null,
|
||||
lat: 0,
|
||||
lng: 0,
|
||||
stream_url: 'ftp://example.com',
|
||||
source_type: 'mjpeg',
|
||||
config: null,
|
||||
}
|
||||
expect(sanitizeDeviceForResponse(device).streamUrl).toBe('')
|
||||
})
|
||||
})
|
||||
|
||||
describe('validateDeviceBody', () => {
|
||||
|
||||
Reference in New Issue
Block a user