From 47050985bcd06895855e9dd6f91195c335873d39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20M=C3=BCller?= Date: Sun, 24 Sep 2017 00:22:58 +0200 Subject: [PATCH] frisby tests removed --- Makefile | 3 - README.md | 8 -- api_spec.js | 229 ---------------------------------------------------- 3 files changed, 240 deletions(-) delete mode 100644 api_spec.js diff --git a/Makefile b/Makefile index 81164a9..872def3 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,5 @@ run: SKIP_CAPTCHA=1 go run *.go -test: - jasmine-node . - db: echo 'CREATE TABLE "notes" (`id` VARCHAR(6) UNIQUE PRIMARY KEY, `text` TEXT, `published` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, `edited` TIMESTAMP DEFAULT NULL, `password` VARCHAR(16), `views` INTEGER DEFAULT 0);' | sqlite3 database.sqlite diff --git a/README.md b/README.md index 35bda51..8cc5cdd 100644 --- a/README.md +++ b/README.md @@ -13,11 +13,3 @@ Install `dep` using Homebrew and run it inside project to install the dependenci Now you can run the app with `make run`. -## Testing - -Install `frisby 0.8.5 globally` and link it inside the project: - -1. `npm install -g frisby@0.8.5` -2. `npm link frisby` - -Now the test can be run with: `make test` diff --git a/api_spec.js b/api_spec.js deleted file mode 100644 index b9837bc..0000000 --- a/api_spec.js +++ /dev/null @@ -1,229 +0,0 @@ -var frisby = require('frisby'); - -frisby.create('Landing page') - .get('http://localhost:3000/') - .expectStatus(200) - .expectHeaderContains('content-type', 'text/html; charset=utf-8') - .expectBodyContains('Markdown Publishing') - .toss(); - -frisby.create('Open note page') - .get('http://localhost:3000/new') - .expectStatus(200) - .expectHeaderContains('content-type', 'text/html; charset=utf-8') - .expectBodyContains('Terms of Service') - .toss(); - -frisby.create('Open TOS') - .get('http://localhost:3000/TOS.md') - .expectStatus(200) - .expectHeaderContains('content-type', 'text/html; charset=utf-8') - .expectBodyContains('Site Terms of Use Modifications') - .toss(); - -frisby.create('Incurrect URL') - .get('http://localhost:3000/abcdef') - .expectStatus(404) - .expectBodyContains('Not found') - .toss(); - -frisby.create('Invalid posting 1') - .post('http://localhost:3000/note') - .expectStatus(412) - .expectHeaderContains('content-type', 'text/html; charset=utf-8') - .expectBodyContains('Precondition failed') - .toss(); - -frisby.create('Invalid posting 2') - .post('http://localhost:3000/note', { tos: "on" }) - .expectStatus(400) - .expectHeaderContains('content-type', 'text/html; charset=utf-8') - .expectBodyContains('Bad request') - .toss(); - -frisby.create('Invalid posting 3') - .post('http://localhost:3000/note', { - text: "too short", - password: '', - tos: 'on', - }) - .expectStatus(400) - .expectHeaderContains('content-type', 'text/html; charset=utf-8') - .expectBodyContains('length not accepted') - .toss(); - -let testNote = 'This is a test note'; - -frisby.create('Invalid posting 4') - .post('http://localhost:3000/note', { - note: testNote - }) - .expectStatus(412) - .expectHeaderContains('content-type', 'text/html; charset=utf-8') - .expectBodyContains('Precondition failed') - .toss(); - -frisby.create('Valid posting') - .post('http://localhost:3000/note', { - password: '', - tos: 'on', - text: testNote - }) - .expectStatus(301) - .expectHeaderContains('content-type', 'text/plain; charset=utf-8') - .expectHeaderContains('Location', '/') - .after(function(err, res, body) { - let noteId = res.headers.location.replace('/', ''); - frisby.create('Read posted note') - .get('http://localhost:3000/' + noteId) - .expectStatus(200) - .expectBodyContains(testNote) - .after((err, res, body) => { - frisby.create('Illegal note editing attempt with empty password') - .post('http://localhost:3000/note', { - id: noteId, - tos: 'on', - action: 'UPDATE', - text: testNote + '!!!', - password: '' - }) - .expectStatus(400) - .expectBodyContains('password is empty') - .toss(); - }) - .after((err, res, body) => { - frisby.create('Illegal note editing attempt') - .post('http://localhost:3000/note', { - id: noteId, - tos: 'on', - action: 'UPDATE', - text: testNote + '!!!', - password: 'aaabbb' - }) - .expectStatus(401) - .expectBodyContains('id or password is wrong') - .toss(); - - }) - .toss(); - }) - .toss(); - -frisby.create('Valid posting, editing and removal') - .post('http://localhost:3000/note', { - password: 'aabbcc', - tos: 'on', - text: testNote - }) - .expectStatus(301) - .expectHeaderContains('Location', '/') - .expectHeaderContains('content-type', 'text/plain; charset=utf-8') - .after(function(err, res, body) { - let noteId = res.headers.location.replace('/', ''); - frisby.create('Export posted note') - .get('http://localhost:3000/' + noteId + '/export') - .expectStatus(200) - .expectHeaderContains('content-type', 'text/plain; charset=utf-8') - .expectBodyContains(testNote) - .toss(); - frisby.create('Read posted note') - .get('http://localhost:3000/' + noteId) - .expectStatus(200) - .expectBodyContains(testNote) - .expectHeaderContains('content-type', 'text/html; charset=utf-8') - .after((err, res, body) => { - frisby.create('Unauthorized note editing attempt') - .post('http://localhost:3000/note', { - id: noteId, - tos: 'on', - text: testNote + '!!!', - password: 'abbcc' - }) - .expectStatus(401) - .expectBodyContains('password is wrong') - .toss(); - }) - .after((err, res, body) => { - frisby.create('Valid note editing attempt') - .post('http://localhost:3000/note', { - id: noteId, - tos: 'on', - text: 'Changed text!', - password: 'aabbcc' - }) - .expectStatus(301) - .after((err, res, body) => { - frisby.create('Read changed note') - .get('http://localhost:3000/' + noteId) - .expectStatus(200) - .expectBodyContains('Changed text!') - .after((err, res, body) => { - frisby.create('Read export of posted note') - .expectStatus(200) - .get('http://localhost:3000/' + noteId + '/export') - .expectHeaderContains('content-type', 'text/plain; charset=utf-8') - .expectBodyContains('Changed text!') - .toss(); - frisby.create('Open /edit on posted note') - .expectStatus(200) - .expectBodyContains('') - .get('http://localhost:3000/' + noteId + '/edit') - .toss(); - frisby.create('Read stats of posted note') - .get('http://localhost:3000/' + noteId + '/stats') - .expectHeaderContains('content-type', 'text/html; charset=utf-8') - .expectStatus(200) - .expectBodyContains('Statistics') - .expectBodyContains('Views0') - .toss(); - }) - .after((err, res, body) => { - frisby.create('Note available') - .get('http://localhost:3000/' + noteId) - .expectStatus(200) - .toss(); - frisby.create('Delete note with empty password') - .post('http://localhost:3000/note', { "id": noteId, "tos": "on", "text": "" }) - .expectStatus(400) - .toss(); - frisby.create('Delete note with wrong password') - .post('http://localhost:3000/note', { "id": noteId, "tos": "on", "text": "", "password": "xxyycc" }) - .expectStatus(401) - .toss(); - }) - .after((err, res, body) => { - frisby.create('Delete note') - .post('http://localhost:3000/note', { "id": noteId, "tos": "on", "text": "", "password": "aabbcc" }) - .expectStatus(301) - .after(function(err, res, body) { - frisby.create('Note unavailable') - .get('http://localhost:3000/' + noteId) - .expectStatus(404) - .toss(); - }) - .toss(); - }) - .toss(); - }) - .toss(); - }) - .toss(); - }) - .toss(); - -var tooLongNote = 'ABCD'; - -while (tooLongNote.length < 1024*200) tooLongNote += tooLongNote; - -frisby.create('Invalid posting of too long note') - .post('http://localhost:3000/note', { - action: 'POST', - tos: 'on', - password: 'aabbcc', - text: tooLongNote - }) - .expectStatus(400) - .expectHeaderContains('content-type', 'text/html; charset=utf-8') - .expectBodyContains('length not accepted') - .toss(); -