Skip to content

Commit

Permalink
Test cases for Haufe-Lexware/wicked.haufe.io#68 - appId length, frien…
Browse files Browse the repository at this point in the history
…dly name cap at 128 chars.
  • Loading branch information
DonMartin76 committed May 24, 2017
1 parent e662f94 commit f537542
Showing 1 changed file with 47 additions and 4 deletions.
51 changes: 47 additions & 4 deletions portal-api/test/05_applicationsTest.js
Expand Up @@ -173,7 +173,7 @@ describe('/applications', function () {
headers: { 'X-UserId': devUserId },
json: true,
body: {
id: 'app456789012345678901',
id: 'app456789012345678901app456789012345678901app456789012345678901',
name: appName
}
},
Expand Down Expand Up @@ -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);
Expand All @@ -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 () {
Expand Down Expand Up @@ -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(
{
Expand Down

0 comments on commit f537542

Please sign in to comment.