Skip to content

Commit 16ff162

Browse files
author
bgrana
committed
Add type check for upload operation's 'isPublic' parameter
1 parent 1a32277 commit 16ff162

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

tasks/lib/operations.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ module.exports.upload_mac = function upload_mac(grunt, instance_name, file, isPu
3131
'Authorization': 'Bearer ' + instance_info.token_info.access_token
3232
};
3333

34+
if (typeof isPublic !== 'boolean') {
35+
reject('Error: isPublic parameter must be a boolean.');
36+
}
37+
3438
try {
3539
headers['Content-Length'] = fs.statSync(file)['size'];
3640
} catch (e) {

test/operations.spec.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,4 +220,11 @@ describe('Upload', function () {
220220
expect(url).to.include('public=true');
221221
});
222222
});
223+
224+
it('should fail to upload a MAC if the isPublic parameter is not a boolean', function () {
225+
var publicErrorMsg = 'Error: isPublic parameter must be a boolean.';
226+
common.stubOperation('post', {statusCode: 200});
227+
var promise = ops.upload_mac(grunt, "some_instance", "File", "Not a boolean");
228+
expect(promise).to.be.rejectedWith(publicErrorMsg);
229+
});
223230
});

0 commit comments

Comments
 (0)