Skip to content

Commit 527e633

Browse files
committed
fix: individual test cases for security params
1 parent 1914360 commit 527e633

File tree

1 file changed

+37
-3
lines changed

1 file changed

+37
-3
lines changed

test/upload.js

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,19 +119,53 @@ describe("File upload", function () {
119119
expect(callback.calledOnce).to.be.true;
120120
sinon.assert.calledWith(callback, { help: "", message: "Missing file parameter for upload" }, null);
121121
});
122+
123+
it('Missing token', function () {
124+
const fileOptions = {
125+
fileName: "test_file_name",
126+
file: "test_file",
127+
signature: 'test_signature',
128+
expire: 123
129+
};
122130

123-
it('Missing security parameters', function () {
131+
var callback = sinon.spy();
132+
133+
imagekit.upload(fileOptions, callback);
134+
expect(server.requests.length).to.be.equal(1);
135+
expect(callback.calledOnce).to.be.true;
136+
sinon.assert.calledWith(callback, { message: "Missing token for upload. The SDK expects token for authentication.", help: "" }, null);
137+
});
138+
139+
it('Missing signature', function () {
124140
const fileOptions = {
125141
fileName: "test_file_name",
126-
file: "test_file"
142+
file: "test_file",
143+
token: 'test_token',
144+
expire: 123
145+
};
146+
147+
var callback = sinon.spy();
148+
149+
imagekit.upload(fileOptions, callback);
150+
expect(server.requests.length).to.be.equal(1);
151+
expect(callback.calledOnce).to.be.true;
152+
sinon.assert.calledWith(callback, { message: "Missing signature for upload. The SDK expects signature for authentication.", help: "" }, null);
153+
});
154+
155+
it('Missing expire', function () {
156+
const fileOptions = {
157+
fileName: "test_file_name",
158+
file: "test_file",
159+
token: 'test_token',
160+
signature: 'test_signature'
127161
};
128162

129163
var callback = sinon.spy();
130164

131165
imagekit.upload(fileOptions, callback);
132166
expect(server.requests.length).to.be.equal(1);
133167
expect(callback.calledOnce).to.be.true;
134-
sinon.assert.calledWith(callback, { message: "Missing security parameters for upload. The SDK expects token, signature and expire for authentication.", help: "" }, null);
168+
sinon.assert.calledWith(callback, { message: "Missing expire for upload. The SDK expects expire for authentication.", help: "" }, null);
135169
});
136170

137171
it('Missing public key', function () {

0 commit comments

Comments
 (0)