Skip to content

Commit da2c717

Browse files
committed
signed url and auth param test cases
1 parent d1b3ebd commit da2c717

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

tests/authParams.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const chai = require("chai");
2+
const expect = chai.expect;
3+
const initializationParams = require("./data").initializationParams
4+
const ImageKit = require(".."); // This will automatically pick main module (cjs bundle) as per package.json
5+
6+
7+
describe("Authentication params check", function () {
8+
var imagekit = new ImageKit({
9+
publicKey: "public_key_test",
10+
privateKey: "private_key_test",
11+
urlEndpoint: "https://test-domain.com/test-endpoint"
12+
});
13+
14+
it('Singature should be correct', function () {
15+
var authenticationParameters = imagekit.getAuthenticationParameters("your_token", 1582269249);
16+
expect(authenticationParameters).to.deep.equal({
17+
token: 'your_token',
18+
expire: 1582269249,
19+
signature: 'e71bcd6031016b060d349d212e23e85c791decdd'
20+
})
21+
});
22+
});

tests/url-generation.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@ describe("URL generation", function () {
3333
expect(url).equal(`https://ik.imagekit.io/test_url_endpoint/test_path_alt.jpg`);
3434
});
3535

36+
it('Signed URL', function () {
37+
const url = imagekit.url({
38+
path: "/test_path_alt.jpg",
39+
signed: true
40+
});
41+
42+
expect(url).equal(`https://ik.imagekit.io/test_url_endpoint/test_path_alt.jpg?ik-s=e26ca157df99b30b2443d7cb6886fc396fb4c87b`);
43+
});
44+
3645
it('should generate the correct url with path param', function () {
3746
const url = imagekit.url({
3847
path: "/test_path.jpg",

0 commit comments

Comments
 (0)