diff --git a/test/basic.js b/test/basic.js index 67cfcf2..ef50631 100644 --- a/test/basic.js +++ b/test/basic.js @@ -31,74 +31,42 @@ const paths = [ tap.setTimeout(0); tap.test("DNS rebind attack fails", (t) => { + t.plan(1); supertest(app) .get("/inbox") .set("Host", "example.com") .expect(400) - .end((err) => { - t.equal(err, null); - t.end(); - }); + .end(t.error); }); tap.test("CSRF attack should fail with no referer", (t) => { - supertest(app).post("/conn/settings/stop").expect(400).end(t.end); + t.plan(1); + supertest(app).post("/conn/settings/stop").expect(400).end(t.error); }); tap.test("CSRF attack should fail with wrong referer", (t) => { + t.plan(1); supertest(app) .post("/conn/settings/stop") .set("Host", "example.com") .expect(400) - .end((err) => { - t.equal(err, null); - t.end(); - }); + .end(t.error); }); paths.forEach((path) => { tap.test(path, (t) => { + t.plan(1); supertest(app) .get(path) .set("Host", "localhost") .expect(200) .end((err) => { - t.equal(err, null); - console.log("done:" + path); - t.end(); + console.log(path); + t.error(err); }); }); }); -// basic blob -tap.test("preview with blob", (t) => { - // TODO: i bet there must be something like beautfiul soup for nodejs, right? - let textRe = /hello testworld!/; - let blobRe = /\[128zeros\]\((&[0-9a-zA-Z]+=.sha256)\)/; - supertest(app) - .post("/publish/preview") - .field("text", "hello testworld!") - .attach("blob", "test/fixtures/128zeros") - .set("Referer", "http://localhost/publish/preview") - .set("Host", "localhost") - .set("Accept", "text/html") - .expect(200, textRe) - .expect((res) => { - let found = res.text.match(blobRe); - t.notEqual(found, null, "body did not match blob regexp"); - t.true(found.length >= 1, `expected ${found.length} >= 1`); - t.equal( - found[1], - "&OHI6Ll6KF6p5UNwAggmUTomPaae9EKI8g500HpNf1co=.sha256" - ); - }) - .end((err) => { - t.equal(err, null); - console.log("done: preview with blob"); - t.end(); - }); -}); - // HACK: This closes the database. tap.teardown(() => { app.close();