Compare commits

...

3 Commits

Author SHA1 Message Date
Will Toozs 6ba2ae50ab
ARSN-363: update test 2023-12-07 17:51:35 +01:00
Will Toozs fffe9526a3
ARSN-363: add object retention days logic to conditions 2023-12-07 17:51:19 +01:00
Will Toozs cde9548419
ARSN-363: add object retention days logic to structures 2023-12-07 17:50:41 +01:00
4 changed files with 33 additions and 0 deletions

View File

@ -36,6 +36,7 @@ export type ParsedRetention =
export default class ObjectLockConfiguration {
_parsedXml: any;
_config: Config;
_days: number | null;
/**
* Create an Object Lock Configuration instance
@ -45,6 +46,7 @@ export default class ObjectLockConfiguration {
constructor(xml: any) {
this._parsedXml = xml;
this._config = {};
this._days = null;
}
/**
@ -183,6 +185,8 @@ export default class ObjectLockConfiguration {
this._config.rule = {};
this._config.rule.mode = validMode.mode;
this._config.rule[validTime.timeType!] = validTime.timeValue;
// Store the number of days
this._days = validTime.timeType === 'years' ? 365 * validTime.timeValue : validTime.timeValue;
}
return validConfig;
}

View File

@ -171,6 +171,7 @@ export default class RequestContext {
_needTagEval: boolean;
_foundAction?: string;
_foundResource?: string;
_objectLockRetentionDays?: number | null;
constructor(
headers: { [key: string]: string | string[] },
@ -192,6 +193,7 @@ export default class RequestContext {
requestObjTags?: string,
existingObjTag?: string,
needTagEval?: false,
objectLockRetentionDays?: number,
) {
this._headers = headers;
this._query = query;
@ -224,6 +226,7 @@ export default class RequestContext {
this._requestObjTags = requestObjTags || null;
this._existingObjTag = existingObjTag || null;
this._needTagEval = needTagEval || false;
this._objectLockRetentionDays = objectLockRetentionDays || null;
return this;
}
@ -255,6 +258,7 @@ export default class RequestContext {
requestObjTags: this._requestObjTags,
existingObjTag: this._existingObjTag,
needTagEval: this._needTagEval,
objectLockRetentionDays: this._objectLockRetentionDays,
};
return JSON.stringify(requestInfo);
}
@ -295,6 +299,7 @@ export default class RequestContext {
obj.requestObjTags,
obj.existingObjTag,
obj.needTagEval,
obj.objectLockRetentionDays,
);
}
@ -698,4 +703,24 @@ export default class RequestContext {
getNeedTagEval() {
return this._needTagEval;
}
/**
* Get object lock retention days
*
* @returns objectLockRetentionDays - object lock retention days
*/
getObjectLockRetentionDays() {
return this._objectLockRetentionDays;
}
/**
* Set object lock retention days
*
* @param objectLockRetentionDays - object lock retention days
* @returns itself
*/
setObjectLockRetentionDays(objectLockRetentionDays: number) {
this._objectLockRetentionDays = objectLockRetentionDays;
return this;
}
}

View File

@ -166,6 +166,9 @@ export function findConditionKey(
return requestContext.getNeedTagEval() && requestContext.getRequestObjTags()
? getTagKeys(requestContext.getRequestObjTags()!)
: undefined;
// The maximum retention period is 100 years.
case 's3:object-lock-remaining-retention-days':
return requestContext.getObjectLockRetentionDays() || undefined;
default:
return undefined;
}

View File

@ -111,6 +111,7 @@ describe('RequestContext', () => {
specificResource: 'specific-resource',
sslEnabled: true,
tokenIssueTime: null,
objectLockRetentionDays: null,
};
it('serialize()', () => {
assert.deepStrictEqual(JSON.parse(rc.serialize()), SerializedFields);