🚧 Update certificate management
This commit is contained in:
@@ -116,7 +116,22 @@ def client(db_session, monkeypatch):
|
||||
def set_client_password(self, username, password):
|
||||
pass
|
||||
|
||||
def set_client_id(self, username, clientid=None):
|
||||
# Mirrors the real broker's setClientId: empty string unbinds.
|
||||
client = self.clients.get(username)
|
||||
if client is None:
|
||||
from app.dynsec import DynsecError
|
||||
|
||||
raise DynsecError(f"Client not found: {username}")
|
||||
client["clientid"] = clientid or ""
|
||||
|
||||
def get_client(self, username):
|
||||
# Mirrors the real broker: getClient on a missing client
|
||||
# returns a dynsec error, which the router maps to 404.
|
||||
if username not in self.clients:
|
||||
from app.dynsec import DynsecError
|
||||
|
||||
raise DynsecError(f"Client not found: {username}")
|
||||
return self.clients[username]
|
||||
|
||||
def create_group(self, groupname, roles=None):
|
||||
@@ -204,6 +219,11 @@ def client(db_session, monkeypatch):
|
||||
|
||||
monkeypatch.setattr(mqtt_router, "dynsec_client", fake)
|
||||
|
||||
from app.routers import pki as pki_router
|
||||
|
||||
# The PKI client-cert endpoint validates the dynsec client exists.
|
||||
monkeypatch.setattr(pki_router, "dynsec_client", fake)
|
||||
|
||||
with TestClient(main_module.app) as test_client:
|
||||
yield test_client
|
||||
|
||||
|
||||
Reference in New Issue
Block a user