-
Notifications
You must be signed in to change notification settings - Fork 253
Improvement/cldsrv 724 versionning related functional tests #5978
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
Open
benzekrimaha
wants to merge
44
commits into
improvement/CLDSRV-724-bucket-related-functional-tests
Choose a base branch
from
improvement/CLDSRV-724-versionning-related-functional-tests
base: improvement/CLDSRV-724-bucket-related-functional-tests
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+18,243
−14,152
Open
Changes from 39 commits
Commits
Show all changes
44 commits
Select commit
Hold shift + click to select a range
5ecbaaf
utilities adaptation to comply with sdk migration
benzekrimaha fd45184
SUR tests sdk migration
benzekrimaha 532fd7c
UTAPI tests sdk migration
benzekrimaha 5c1fdd2
dependencies install
benzekrimaha 943ba0c
kms tests related code update after sdk migration
benzekrimaha 172e889
dependencies update
benzekrimaha c14d239
delete operation related tests migration
benzekrimaha bfc45c5
get operation related tests migration
benzekrimaha eec0c79
put operation related tests migration
benzekrimaha 6cab547
config adaptation to migration
benzekrimaha d788c64
route related tests migration
benzekrimaha 3324047
complete mpu related tests migration
benzekrimaha 6d7c130
multiple backend related tests migration
benzekrimaha 770e5f3
acl related tests migration
benzekrimaha b5b2dd8
listParts related tests migration
benzekrimaha 71d7c95
objectCopy related tests migration
benzekrimaha af4f95b
objectTagging related tests migration
benzekrimaha c244695
versionning utility migration
benzekrimaha 954f00f
tests utilities migration
benzekrimaha e6a0e37
mpu related tests migration
benzekrimaha 319fafa
cors related tests migration
benzekrimaha 8cae616
get operation related tests migration
benzekrimaha 8dd5a90
copy operation related tests migration
benzekrimaha 0d5f9f1
put operation related tests migration
benzekrimaha d737d0e
delete operation related tests migration
benzekrimaha e3b43ef
website related tests migration
benzekrimaha c1396ac
config migration
benzekrimaha 6f05235
rest of object related tests migration
benzekrimaha 1166011
additional dependencies install
benzekrimaha 3656891
get operation related bucket tests migration
benzekrimaha 966ccdd
delete operation related bucket tests migration
benzekrimaha 67efdd2
put operation related bucket tests migration
benzekrimaha bac5758
other operations related bucket tests migration
benzekrimaha 0f98b4c
quota related bucket tests migration
benzekrimaha 3e2bdfc
dependencies install
benzekrimaha 6862eeb
versionning utilities migration
benzekrimaha 30dc643
object related versionning tests migration
benzekrimaha b8c48cf
bucket related versionning tests migration
benzekrimaha 4b11b09
rest of versionning tests migration
benzekrimaha 6c49a49
fixups post reviews
benzekrimaha e69198c
post reviews fixups
benzekrimaha 9c8e3d1
fixups post reviews
benzekrimaha 337c4e5
fixups post reviews
benzekrimaha 49c2391
post review fixups
benzekrimaha File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 47 additions & 31 deletions
78
tests/functional/aws-node-sdk/lib/utility/customS3Request.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,43 +1,59 @@ | ||
| const { S3 } = require('aws-sdk'); | ||
| const { S3Client } = require('@aws-sdk/client-s3'); | ||
| const { HttpRequest } = require('@smithy/protocol-http'); | ||
| const querystring = require('querystring'); | ||
|
|
||
| const getConfig = require('../../test/support/config'); | ||
|
|
||
| const config = getConfig('default', { signatureVersion: 'v4' }); | ||
| const s3 = new S3(config); | ||
| const config = getConfig('default'); | ||
|
|
||
|
|
||
| // Custom middleware to modify requests without mutating args | ||
| const customRequestMiddleware = buildParams => next => async args => { | ||
|
|
||
| function customS3Request(action, params, buildParams, callback) { | ||
| const method = action.bind(s3); | ||
| const request = method(params); | ||
| const { headers, query } = buildParams; | ||
| // modify underlying http request object created by aws sdk | ||
| request.on('build', () => { | ||
| Object.assign(request.httpRequest.headers, headers); | ||
| if (query) { | ||
| const qs = querystring.stringify(query); | ||
| // NOTE: that this relies on there not being a query string in the | ||
| // first place; if there is a qs then we have to search for ? and | ||
| // append &qs at the end of the string, if ? is not followed by '' | ||
| request.httpRequest.path = `${request.httpRequest.path}?${qs}`; | ||
| } | ||
| }); | ||
| request.on('success', response => { | ||
| const resData = { | ||
| statusCode: response.httpResponse.statusCode, | ||
| headers: response.httpResponse.headers, | ||
| body: response.httpResponse.body.toString('utf8'), | ||
| }; | ||
| callback(null, resData); | ||
|
|
||
| const prevReq = args.request; | ||
| const base = prevReq instanceof HttpRequest ? prevReq : new HttpRequest(prevReq); | ||
|
|
||
| let newHeaders = base.headers || {}; | ||
| if (headers) { | ||
| newHeaders = { ...newHeaders, ...headers }; | ||
| } | ||
|
|
||
| let newQuery = base.query || {}; | ||
| if (query) { | ||
| const extra = querystring.parse(querystring.stringify(query)); | ||
| newQuery = { ...newQuery, ...extra }; | ||
| } | ||
|
|
||
| const newReq = new HttpRequest({ | ||
| ...base, | ||
| headers: newHeaders, | ||
| query: newQuery, | ||
| }); | ||
| request.on('error', err => { | ||
|
|
||
| return next({ ...args, request: newReq }); | ||
| }; | ||
|
|
||
| async function customS3Request(CommandClass, params, buildParams) { | ||
| const customS3 = new S3Client({ ...config }); | ||
benzekrimaha marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| customS3.middlewareStack.add( | ||
| customRequestMiddleware(buildParams), | ||
| { step: 'build', name: 'customRequestMiddleware', tags: ['CUSTOM'] } | ||
| ); | ||
|
|
||
| const command = new CommandClass(params); | ||
| const response = await customS3.send(command); | ||
|
|
||
| const resData = { | ||
| statusCode: request.response.httpResponse.statusCode, | ||
| headers: request.response.httpResponse.headers, | ||
| body: request.response.httpResponse.body.toString('utf8'), | ||
| statusCode: 200, | ||
| headers: response.$metadata?.httpHeaders || {}, | ||
| body: JSON.stringify(response), | ||
| }; | ||
| callback(err, resData); | ||
| }); | ||
| request.send(); | ||
|
|
||
| return resData; | ||
|
|
||
| } | ||
|
|
||
| module.exports = customS3Request; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.