|  |  | @ -4,8 +4,8 @@ from Crypto.PublicKey import RSA | 
			
		
	
		
		
			
				
					
					|  |  |  | from pathlib import Path |  |  |  | from pathlib import Path | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | from openpilot.common.params import Params |  |  |  | from openpilot.common.params import Params | 
			
		
	
		
		
			
				
					
					|  |  |  | from openpilot.selfdrive.athena.registration import register, UNREGISTERED_DONGLE_ID |  |  |  | from openpilot.system.athena.registration import register, UNREGISTERED_DONGLE_ID | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | from openpilot.selfdrive.athena.tests.helpers import MockResponse |  |  |  | from openpilot.system.athena.tests.helpers import MockResponse | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | from openpilot.system.hardware.hw import Paths |  |  |  | from openpilot.system.hardware.hw import Paths | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -36,7 +36,7 @@ class TestRegistration: | 
			
		
	
		
		
			
				
					
					|  |  |  |     self.params.put("HardwareSerial", "serial") |  |  |  |     self.params.put("HardwareSerial", "serial") | 
			
		
	
		
		
			
				
					
					|  |  |  |     self._generate_keys() |  |  |  |     self._generate_keys() | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     m = mocker.patch("openpilot.selfdrive.athena.registration.api_get", autospec=True) |  |  |  |     m = mocker.patch("openpilot.system.athena.registration.api_get", autospec=True) | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |     dongle = "DONGLE_ID_123" |  |  |  |     dongle = "DONGLE_ID_123" | 
			
		
	
		
		
			
				
					
					|  |  |  |     self.params.put("DongleId", dongle) |  |  |  |     self.params.put("DongleId", dongle) | 
			
		
	
		
		
			
				
					
					|  |  |  |     assert register() == dongle |  |  |  |     assert register() == dongle | 
			
		
	
	
		
		
			
				
					|  |  | @ -44,7 +44,7 @@ class TestRegistration: | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   def test_no_keys(self, mocker): |  |  |  |   def test_no_keys(self, mocker): | 
			
		
	
		
		
			
				
					
					|  |  |  |     # missing pubkey |  |  |  |     # missing pubkey | 
			
		
	
		
		
			
				
					
					|  |  |  |     m = mocker.patch("openpilot.selfdrive.athena.registration.api_get", autospec=True) |  |  |  |     m = mocker.patch("openpilot.system.athena.registration.api_get", autospec=True) | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |     dongle = register() |  |  |  |     dongle = register() | 
			
		
	
		
		
			
				
					
					|  |  |  |     assert m.call_count == 0 |  |  |  |     assert m.call_count == 0 | 
			
		
	
		
		
			
				
					
					|  |  |  |     assert dongle == UNREGISTERED_DONGLE_ID |  |  |  |     assert dongle == UNREGISTERED_DONGLE_ID | 
			
		
	
	
		
		
			
				
					|  |  | @ -53,7 +53,7 @@ class TestRegistration: | 
			
		
	
		
		
			
				
					
					|  |  |  |   def test_missing_cache(self, mocker): |  |  |  |   def test_missing_cache(self, mocker): | 
			
		
	
		
		
			
				
					
					|  |  |  |     # keys exist but no dongle id |  |  |  |     # keys exist but no dongle id | 
			
		
	
		
		
			
				
					
					|  |  |  |     self._generate_keys() |  |  |  |     self._generate_keys() | 
			
		
	
		
		
			
				
					
					|  |  |  |     m = mocker.patch("openpilot.selfdrive.athena.registration.api_get", autospec=True) |  |  |  |     m = mocker.patch("openpilot.system.athena.registration.api_get", autospec=True) | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |     dongle = "DONGLE_ID_123" |  |  |  |     dongle = "DONGLE_ID_123" | 
			
		
	
		
		
			
				
					
					|  |  |  |     m.return_value = MockResponse(json.dumps({'dongle_id': dongle}), 200) |  |  |  |     m.return_value = MockResponse(json.dumps({'dongle_id': dongle}), 200) | 
			
		
	
		
		
			
				
					
					|  |  |  |     assert register() == dongle |  |  |  |     assert register() == dongle | 
			
		
	
	
		
		
			
				
					|  |  | @ -67,7 +67,7 @@ class TestRegistration: | 
			
		
	
		
		
			
				
					
					|  |  |  |   def test_unregistered(self, mocker): |  |  |  |   def test_unregistered(self, mocker): | 
			
		
	
		
		
			
				
					
					|  |  |  |     # keys exist, but unregistered |  |  |  |     # keys exist, but unregistered | 
			
		
	
		
		
			
				
					
					|  |  |  |     self._generate_keys() |  |  |  |     self._generate_keys() | 
			
		
	
		
		
			
				
					
					|  |  |  |     m = mocker.patch("openpilot.selfdrive.athena.registration.api_get", autospec=True) |  |  |  |     m = mocker.patch("openpilot.system.athena.registration.api_get", autospec=True) | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |     m.return_value = MockResponse(None, 402) |  |  |  |     m.return_value = MockResponse(None, 402) | 
			
		
	
		
		
			
				
					
					|  |  |  |     dongle = register() |  |  |  |     dongle = register() | 
			
		
	
		
		
			
				
					
					|  |  |  |     assert m.call_count == 1 |  |  |  |     assert m.call_count == 1 |