浏览代码

HPCC-13192 Add a more sensible authorization message for older versions or redis

Signed-off-by: James Noss <james.noss@lexisnexis.com>
James Noss 10 年之前
父节点
当前提交
989125a13e
共有 3 个文件被更改,包括 5 次插入3 次删除
  1. 1 1
      plugins/redis/redis.cpp
  2. 1 1
      testing/regress/ecl/key/redissynctest.xml
  3. 3 1
      testing/regress/ecl/redissynctest.ecl

+ 1 - 1
plugins/redis/redis.cpp

@@ -402,7 +402,7 @@ void Connection::assertOnCommandError(const redisReply * reply, const char * cmd
 }
 void Connection::assertAuthorization(const redisReply * reply)
 {
-    if (strncmp(reply->str, "NOAUTH", 6) == 0)
+    if (reply && reply->str && ( strncmp(reply->str, "NOAUTH", 6) == 0 || strncmp(reply->str, "ERR operation not permitted", 30) == 0 ))
     {
         VStringBuffer msg("Redis Plugin: server authentication failed - %s", reply->str);
         rtlFail(0, msg.str());

+ 1 - 1
testing/regress/ecl/key/redissynctest.xml

@@ -89,7 +89,7 @@
  <Row><Result_30>300</Result_30></Row>
 </Dataset>
 <Dataset name='Result 31'>
- <Row><value>Redis Plugin: server authentication failed - NOAUTH Authentication required.</value></Row>
+ <Row><value>Auth Failed</value></Row>
 </Dataset>
 <Dataset name='Result 32'>
  <Row><value>Redis Plugin: ERROR - the requested key &apos;authTest1&apos; does not exist on database 0</value></Row>

+ 3 - 1
testing/regress/ecl/redissynctest.ecl

@@ -157,10 +157,12 @@ SEQUENTIAL(
 
 //Test some authentication exceptions
 myRedis4 := RedisServer(server);
+STRING noauth := 'Redis Plugin: server authentication failed - NOAUTH Authentication required.';
+STRING opNotPerm :=  'Redis Plugin: server authentication failed - ERR operation not permitted';
 ds1 := DATASET(NOFOLD(1), TRANSFORM({string value}, SELF.value := myRedis4.GetString('authTest' + (string)COUNTER)));
 SEQUENTIAL(
     myRedis.FlushDB();
-    OUTPUT(CATCH(ds1, ONFAIL(TRANSFORM({ STRING value }, SELF.value := FAILMESSAGE))));
+    OUTPUT(CATCH(ds1, ONFAIL(TRANSFORM({ STRING value }, SELF.value := IF(FAILMESSAGE = noauth OR FAILMESSAGE = opNotPerm, 'Auth Failed', 'Unexpected Error')))));
     );
 
 ds2 := DATASET(NOFOLD(1), TRANSFORM({string value}, SELF.value := myRedis.GetString('authTest' + (string)COUNTER)));