Skip to content

Commit

Permalink
test(cloudfront-signer): use non-null assertion for parsedUrl.query
Browse files Browse the repository at this point in the history
  • Loading branch information
trivikr committed Apr 30, 2024
1 parent d916f62 commit e25d416
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/cloudfront-signer/src/sign.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ describe("getSignedUrl", () => {
expect(result).toBe(`${url}?Expires=${epochDateLessThan}&Key-Pair-Id=${keyPairId}&Signature=${signature}`);
const parsedUrl = parseUrl(result);
expect(parsedUrl).toBeDefined();
const signatureQueryParam = denormalizeBase64(parsedUrl.query["Signature"] as string);
const signatureQueryParam = denormalizeBase64(parsedUrl.query!["Signature"] as string);
expect(verifySignature(signatureQueryParam, policyStr)).toBeTruthy();
});
it("should sign a URL with a custom policy containing a start date", () => {
Expand Down Expand Up @@ -162,7 +162,7 @@ describe("getSignedUrl", () => {
expect(result).toBe(`${url}?Policy=${encodeToBase64(policyStr)}&Key-Pair-Id=${keyPairId}&Signature=${signature}`);
const parsedUrl = parseUrl(result);
expect(parsedUrl).toBeDefined();
const signatureQueryParam = denormalizeBase64(parsedUrl.query["Signature"] as string);
const signatureQueryParam = denormalizeBase64(parsedUrl.query!["Signature"] as string);
expect(verifySignature(signatureQueryParam, policyStr)).toBeTruthy();
});
it("should sign a URL with a custom policy containing an ip address", () => {
Expand Down Expand Up @@ -193,7 +193,7 @@ describe("getSignedUrl", () => {
expect(result).toBe(`${url}?Policy=${encodeToBase64(policyStr)}&Key-Pair-Id=${keyPairId}&Signature=${signature}`);
const parsedUrl = parseUrl(result);
expect(parsedUrl).toBeDefined();
const signatureQueryParam = denormalizeBase64(parsedUrl.query["Signature"] as string);
const signatureQueryParam = denormalizeBase64(parsedUrl.query!["Signature"] as string);
expect(verifySignature(signatureQueryParam, policyStr)).toBeTruthy();
});
it("should sign a URL with a custom policy containing a start date and ip address", () => {
Expand Down Expand Up @@ -228,7 +228,7 @@ describe("getSignedUrl", () => {
expect(result).toBe(`${url}?Policy=${encodeToBase64(policyStr)}&Key-Pair-Id=${keyPairId}&Signature=${signature}`);
const parsedUrl = parseUrl(result);
expect(parsedUrl).toBeDefined();
const signatureQueryParam = denormalizeBase64(parsedUrl.query["Signature"] as string);
const signatureQueryParam = denormalizeBase64(parsedUrl.query!["Signature"] as string);
expect(verifySignature(signatureQueryParam, policyStr)).toBeTruthy();
});
it("should allow an ip address with and without a mask", () => {
Expand Down

0 comments on commit e25d416

Please sign in to comment.