reset test/basic.js

this time without cryptix's basic blob test (to see if CI completes)
This commit is contained in:
Alexander Cobleigh 2020-10-21 14:53:18 +02:00
parent 988d35a736
commit d88d960c52
1 changed files with 9 additions and 41 deletions

View File

@ -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();