fix: send the full webhook and skip /users/me in the point alarm register client
The backend requires a webhook with a delivery policy on every point alarm register call and resolves the account from the caller, so the register client no longer calls /v1/users/me (account is null for some users), no longer sends the accountId-only webhook and no longer relies on IKLIM_WEBHOOK_INITIALIZED.
This commit is contained in:
@@ -176,9 +176,6 @@ class FakeRegisterService:
|
||||
self.payloads: list[dict] = []
|
||||
self.recipient_hits: list = []
|
||||
|
||||
def get_account_id(self):
|
||||
return "acc"
|
||||
|
||||
def register(self, payload, key):
|
||||
self.payloads.append(payload)
|
||||
result = self.results.pop(0)
|
||||
@@ -199,7 +196,11 @@ class RegisterTest(unittest.TestCase):
|
||||
self.filter = self.dir / "filter.json"
|
||||
self.filter.write_text(json.dumps({"lightning": {"type": "PULSE_IN_CLOUD"}}), encoding="utf-8")
|
||||
self.webhook = self.dir / "webhook.json"
|
||||
self.webhook.write_text("{}", encoding="utf-8")
|
||||
self.webhook.write_text(json.dumps({
|
||||
"url": "https://example.com/hook", "httpMethod": "POST", "contentType": "application/json",
|
||||
"authentication": {"selected": "JWT_TOKEN", "options": {"JWT_TOKEN": {"jwtToken": "t"}}},
|
||||
"deliveryPolicy": {"maxAttempts": 3},
|
||||
}), encoding="utf-8")
|
||||
self.csv = self.dir / "r.csv"
|
||||
|
||||
def run_processor(self, rows: str | None, service) -> list[dict]:
|
||||
@@ -208,8 +209,7 @@ class RegisterTest(unittest.TestCase):
|
||||
processor = PointRegistrationProcessor(
|
||||
service, csv_path=self.csv, webhook_config_path=self.webhook, filter_config_path=self.filter
|
||||
)
|
||||
with patch.dict(os.environ, {"IKLIM_WEBHOOK_INITIALIZED": "true"}):
|
||||
processor.run()
|
||||
processor.run()
|
||||
with self.csv.open(encoding="utf-8-sig", newline="") as handle:
|
||||
return list(csv.DictReader(handle, delimiter=";"))
|
||||
|
||||
@@ -226,7 +226,8 @@ class RegisterTest(unittest.TestCase):
|
||||
self.assertEqual(rows[0]["registrationId"], REG_ID)
|
||||
self.assertIn("duplicate", rows[1]["errorBody"])
|
||||
self.assertEqual(rows[2]["httpStatus"], "NOT_SENT")
|
||||
self.assertEqual(service.payloads[0]["webhook"], {"accountId": "acc"})
|
||||
self.assertEqual(service.payloads[0]["webhook"]["deliveryPolicy"], {"maxAttempts": 3})
|
||||
self.assertNotIn("accountId", service.payloads[0]["webhook"])
|
||||
self.assertEqual(service.payloads[0]["filter"]["lightning"]["type"], "PULSE_IN_CLOUD")
|
||||
# Re-run: SUCCESS row is skipped, the failed one is retried.
|
||||
service2 = FakeRegisterService(
|
||||
|
||||
Reference in New Issue
Block a user