From fb6fdcba197bb9976c44a5a5fe9972b4ba21e829 Mon Sep 17 00:00:00 2001 From: ambiguouStr <59325440+ambiguoustexture@users.noreply.github.com> Date: Tue, 29 Aug 2023 05:21:59 +0000 Subject: [PATCH] Add redisAuth --- src/redisAuth.m | 20 ++++++++++++++++++++ test/test.m | 3 +++ 2 files changed, 23 insertions(+) create mode 100644 src/redisAuth.m diff --git a/src/redisAuth.m b/src/redisAuth.m new file mode 100644 index 0000000..5768f7e --- /dev/null +++ b/src/redisAuth.m @@ -0,0 +1,20 @@ +function [R, S] = redisSet(R, pwd) + +S = 'OK'; + +if ~isstr(pwd) + S = 'ERROR - AUTH PWD MUST BE A STRING'; + return +end + +if ~strcmp(R.status, 'open') + S = 'ERROR - NO CONNECTION'; + return +end + +[Response, R, S] = redisCommand(R, redisCommandString(sprintf('AUTH %s', pwd))); + +if strcmp(Response, '+OK') + S = Response; + return +end \ No newline at end of file diff --git a/test/test.m b/test/test.m index 2d2f092..88a0c43 100644 --- a/test/test.m +++ b/test/test.m @@ -7,6 +7,9 @@ function test() [R, M] = redisConnection(); assert_string(M, 'OK'); +% [R, M] = redisAuth(R, ''); +% assert_string(M, 'OK'); + [Value, R, M] = redisPing(R); assert_string(Value, 'PONG');