Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure needQuota flag is passed in stringified request context #2274

Merged
merged 2 commits into from
Dec 7, 2024
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
5 changes: 4 additions & 1 deletion lib/policyEvaluator/RequestContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ export default class RequestContext {
existingObjTag?: string,
needTagEval?: false,
objectLockRetentionDays?: number,
needQuota?: boolean,
) {
this._headers = headers;
this._query = query;
Expand Down Expand Up @@ -256,7 +257,7 @@ export default class RequestContext {
this._securityToken = securityToken;
this._policyArn = policyArn;
this._action = action;
this._needQuota = actionNeedQuotaCheck[apiMethod] === true
this._needQuota = needQuota || actionNeedQuotaCheck[apiMethod] === true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Not for this PR)
In the cleanup to come, I'm thinking we should probably make this class dumber and leave the decision up to cloudserver

|| actionWithDataDeletion[apiMethod] === true;
this._requestObjTags = requestObjTags || null;
this._existingObjTag = existingObjTag || null;
Expand Down Expand Up @@ -294,6 +295,7 @@ export default class RequestContext {
existingObjTag: this._existingObjTag,
needTagEval: this._needTagEval,
objectLockRetentionDays: this._objectLockRetentionDays,
needQuota: this._needQuota,
};
return JSON.stringify(requestInfo);
}
Expand Down Expand Up @@ -335,6 +337,7 @@ export default class RequestContext {
obj.existingObjTag,
obj.needTagEval,
obj.objectLockRetentionDays,
obj.needQuota,
);
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"engines": {
"node": ">=16"
},
"version": "8.1.142",
"version": "8.1.143",
"description": "Common utilities for the S3 project components",
"main": "build/index.js",
"repository": {
Expand Down
9 changes: 7 additions & 2 deletions tests/unit/policyEvaluator/RequestContext.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ describe('RequestContext', () => {
'reqTagOne=valueOne&reqTagTwo=valueTwo', // requestObjTags
'existingTagOne=valueOne&existingTagTwo=valueTwo', // existingObjTag
true, // needTagEval
5, // objectLockRetentionDays
true, // needQuota
];
const rc = new RequestContext(...constructorParams);

Expand Down Expand Up @@ -62,10 +64,12 @@ describe('RequestContext', () => {
{ name: 'getMultiFactorAuthAge', expectedValue: null },
{ name: 'getSecurityToken', expectedValue: 'security-token' },
{ name: 'getPolicyArn', expectedValue: 'arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccess' },
{ name: 'isQuotaCheckNeeded', expectedValue: false },
{ name: 'getRequestObjTags', expectedValue: 'reqTagOne=valueOne&reqTagTwo=valueTwo' },
{ name: 'getExistingObjTag', expectedValue: 'existingTagOne=valueOne&existingTagTwo=valueTwo' },
{ name: 'getNeedTagEval', expectedValue: true },
{ name: 'getObjectLockRetentionDays', expectedValue: 5 },
{ name: 'isQuotaCheckNeeded', expectedValue: true },

];
GetterTests.forEach(testCase => {
it(`getter:${testCase.name}`, () => {
Expand Down Expand Up @@ -111,7 +115,8 @@ describe('RequestContext', () => {
specificResource: 'specific-resource',
sslEnabled: true,
tokenIssueTime: null,
objectLockRetentionDays: null,
objectLockRetentionDays: 5,
needQuota: true,
};
it('serialize()', () => {
assert.deepStrictEqual(JSON.parse(rc.serialize()), SerializedFields);
Expand Down
Loading