From 38221e1a4041937f437d5f93edfdf2973c1f70b2 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 4 Feb 2023 16:23:31 -0800 Subject: Update integration tests --- tools/test-integration.py | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) (limited to 'tools') diff --git a/tools/test-integration.py b/tools/test-integration.py index 89f1c76ed..9aad642ae 100755 --- a/tools/test-integration.py +++ b/tools/test-integration.py @@ -4,7 +4,7 @@ import sys import os import xml.etree.ElementTree import urllib -import urllib2 +import urllib.request as urllib2 import json import socket import time @@ -18,10 +18,9 @@ messages = { 't55' : '$PGID,123456789012345*0F\r\n$GPRMC,120500.000,A,6000.0000,N,13000.0000,E,0.00,0.00,010112,,*33\r\n', 'xexun' : '111111120009,+436763737552,GPRMC,120600.000,A,6000.0000,N,13000.0000,E,0.00,0.00,010112,,,A*68,F,, imei:123456789012345,04,481.2,F:4.15V,0,139,2689,232,03,2725,0576\n', 'totem' : '$$B3123456789012345|AA$GPRMC,120700.000,A,6000.0000,N,13000.0000,E,0.00,,010112,,,A*74|01.8|01.0|01.5|000000000000|20120403234603|14251914|00000000|0012D888|0000|0.0000|3674|940B\r\n', - 'meiligao' : '$$\x00\x60\x12\x34\x56\xFF\xFF\xFF\xFF\x99\x55120900.000,A,6000.0000,N,13000.0000,E,0.00,,010112,,*1C|11.5|194|0000|0000,0000\x69\x62\x0D\x0A', 'suntech' : 'SA200STT;123456;042;20120101;12:11:00;16d41;-15.618767;-056.083214;000.011;000.00;11;1;41557;12.21;000000;1;3205\r', 'h02' : '*HQ,123456789012345,V1,121300,A,6000.0000,N,13000.0000,E,0.00,0.00,010112,ffffffff,000000,000000,000000,000000#', - 'jt600' : '$\x00\x00\x12\x34\x56\x11\x00\x1B\x01\x01\x12\x12\x14\x00\x60\x00\x00\x00\x13\x00\x00\x00\x0F\x00\x00\x07\x50\x00\x00\x00\x2B\x91\x04\x4D\x1F\xA1', + 'jt600' : '(1234567890,P45,290322,132412,25.28217,S,57.54683,W,A,0,0,5,0,0000000000,0,0,9,0)', 'v680' : '#123456789012345#1000#0#1000#AUT#1#66830FFB#13000.0000,E,6000.0000,N,001.41,259#010112#121600##', 'pt502' : '$POS,123456,121700.000,A,6000.0000,N,13000.0000,E,0.0,0.0,010112,,,A/00000,00000/0/23895000//\r\n', 'tr20' : '%%123456789012345,A,120101121800,N6000.0000E13000.0000,0,000,0,01034802,150,[Message]\r\n', @@ -119,6 +118,9 @@ messages = { 'mobilogix': '[2020-10-25 20:45:09,T9,1,V1.2.3,123456789012,59,10.50,701,-25.236860,-45.708530,0,314]', 'swiftech': '@@123456789012345,,0,102040,1023.9670,N,07606.8160,E,2.26,151220,A,0127,1,1,03962,00000,#', 'ennfu': 'Ennfu:123456789012345,041504.00,A,3154.86654,N,11849.08737,E,0.053,,080121,20,3.72,21.4,V0.01$', + 'startek': '&&o125,123456789012345,000,0,,210702235150,A,27.263505,153.037061,11,1.2,0,0,31,5125,505|1|7032|8C89802,20,0000002D,00,00,01E2|019DF0\r\n', + 'hoopo': '{ "deviceId": "123456789012345", "assetName": "123456789012345", "assetType": "test", "eventData": { "latitude": 31.97498, "longitude": 34.80802, "locationName": "", "accuracyLevel": "High", "eventType": "Arrival", "batteryLevel": 100, "receiveTime": "2021-09-20T18:52:32Z" }, "eventTime": "2021-09-20T08:52:02Z", "serverReportTime": "0001-01-01T00:00:00Z" }', + 'techtocruz': '$$A120,123456789012345,211005105836,A,FLEX,KCB 947C,000.0,0,-1.38047,S,36.93951,E,1648.4,243.140,21,28,12.1,3.7,0,1,0,0,0,*F6', } baseUrl = 'http://localhost:8082' @@ -135,14 +137,14 @@ def load_ports(): if key.endswith('.port'): ports[key[:-5]] = int(entry.text) if debug: - print '\nports: %s\n' % repr(ports) + print('\nports: {ports!r}\n') return ports def login(): request = urllib2.Request(baseUrl + '/api/session') - response = urllib2.urlopen(request, urllib.parse.urlencode(user)) + response = urllib2.urlopen(request, urllib.parse.urlencode(user).encode()) if debug: - print '\nlogin: %s\n' % repr(json.load(response)) + print(f'\nlogin: {json.load(response)!r}\n') return response.headers.get('Set-Cookie') def remove_devices(cookie): @@ -151,7 +153,7 @@ def remove_devices(cookie): response = urllib2.urlopen(request) data = json.load(response) if debug: - print '\ndevices: %s\n' % repr(data) + print(f'\ndevices: {data!r}\n') for device in data: request = urllib2.Request(baseUrl + '/api/devices/' + str(device['id'])) request.add_header('Cookie', cookie) @@ -163,14 +165,14 @@ def add_device(cookie, unique_id): request.add_header('Cookie', cookie) request.add_header('Content-Type', 'application/json') device = { 'name' : unique_id, 'uniqueId' : unique_id } - response = urllib2.urlopen(request, json.dumps(device)) + response = urllib2.urlopen(request, json.dumps(device).encode()) data = json.load(response) return data['id'] def send_message(port, message): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect(('127.0.0.1', port)) - s.send(message) + s.send(message.encode('ascii')) time.sleep(0.5) s.close() @@ -203,9 +205,9 @@ if __name__ == "__main__": all = set(ports.keys()) protocols = set(messages.keys()) - print 'Total: %d' % len(all) - print 'Missing: %d' % len(all - protocols) - print 'Covered: %d' % len(protocols) + print(f'Total: {len(all)}') + print(f'Missing: {len(all - protocols)}') + print(f'Covered: {len(protocols)}') for protocol in messages: send_message(ports[protocol], messages[protocol]) @@ -213,8 +215,8 @@ if __name__ == "__main__": for device in devices: protocols -= set(get_protocols(cookie, devices[device])) - print 'Success: %d' % (len(messages) - len(protocols)) - print 'Failed: %d' % len(protocols) + print(f'Success: {len(messages) - len(protocols)}') + print(f'Failed:{len(protocols)}') if protocols: - print '\nFailed: %s' % repr(list(protocols)) + print(f'\nFailed: {list(protocols)!r}') -- cgit v1.2.3 From 7c67b6f9b46a350ae111eff2caea5981dc0e1bff Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sun, 26 Mar 2023 07:07:46 -0700 Subject: Fix map testing script --- tools/test-map.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tools') diff --git a/tools/test-map.py b/tools/test-map.py index 362c95878..664917eff 100755 --- a/tools/test-map.py +++ b/tools/test-map.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 import urllib -import urllib2 +import urllib.request as urllib2 import http.client as httplib import time import random @@ -14,7 +14,7 @@ devices = 500 def login(): request = urllib2.Request(baseUrl + '/api/session') - response = urllib2.urlopen(request, urllib.parse.urlencode(user)) + response = urllib2.urlopen(request, urllib.parse.urlencode(user).encode()) return response.headers.get('Set-Cookie') def add_device(cookie, unique_id): @@ -23,7 +23,7 @@ def add_device(cookie, unique_id): request.add_header('Content-Type', 'application/json') device = { 'name' : unique_id, 'uniqueId' : unique_id } try: - response = urllib2.urlopen(request, json.dumps(device)) + response = urllib2.urlopen(request, json.dumps(device).encode()) except urllib2.HTTPError: pass -- cgit v1.2.3 From 514605fc0070c7365e525141b6bdd64f5dffadc7 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sun, 16 Apr 2023 10:17:09 -0700 Subject: Add integration tests --- tools/test-integration.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'tools') diff --git a/tools/test-integration.py b/tools/test-integration.py index 9aad642ae..84d2fa2e3 100755 --- a/tools/test-integration.py +++ b/tools/test-integration.py @@ -121,6 +121,11 @@ messages = { 'startek': '&&o125,123456789012345,000,0,,210702235150,A,27.263505,153.037061,11,1.2,0,0,31,5125,505|1|7032|8C89802,20,0000002D,00,00,01E2|019DF0\r\n', 'hoopo': '{ "deviceId": "123456789012345", "assetName": "123456789012345", "assetType": "test", "eventData": { "latitude": 31.97498, "longitude": 34.80802, "locationName": "", "accuracyLevel": "High", "eventType": "Arrival", "batteryLevel": 100, "receiveTime": "2021-09-20T18:52:32Z" }, "eventTime": "2021-09-20T08:52:02Z", "serverReportTime": "0001-01-01T00:00:00Z" }', 'techtocruz': '$$A120,123456789012345,211005105836,A,FLEX,KCB 947C,000.0,0,-1.38047,S,36.93951,E,1648.4,243.140,21,28,12.1,3.7,0,1,0,0,0,*F6', + 'flexapi': '${"topic":"v1/123456789012345/motion/info","payload":{"motion.ts":1641885877,"motion.ax":0.006344,"motion.ay":0.289384,"motion.az":-0.939156,"motion.gx":0.420000,"motion.gy":0.420000,"motion.gz":-0.280000}}xx\r\n', + 'jido': '*123456789012345,03,130517,160435,1820.5845,N,07833.2478,E,1,58#', + 'armoli': '[M123456789012345210122125205N38.735641E035.4727751E003340000000C00000E9E07FF:106AG505283H60E];', + 'teratrack': '{"MDeviceID":"022043756090","DiviceType":"1","DataType":"1","DataLength":"69","DateTime":"2022-03-09 10:56:01","Latitude":"-6.846451","Longitude":"39.316324","LongitudeState":"1","LatitudeState":"0","Speed":"90","Mileage":"0","FenceAlarm":"0","AreaAlarmID":"0","LockCutOff":"0","SealTampered":"0","MessageAck":"1","LockRope":"1","LockStatus":"1","LockOpen":"0","PasswordError":"0","CardNo":"60000644","IllegalCard":"0","LowPower":"0","UnCoverBack":"0","CoverStatus":"1","LockStuck":"0","Power":"79","GSM":"16","IMEI":"123456789012345","Index":"20","Slave":[]}', + 'envotech': '$80SLM,02,F,123456,130410155921,431750216,000040,0000,,00000000,\'13041015592110476673N10111459E001281*2A#', } baseUrl = 'http://localhost:8082' -- cgit v1.2.3 From ab801e856521356ff7a33250e1abdb8857ef84b3 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 19 Apr 2023 06:29:50 -0700 Subject: Fix group commands --- src/main/java/org/traccar/api/resource/CommandResource.java | 6 ++++-- tools/test-commands.py | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'tools') diff --git a/src/main/java/org/traccar/api/resource/CommandResource.java b/src/main/java/org/traccar/api/resource/CommandResource.java index 7ba1ee2b4..b69d4d9ac 100644 --- a/src/main/java/org/traccar/api/resource/CommandResource.java +++ b/src/main/java/org/traccar/api/resource/CommandResource.java @@ -28,6 +28,7 @@ import org.traccar.model.Command; import org.traccar.model.Device; import org.traccar.model.Group; import org.traccar.model.Position; +import org.traccar.model.QueuedCommand; import org.traccar.model.Typed; import org.traccar.model.User; import org.traccar.model.UserRestrictions; @@ -121,8 +122,9 @@ public class CommandResource extends ExtendedObjectResource { permissionsService.checkPermission(Group.class, getUserId(), groupId); var devices = DeviceUtil.getAccessibleDevices(storage, getUserId(), List.of(), List.of(groupId)); for (Device device : devices) { - entity.setDeviceId(device.getId()); - result = result && commandsManager.sendCommand(entity); + Command command = QueuedCommand.fromCommand(entity).toCommand(); + command.setDeviceId(device.getId()); + result = result && commandsManager.sendCommand(command); } } else { permissionsService.checkPermission(Device.class, getUserId(), entity.getDeviceId()); diff --git a/tools/test-commands.py b/tools/test-commands.py index 6e310051a..7efd963b4 100755 --- a/tools/test-commands.py +++ b/tools/test-commands.py @@ -6,9 +6,9 @@ import binascii s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect(("localhost", 5001)) #s.send(binascii.unhexlify('68680f0504035889905831401700df1a00000d0a')) -s.send("imei:123456789012345,tracker,151030080103,,F,000101.000,A,5443.3834,N,02512.9071,E,0.00,0;") +s.send(b"imei:123456789012345,tracker,151030080103,,F,000101.000,A,5443.3834,N,02512.9071,E,0.00,0;") while True: - print s.recv(1024) + print(s.recv(1024)) s.close() -- cgit v1.2.3 From 41d7a5ad4c32d3911d6096802f0339ebe4bc0f39 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Tue, 30 May 2023 14:01:25 -0700 Subject: Add integration test --- tools/test-integration.py | 1 + 1 file changed, 1 insertion(+) (limited to 'tools') diff --git a/tools/test-integration.py b/tools/test-integration.py index 84d2fa2e3..204fecb70 100755 --- a/tools/test-integration.py +++ b/tools/test-integration.py @@ -126,6 +126,7 @@ messages = { 'armoli': '[M123456789012345210122125205N38.735641E035.4727751E003340000000C00000E9E07FF:106AG505283H60E];', 'teratrack': '{"MDeviceID":"022043756090","DiviceType":"1","DataType":"1","DataLength":"69","DateTime":"2022-03-09 10:56:01","Latitude":"-6.846451","Longitude":"39.316324","LongitudeState":"1","LatitudeState":"0","Speed":"90","Mileage":"0","FenceAlarm":"0","AreaAlarmID":"0","LockCutOff":"0","SealTampered":"0","MessageAck":"1","LockRope":"1","LockStatus":"1","LockOpen":"0","PasswordError":"0","CardNo":"60000644","IllegalCard":"0","LowPower":"0","UnCoverBack":"0","CoverStatus":"1","LockStuck":"0","Power":"79","GSM":"16","IMEI":"123456789012345","Index":"20","Slave":[]}', 'envotech': '$80SLM,02,F,123456,130410155921,431750216,000040,0000,,00000000,\'13041015592110476673N10111459E001281*2A#', + 'bstpl': 'BSTPL$1,123456789012345,V,200722,045113,00.000000,0,00.00000,0,0,0,000,00,0,17,1,1,0,0,00.01,0,04.19,15B_190821,8991000907387031196F,12.27#', } baseUrl = 'http://localhost:8082' -- cgit v1.2.3 From 44236d51aa70c2e07356f4d430aee8ddc04e74dd Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 26 Aug 2023 15:55:52 -0700 Subject: Update app icons --- src/main/java/org/traccar/web/OverrideFilter.java | 2 +- tools/test-generator.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'tools') diff --git a/src/main/java/org/traccar/web/OverrideFilter.java b/src/main/java/org/traccar/web/OverrideFilter.java index f870c4147..917fb74cc 100644 --- a/src/main/java/org/traccar/web/OverrideFilter.java +++ b/src/main/java/org/traccar/web/OverrideFilter.java @@ -57,7 +57,7 @@ public class OverrideFilter implements Filter { byte[] bytes = wrappedResponse.getCapture(); if (bytes != null) { if (wrappedResponse.getContentType() != null && wrappedResponse.getContentType().contains("text/html") - || ((HttpServletRequest) request).getPathInfo().endsWith("manifest.json")) { + || ((HttpServletRequest) request).getPathInfo().endsWith("manifest.webmanifest")) { Server server; try { diff --git a/tools/test-generator.py b/tools/test-generator.py index ed135b4aa..20cecccf1 100755 --- a/tools/test-generator.py +++ b/tools/test-generator.py @@ -8,7 +8,7 @@ import time import random id = '123456789012345' -server = 'localhost:5055' +server = '49.13.29.182:5055' period = 1 step = 0.001 device_speed = 40 -- cgit v1.2.3 From 415f67418c510aa98a78883a1957a138c7313880 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 2 Sep 2023 08:14:53 -0700 Subject: Fix tests --- tools/test-generator.py | 2 +- tools/test-integration.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'tools') diff --git a/tools/test-generator.py b/tools/test-generator.py index 20cecccf1..ed135b4aa 100755 --- a/tools/test-generator.py +++ b/tools/test-generator.py @@ -8,7 +8,7 @@ import time import random id = '123456789012345' -server = '49.13.29.182:5055' +server = 'localhost:5055' period = 1 step = 0.001 device_speed = 40 diff --git a/tools/test-integration.py b/tools/test-integration.py index 204fecb70..f31ad7a82 100755 --- a/tools/test-integration.py +++ b/tools/test-integration.py @@ -179,7 +179,7 @@ def send_message(port, message): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect(('127.0.0.1', port)) s.send(message.encode('ascii')) - time.sleep(0.5) + time.sleep(1.0) s.close() def get_protocols(cookie, device_id): -- cgit v1.2.3