Skip to content

Commit fad266d

Browse files
committed
CLDSRV-776: update metadata.getBucket stubs for raftSessionId parameter
Update test stubs of metadata.getBucket() to include the third raftSessionId parameter introduced in Arsenal ARSN-533.
1 parent 3f56453 commit fad266d

File tree

3 files changed

+39
-6
lines changed

3 files changed

+39
-6
lines changed

tests/unit/api/multiObjectDelete.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ describe('multiObjectDelete function', () => {
400400
'accountA',
401401
new Date().toISOString(),
402402
15,
403-
)));
403+
), undefined));
404404

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

448448
multiObjectDelete.multiObjectDelete(authInfo, request, log, (err, res) => {
449449
// Expected result is an access denied on the object, and no error, as the API was authorized

tests/unit/routes/routeBackbeat.js

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ describe('routeBackbeat', () => {
671671
getName: () => 'bucket0',
672672
getQuota: () => 0n,
673673
};
674-
sandbox.stub(metadata, 'getBucket').callsFake((bucket, log, cb) => cb(null, bucketMD));
674+
sandbox.stub(metadata, 'getBucket').callsFake((bucket, log, cb) => cb(null, bucketMD, undefined));
675675

676676
routeBackbeat('127.0.0.1', mockRequest, mockResponse, log);
677677
await endPromise;
@@ -791,6 +791,39 @@ describe('routeBackbeat', () => {
791791
assert.strictEqual(mockResponse.statusCode, 200);
792792
assert.deepStrictEqual(mockResponse.body, null);
793793
});
794+
795+
it('should handle raftSessionId parameter from metadata.getBucket', async () => {
796+
sandbox.stub(config, 'isQuotaEnabled').returns(true);
797+
const testRaftSessionId = 12345;
798+
const bucketMD = {
799+
getName: () => 'bucket0',
800+
getQuota: () => 0n,
801+
};
802+
803+
const getBucketStub = sandbox.stub(metadata, 'getBucket')
804+
.callsFake((bucket, log, cb) => cb(null, bucketMD, testRaftSessionId));
805+
806+
routeBackbeat('127.0.0.1', mockRequest, mockResponse, log);
807+
void await endPromise;
808+
809+
sinon.assert.calledOnce(getBucketStub);
810+
811+
sinon.assert.calledOnce(validateQuotasSpy);
812+
sinon.assert.calledWith(validateQuotasSpy,
813+
mockRequest,
814+
bucketMD,
815+
mockRequest.accountQuotas,
816+
['objectDelete'],
817+
'objectDelete',
818+
-100,
819+
false,
820+
log,
821+
sinon.match.any,
822+
);
823+
824+
assert.strictEqual(mockResponse.statusCode, 200);
825+
assert.deepStrictEqual(mockResponse.body, null);
826+
});
794827
});
795828

796829
describe('routeBackbeatAPIProxy', () => {

tests/unit/routes/veeam-routes.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ describe('Veeam routes - comprehensive unit tests', () => {
4848
utilizationStub = sinon.stub(UtilizationService, 'getUtilizationMetrics');
4949
metadataStub = sinon.stub(metadata, 'getBucket');
5050
// By default, metadata.getBucket succeeds
51-
metadataStub.callsArgWith(2, null, bucketMd);
51+
metadataStub.callsArgWith(2, null, bucketMd, undefined);
5252
});
5353

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

303303
metadataStub = sinon.stub(metadata, 'getBucket');
304-
metadataStub.callsArgWith(2, null, bucketMd);
304+
metadataStub.callsArgWith(2, null, bucketMd, undefined);
305305
});
306306

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

440440
metadataStub = sinon.stub(metadata, 'getBucket');
441-
metadataStub.callsArgWith(2, null, bucketMd);
441+
metadataStub.callsArgWith(2, null, bucketMd, undefined);
442442
});
443443

444444
afterEach(() => {

0 commit comments

Comments
 (0)