Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/routes/routeBackbeat.js
Original file line number Diff line number Diff line change
Expand Up @@ -1316,7 +1316,8 @@ function batchDelete(request, response, userInfo, log, callback) {
}

return async.waterfall([
next => metadata.getBucket(bucket, log, next),
// eslint-disable-next-line no-unused-vars
next => metadata.getBucket(bucket, log, (err, bucketMD, raftSessionId) => next(err, bucketMD)),
(bucketMD, next) => quotaUtils.validateQuotas(request, bucketMD, request.accountQuotas,
['objectDelete'], 'objectDelete', -contentLength, false, log, next),
], err => {
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/api/multiObjectDelete.js
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ describe('multiObjectDelete function', () => {
'accountA',
new Date().toISOString(),
15,
)));
), undefined));

multiObjectDelete.multiObjectDelete(authInfo, request, log, (err, res) => {
// Expected result is an access denied on the object, and no error, as the API was authorized
Expand Down Expand Up @@ -443,7 +443,7 @@ describe('multiObjectDelete function', () => {
'accountA',
new Date().toISOString(),
15,
)));
), undefined));

multiObjectDelete.multiObjectDelete(authInfo, request, log, (err, res) => {
// Expected result is an access denied on the object, and no error, as the API was authorized
Expand Down
35 changes: 34 additions & 1 deletion tests/unit/routes/routeBackbeat.js
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ describe('routeBackbeat', () => {
getName: () => 'bucket0',
getQuota: () => 0n,
};
sandbox.stub(metadata, 'getBucket').callsFake((bucket, log, cb) => cb(null, bucketMD));
sandbox.stub(metadata, 'getBucket').callsFake((bucket, log, cb) => cb(null, bucketMD, undefined));

routeBackbeat('127.0.0.1', mockRequest, mockResponse, log);
await endPromise;
Expand Down Expand Up @@ -791,6 +791,39 @@ describe('routeBackbeat', () => {
assert.strictEqual(mockResponse.statusCode, 200);
assert.deepStrictEqual(mockResponse.body, null);
});

it('should handle raftSessionId parameter from metadata.getBucket', async () => {
sandbox.stub(config, 'isQuotaEnabled').returns(true);
const testRaftSessionId = 12345;
const bucketMD = {
getName: () => 'bucket0',
getQuota: () => 0n,
};

const getBucketStub = sandbox.stub(metadata, 'getBucket')
.callsFake((bucket, log, cb) => cb(null, bucketMD, testRaftSessionId));

routeBackbeat('127.0.0.1', mockRequest, mockResponse, log);
void await endPromise;

sinon.assert.calledOnce(getBucketStub);

sinon.assert.calledOnce(validateQuotasSpy);
sinon.assert.calledWith(validateQuotasSpy,
mockRequest,
bucketMD,
mockRequest.accountQuotas,
['objectDelete'],
'objectDelete',
-100,
false,
log,
sinon.match.any,
);

assert.strictEqual(mockResponse.statusCode, 200);
assert.deepStrictEqual(mockResponse.body, null);
});
});

describe('routeBackbeatAPIProxy', () => {
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/routes/veeam-routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe('Veeam routes - comprehensive unit tests', () => {
utilizationStub = sinon.stub(UtilizationService, 'getUtilizationMetrics');
metadataStub = sinon.stub(metadata, 'getBucket');
// By default, metadata.getBucket succeeds
metadataStub.callsArgWith(2, null, bucketMd);
metadataStub.callsArgWith(2, null, bucketMd, undefined);
});

afterEach(() => {
Expand Down Expand Up @@ -301,7 +301,7 @@ describe('Veeam routes - HEAD request UtilizationService error handling', () =>
log.debug = sinon.stub();

metadataStub = sinon.stub(metadata, 'getBucket');
metadataStub.callsArgWith(2, null, bucketMd);
metadataStub.callsArgWith(2, null, bucketMd, undefined);
});

afterEach(() => {
Expand Down Expand Up @@ -438,7 +438,7 @@ describe('Veeam routes - LIST request handling', () => {
log.trace = sinon.stub();

metadataStub = sinon.stub(metadata, 'getBucket');
metadataStub.callsArgWith(2, null, bucketMd);
metadataStub.callsArgWith(2, null, bucketMd, undefined);
});

afterEach(() => {
Expand Down
Loading