Skip to content

Commit e227ea7

Browse files
committed
test(cloudfront-signer): should not normalize the URL
1 parent 43d0b6d commit e227ea7

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

packages/cloudfront-signer/src/sign.spec.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,23 @@ describe("getSignedUrl", () => {
366366
const signatureQueryParam = denormalizeBase64(signature);
367367
expect(verifySignature(signatureQueryParam, policy)).toBeTruthy();
368368
});
369+
370+
describe("should not normalize the URL", () => {
371+
it.each([".", ".."])("with '%s'", (folderName) => {
372+
const urlWithFolderName = `https://d111111abcdef8.cloudfront.net/public-content/${folderName}/private-content/private.jpeg`;
373+
const policy = JSON.stringify({ Statement: [{ Resource: urlWithFolderName }] });
374+
const result = getSignedUrl({
375+
keyPairId,
376+
privateKey,
377+
policy,
378+
passphrase,
379+
});
380+
const signature = createSignature(policy);
381+
expect(result.startsWith(urlWithFolderName)).toBeTruthy();
382+
const signatureQueryParam = denormalizeBase64(signature);
383+
expect(verifySignature(signatureQueryParam, policy)).toBeTruthy();
384+
});
385+
});
369386
});
370387

371388
describe("getSignedCookies", () => {

0 commit comments

Comments
 (0)