From f5375421e78f216f31250003af4265a1631a3db0 Mon Sep 17 00:00:00 2001 From: Martin Danielsson Date: Wed, 24 May 2017 10:31:17 +0200 Subject: [PATCH] Test cases for Haufe-Lexware/wicked.haufe.io#68 - appId length, friendly name cap at 128 chars. --- portal-api/test/05_applicationsTest.js | 51 ++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 4 deletions(-) diff --git a/portal-api/test/05_applicationsTest.js b/portal-api/test/05_applicationsTest.js index 5f1ef15..e4d7749 100644 --- a/portal-api/test/05_applicationsTest.js +++ b/portal-api/test/05_applicationsTest.js @@ -173,7 +173,7 @@ describe('/applications', function () { headers: { 'X-UserId': devUserId }, json: true, body: { - id: 'app456789012345678901', + id: 'app456789012345678901app456789012345678901app456789012345678901', name: appName } }, @@ -206,19 +206,19 @@ describe('/applications', function () { }); }); - it('should be possible to create a new application with 20 char appId', function (done) { + it('should be possible to create a new application with 50 char appId', function (done) { request.post( { url: baseUrl + 'applications', headers: { 'X-UserId': devUserId }, json: true, body: { - id: 'appl5678901234567890', + id: 'appl5678901234567890appl56789012345678900123456789', name: appName } }, function (err, res, body) { - utils.deleteApplication('appl5678901234567890', devUserId, function () { + utils.deleteApplication('appl5678901234567890appl56789012345678900123456789', devUserId, function () { assert.isNotOk(err); assert.equal(201, res.statusCode); var jsonBody = utils.getJson(body); @@ -227,6 +227,29 @@ describe('/applications', function () { }); }); }); + + it('should be possible to create a new application, cap name at 128 chars', function (done) { + request.post( + { + url: baseUrl + 'applications', + headers: { 'X-UserId': devUserId }, + json: true, + body: { + id: 'appl5678901234567890appl56789012345678900123456789', + name: '0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdefXXXX' + } + }, + function (err, res, body) { + utils.deleteApplication('appl5678901234567890appl56789012345678900123456789', devUserId, function () { + assert.isNotOk(err); + assert.equal(201, res.statusCode); + var jsonBody = utils.getJson(body); + assert.isOk(jsonBody); + assert.equal(jsonBody.name, '0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef') + done(); + }); + }); + }); }); // POST describe('GET', function () { @@ -330,6 +353,26 @@ describe('/applications', function () { }); }); + it('should allow for changing an application name, cap at 128 chars', function (done) { + request.patch( + { + url: baseUrl + 'applications/' + appId, + headers: { 'X-UserId': devUserId }, + json: true, + body: { + id: appId, + name: '0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdefXXXX' + } + }, + function (err, res, body) { + assert.isNotOk(err); + assert.equal(200, res.statusCode); + var jsonBody = utils.getJson(body); + assert.equal('0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef', jsonBody.name); + done(); + }); + }); + it('should not allow for changing an application name for other user', function (done) { request.patch( {