Skip to content

Commit

Permalink
test: signing works as expected when path encoding is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
frederickfogerty committed Feb 24, 2022
1 parent 929e878 commit f9dca28
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions test/test-pathEncoding.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,25 @@ describe('Path Encoding:', function describeSuite() {
'https://sdk-test.imgix.net/file+with%20some+crazy?things.jpg';
assert(actual.includes(expected), 'srcset should include expected url');
});
it('signs a pre-encoded path correctly', () => {
const client = new ImgixClient({
domain: 'sdk-test.imgix.net',
secureURLToken: 'abcde1234',
includeLibraryParam: false,
});
const actual = client.buildURL(
'file+with%20some+crazy%20things.jpg',
{},
{
disablePathEncoding: true,
},
);

// The signing param for this URL was taken from a known working implementation
const expected =
'https://sdk-test.imgix.net/file+with%20some+crazy%20things.jpg?s=4aadfc1a58f27729a41d05831c52116f';
assert.strictEqual(actual, expected);
});
});
describe('buildSrcSet', () => {
let client;
Expand Down Expand Up @@ -129,5 +148,26 @@ describe('Path Encoding:', function describeSuite() {
'https://sdk-test.imgix.net/file+with%20some+crazy?things.jpg';
assert(actual.includes(expected), 'srcset should include expected url');
});
it('signs a pre-encoded path correctly', () => {
const client = new ImgixClient({
domain: 'sdk-test.imgix.net',
secureURLToken: 'abcde1234',
includeLibraryParam: false,
});
const actual = client.buildSrcSet(
'file+with%20some+crazy%20things.jpg',
{},
{
disablePathEncoding: true,
},
);

// The signing param for this URL was taken from a known working implementation
const expected = '524748753f8aa52fb41b9359f79c3188';
const firstURLSignature = new URL(
actual.split(',')[0].split(' ')[0],
).searchParams.get('s');
assert.strictEqual(firstURLSignature, expected);
});
});
});

0 comments on commit f9dca28

Please sign in to comment.