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

docs(samples): Samples for v4 Signed URL #654

Merged
merged 13 commits into from
Apr 4, 2019

Conversation

jkwlui
Copy link
Member

@jkwlui jkwlui commented Apr 1, 2019

No description provided.

@jkwlui jkwlui changed the base branch from master to v4-signedurl April 1, 2019 22:52
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Apr 1, 2019
@JustinBeckwith
Copy link
Contributor

That's a fine lookin API!

@jkwlui jkwlui requested a review from frankyn April 2, 2019 17:12
samples/files.js Outdated Show resolved Hide resolved
samples/files.js Outdated Show resolved Hide resolved
@jkwlui jkwlui requested a review from frankyn April 3, 2019 00:53
Copy link
Member

@frankyn frankyn left a comment

Choose a reason for hiding this comment

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

One more small nit and LGTM.

samples/files.js Outdated
const options = {
version: 'v4',
action: 'read',
expires: Date.now() + 1000 * 60 * 60, // one hour
Copy link
Member

Choose a reason for hiding this comment

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

Missed this in the last review, please change expires time to 15 minutes to be consistent with other language samples. For Read and Upload samples.

Copy link
Contributor

@bcoe bcoe left a comment

Choose a reason for hiding this comment

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

a few nits, mainly I feel the ratio of console.logs to the size of the code snippets is a bit high (but maaaaybe I'm too terse). I would, however, try to make your tests less dependent on the text output.

.getSignedUrl(options);

console.log('Generated GET signed URL:');
console.log(url);
Copy link
Contributor

Choose a reason for hiding this comment

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

this is a little wordy, I might be tempted to consolidate in a single template string comment:

console.info(`generated the signed URL ${url} which is valid for one hour`)

Copy link
Member Author

Choose a reason for hiding this comment

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

Good call out, but as @frankyn mentioned, we have standardized the outputs of these samples across languages so we'd just have to follow the canonical :)

samples/system-test/files.test.js Outdated Show resolved Hide resolved
`${cmd} generate-v4-upload-signed-url ${bucketName} ${signedFileName}`
);
const regExp = new RegExp(
'Generated PUT signed URL:\n' +
Copy link
Contributor

Choose a reason for hiding this comment

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

Again I'd probably try to reduce the size of this regex, perhaps just:

output.match(/URL: ([^ ]+)/)

samples/system-test/files.test.js Show resolved Hide resolved
@JustinBeckwith JustinBeckwith merged commit 4146ba0 into v4-signedurl Apr 4, 2019
jkwlui added a commit that referenced this pull request Apr 4, 2019
* feat: v4 signed url WIP

* make version an optinoal

* lint

* add required host header

* fix canonical query params joining

* add test for defaulting to v2

* fix v4 signing with test

* fix tests

* refactor post-signing url construction v2/v4

* add v4 tests: response-content-type and generate parameters

* convert signature to HEX

* add conformance test

* npm run fix

* remove reduntant toLowerCase

* do not promisify getDate()

* add system-test for v4 signing

* run conformance test along with system test

* fix tests

* add content-md5 and content-type to signed headers if given

* Object.entries in not ES5

* npm run fix

* split out conformance test

* test: invalid version param given

* mock out Date when testing instead of override Date

* use Array.map to build canonical query

* refactor: use dateformat library instead of writing a function

* refactor: remove unused

* remove reference to deleted methods

* refactor: use string interpolation and dot accessor

* refactor: use method chaining

* add a comment about singled valued header

* refactor signedHeaders

* Number(x)

* refactor: use query-string module as url.parse is deprecated

* npm run fix

* use query-string to build canonicalQueryParams

* refactor: verb => method

* refactor: use sinon.FakeTimers instead of timekeeper

* npm run fix

* use async/await for new system-test

* use async/await for new test (2)

* convert getSignedUrl tests to async/await

* refactor: correctly filter out undefined header values

* npm run fix

* make v4 multi-valued header delimiter consistent with v2, (single `,`, no space)

* copy stack trace

* fix: replace ALL sequential spaces

* OutgoingHttpHeaders use generic type .map; rename flattenObject => objectEntries

* refactor: use build-in querystring

* break up v2/v4 signed url query interface

* add comments about the construction of canonical headers

* npm run fix

* git merge failed to put code in right place

* test: assert SigningError thrown

* test(v4): resumable upload

* prefer string.includes over indexOf

* npm run fix

* docs: add a note on POST and X-Goog-Resumable

* SEVEN_DAYS = 604800

* emit warning when using default version

* emitWarning if using default version for signing

* restore stub

* add new line

* test: v4 signed URL: conformance test (#638)

* Revert "split out conformance test"

This reverts commit ce00255.

* sync conformance-test cases; parse cases without modification

* this.skip

* refactor: lift interface

* remove default v2 warning

* docs(samples): Samples for v4 Signed URL (#654)

* remove timeout on conformance-test

* npm run fix
@stephenplusplus stephenplusplus deleted the v4-signedurl-samples branch November 26, 2019 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants