diff --git a/cproxy.c b/cproxy.c index e6f1fd1c..c0dbe2db 100644 --- a/cproxy.c +++ b/cproxy.c @@ -1968,6 +1968,13 @@ void upstream_error_msg(conn *uc, char *ascii_msg, binary_status = PROTOCOL_BINARY_RESPONSE_EINTERNAL; } + pthread_mutex_lock(&ptd->proxy->proxy_lock); + if (ptd->proxy->name != NULL && + strcmp(ptd->proxy->name, NULL_BUCKET) == 0) { + binary_status = PROTOCOL_BINARY_RESPONSE_AUTH_ERROR; + } + pthread_mutex_unlock(&ptd->proxy->proxy_lock); + write_bin_error(uc, binary_status, 0); update_event(uc, EV_WRITE | EV_PERSIST); diff --git a/t/moxi_multitenancy.py b/t/moxi_multitenancy.py index 1be23e81..3e8097f3 100644 --- a/t/moxi_multitenancy.py +++ b/t/moxi_multitenancy.py @@ -61,17 +61,17 @@ def testNullBucket(self): """Test null bucket""" self.client_connect() - get_oom = self.packRes(memcacheConstants.CMD_GETK, - status=memcacheConstants.ERR_ENOMEM, - val="Out of memory") + get_err = self.packRes(memcacheConstants.CMD_GETK, + status=memcacheConstants.ERR_AUTH_ERROR, + val="Auth failure") get_req = self.packReq(memcacheConstants.CMD_GETK, key='keyNotThere0') self.client_send(get_req) - self.client_recv(get_oom) + self.client_recv(get_err) get_req = self.packReq(memcacheConstants.CMD_GETK, key='keyNotThere0') self.client_send(get_req) - self.client_recv(get_oom) + self.client_recv(get_err) self.assertTrue(self.mock_quiet()) @@ -82,15 +82,15 @@ def testNullBucketSet(self): set_req = self.packReq(memcacheConstants.CMD_SET, key='simpleSet', extraHeader=struct.pack(memcacheConstants.SET_PKT_FMT, 0, 0), val='123') - set_oom = self.packRes(memcacheConstants.CMD_SET, - status=memcacheConstants.ERR_ENOMEM, - val="Out of memory") + set_err = self.packRes(memcacheConstants.CMD_SET, + status=memcacheConstants.ERR_AUTH_ERROR, + val="Auth failure") self.client_send(set_req) - self.client_recv(set_oom) + self.client_recv(set_err) self.client_send(set_req) - self.client_recv(set_oom) + self.client_recv(set_err) self.assertTrue(self.mock_quiet())