From 5434d2118d9b6828f3c679f88618ee8403fd6e8b Mon Sep 17 00:00:00 2001 From: John McLear Date: Wed, 26 Nov 2014 19:28:49 +0000 Subject: [PATCH] tidy up and re-organize --- bin/backendTests.sh | 2 +- tests/backend/specs/{api.js => api/pad.js} | 42 +------------------- tests/backend/specs/api/sessionsAndGroups.js | 38 ++++++++++++++++++ 3 files changed, 40 insertions(+), 42 deletions(-) rename tests/backend/specs/{api.js => api/pad.js} (85%) create mode 100644 tests/backend/specs/api/sessionsAndGroups.js diff --git a/bin/backendTests.sh b/bin/backendTests.sh index ab07e012b..ec12775ba 100755 --- a/bin/backendTests.sh +++ b/bin/backendTests.sh @@ -1 +1 @@ -src/node_modules/mocha/bin/mocha --timeout 5000 --reporter nyan tests/backend/specs +src/node_modules/mocha/bin/mocha --timeout 5000 --reporter nyan tests/backend/specs/api diff --git a/tests/backend/specs/api.js b/tests/backend/specs/api/pad.js similarity index 85% rename from tests/backend/specs/api.js rename to tests/backend/specs/api/pad.js index 279f3088a..efb3f6dee 100644 --- a/tests/backend/specs/api.js +++ b/tests/backend/specs/api/pad.js @@ -4,7 +4,7 @@ var assert = require('assert') api = supertest('http://localhost:9001'); path = require('path'); -var filePath = path.join(__dirname, '../../../APIKEY.txt'); +var filePath = path.join(__dirname, '../../../../APIKEY.txt'); var apiKey = fs.readFileSync(filePath, {encoding: 'utf-8'}); var apiVersion = 1; @@ -197,46 +197,6 @@ describe('getReadOnlyID', function(){ }); }) - - -/* Endpoints Still to interact with.. -padUsersCount(padID) -setPublicStatus(padID, publicStatus) -getPublicStatus(padID) -setPassword(padID, password) -isPasswordProtected(padID) -listAuthorsOfPad(padID) -getLastEdited(padID) -listSessionsOfGroup(groupID) -getSessionInfo(sessionID) -deleteSession(sessionID) -createSession(groupID, authorID, validUntil) -listPadsOfAuthor(authorID) -createAuthorIfNotExistsFor(authorMapper [, name]) -createAuthor([name]) -createGroupPad(groupID, padName [, text]) -listPads(groupID) -deleteGroup(groupID) -createGroupIfNotExistsFor(groupMapper) -createGroup() -*/ - - -/* -describe('getRevisionsCount', function(){ - it('gets the revision counts of a new pad', function(done) { - // This is broken because Etherpad doesn't handle HTTP codes properly see #2$ - // If your APIKey is password you deserve to fail all tests anyway - api.get(endPoint('getRevisionsCount')+"&padID="+testPadId) - .expect('Content-Type', /json/) - .expect(function(res){ - console.log(res.body); - }) - .expect(200, done) - }); -}) -*/ - var endPoint = function(point){ return '/api/'+apiVersion+'/'+point+'?apikey='+apiKey; } diff --git a/tests/backend/specs/api/sessionsAndGroups.js b/tests/backend/specs/api/sessionsAndGroups.js new file mode 100644 index 000000000..921724c7d --- /dev/null +++ b/tests/backend/specs/api/sessionsAndGroups.js @@ -0,0 +1,38 @@ +/* Endpoints Still to interact with.. +padUsersCount(padID) +setPublicStatus(padID, publicStatus) +getPublicStatus(padID) +setPassword(padID, password) +isPasswordProtected(padID) +listAuthorsOfPad(padID) +getLastEdited(padID) +listSessionsOfGroup(groupID) +getSessionInfo(sessionID) +deleteSession(sessionID) +createSession(groupID, authorID, validUntil) +listPadsOfAuthor(authorID) +createAuthorIfNotExistsFor(authorMapper [, name]) +createAuthor([name]) +createGroupPad(groupID, padName [, text]) +listPads(groupID) +deleteGroup(groupID) +createGroupIfNotExistsFor(groupMapper) +createGroup() +*/ + + +var endPoint = function(point){ + return '/api/'+apiVersion+'/'+point+'?apikey='+apiKey; +} + +function makeid() +{ + var text = ""; + var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; + + for( var i=0; i < 5; i++ ){ + text += possible.charAt(Math.floor(Math.random() * possible.length)); + } + return text; +} +