-
Notifications
You must be signed in to change notification settings - Fork 0
feat(source): intern images on POST check internal on PUT #74
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
+7,141
−7,051
Merged
Changes from 4 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
739e0f5
feat: intern images on POST check internal on PUT
bosschaert 2b10a22
fix: keep dynamic media URLs
bosschaert bd68e49
feat: support <picture> elements and add unit tests
bosschaert d7a5118
test: small update to unit test
bosschaert 699ff65
Update test/source/post.test.js
bosschaert 35a038d
Update test/source/utils.test.js
bosschaert 96718ec
test: convert to assert.rejects()
bosschaert 01bd8d5
refactor: reformatting
bosschaert 4ca5386
Merge branch 'main' into post-img
tripodsan a70b677
chore: fix test [skip ci]
tripodsan 0ed0298
Merge branch 'main' into post-img
tripodsan 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,16 +34,22 @@ describe('Source PUT Tests', () => { | |
| }); | ||
|
|
||
| it('test putSource HTML with user', async () => { | ||
| const html = ` | ||
| <body> | ||
| Hello | ||
| <img src="https://main--best--tst.aem.live/my-image.jpg"> | ||
| </body>`; | ||
|
|
||
| async function putFn(_uri, gzipBody) { | ||
| const b = await gunzip(Buffer.from(gzipBody, 'hex')); | ||
| assert.equal(b.toString(), '<html><body>Hello</body></html>'); | ||
| assert.equal(b.toString(), html); | ||
| } | ||
|
|
||
| nock.source() | ||
| .putObject('/tst/best/toast/jam.html') | ||
| .matchHeader('content-type', 'text/html') | ||
| .matchHeader('x-amz-meta-last-modified-by', '[email protected]') | ||
| .matchHeader('x-amz-meta-uncompressed-length', '31') | ||
| .matchHeader('x-amz-meta-uncompressed-length', '107') | ||
| .reply(201, putFn); | ||
|
|
||
| const path = '/tst/sites/best/source/toast/jam.html'; | ||
|
|
@@ -60,11 +66,27 @@ describe('Source PUT Tests', () => { | |
|
|
||
| const resp = await putSource( | ||
| context, | ||
| createInfo(path, {}, 'PUT', '<html><body>Hello</body></html>'), | ||
| createInfo(path, {}, 'PUT', html), | ||
| ); | ||
| assert.equal(resp.status, 201); | ||
| }); | ||
|
|
||
| it('test putSource HTML with external images is rejected', async () => { | ||
| const html = ` | ||
| <body> | ||
| Hello | ||
| <img src="https://main--somesite--someorg.aem.live/myimg.jpeg"> | ||
| </body>`; | ||
|
|
||
| const path = '/myorg/sites/mysite/source/my-page.html'; | ||
| const resp = await putSource( | ||
| setupContext(path), | ||
| createInfo(path, {}, 'PUT', html), | ||
| ); | ||
| assert.equal(resp.status, 400); | ||
| assert.match(resp.headers.get('x-error'), /External images are not allowed, use POST to intern them/); | ||
| }); | ||
|
|
||
| it('test putSource JSON', async () => { | ||
| function putFn(_uri, body) { | ||
| assert.deepStrictEqual(body, { something: 'else' }); | ||
|
|
||
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.
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.