From 18280ccd8a4b521bd6a2e8c300a9a514a7f820a5 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Sun, 21 Feb 2016 15:05:11 -0500 Subject: [PATCH] Fix bad location of auth check Auth check was erroneously in a place without ability to check the authenticated state. Move the check up the stack. --- confluent_client/confluent/client.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/confluent_client/confluent/client.py b/confluent_client/confluent/client.py index a69560f3..bbe584be 100644 --- a/confluent_client/confluent/client.py +++ b/confluent_client/confluent/client.py @@ -123,15 +123,23 @@ class Command(object): def read(self, path, parameters=None): + if not self.authenticated: + raise Exception('Unauthenticated') return send_request('retrieve', path, self.connection, parameters) def update(self, path, parameters=None): + if not self.authenticated: + raise Exception('Unauthenticated') return send_request('update', path, self.connection, parameters) def create(self, path, parameters=None): + if not self.authenticated: + raise Exception('Unauthenticated') return send_request('create', path, self.connection, parameters) def delete(self, path, parameters=None): + if not self.authenticated: + raise Exception('Unauthenticated') return send_request('delete', path, self.connection, parameters) def _connect_unix(self): @@ -208,8 +216,6 @@ def send_request(operation, path, server, parameters=None): :param server: The socket to send data over :param parameters: Parameters if any to send along with the request """ - if not self.authenticated: - raise Exception('Unauthenticated') payload = {'operation': operation, 'path': path} if parameters is not None: payload['parameters'] = parameters