bra1n / judgebooth

Interactive Judge Booth
http://booth.magicjudges.org
Other
5 stars 4 forks source link

WIP: API Snapshot Testing #15

Open Takeno opened 6 years ago

Takeno commented 6 years ago

Before starting to edit something which works, I'd like to have tests to prevent mistakes.

These are rough tests made in Node.js/Jest which can help us to keep backward compatibility. They use the running backend server to check responses for every existing endpoint and it verifies them with the previous snapshot.

They are not completed, they are not verifying roles and we're not safe from bugs. But, we should be able to change things in a safer way.

Before every test, a new database is imported from scratch (it's defined in tests/judgebooth.only-data-test.sql) to create an isolated scope for requests. There is also a .travis-ci.yml configuration which can be configured for this repo too. It runs tests on every pushed commit (https://travis-ci.org/Takeno/judgebooth/builds/419208988)

I've also found a security issue during the tests: the admin-suggest API is not protected by roles, so it is a potential DDOS entrypoint.

@saveriopalmieri review this PR, let me know what are you thinking about. Before merging it, I would like to fix the issue above and update tests.