Commit graph

49 commits

Author SHA1 Message Date
Philip Molares
24ccb1fcd0 Tests: Rename users.e2e-spec.ts to me.e2e-spec.ts
As users.e2e-spec.ts tests the MeController this commit renames the test appropriately

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-02-04 21:50:19 +01:00
Philip Molares
10ef4fcee1 History: Add unit and e2e test
Add unit tests for history service
Adapt relevant me e2e tests to work

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-02-04 21:50:19 +01:00
Philip Molares
7f1afc30c9 History: Add history service and usage
Add history service to allow for CRUD operations.
Use history service in controllers to:
  1. Allow manipulating of history entries
  2. Guaranty the correct existence of history entries

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-02-04 21:50:19 +01:00
Philip Molares
a7f35aaeec tests: Fix tests as part of the DTO Refactor
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-01-31 00:11:58 +01:00
Philip Molares
84ec528d14 auth: Add tests for AuthService
Move AuthTokens to auth folder

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-01-25 21:30:02 +01:00
Philip Molares
fd70b2d121 auth: fixes unit and e2e tests
adds MockAuthGuard which always return user 'hardcoded'

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-01-25 21:30:02 +01:00
Philip Molares
9c3d329bc9 tests: Removed unnecessary import of appConfigMock
As suggested by an review of David Mehren

Co-authored by: David Mehren <git@herrmehren.de>

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-01-19 12:45:36 +01:00
Philip Molares
2c4098dc55 config: splits config in multiple files
splits the big appConfig in multiple configs
adds media.config.mock.ts

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-01-17 21:19:45 +01:00
Yannick Bungers
0d95c29df2
Merge pull request #709 from hedgedoc/fix/api-notes-metadata 2021-01-15 22:47:52 +01:00
David Mehren
9f170bca4c
FilesystemBackend: Use scoped appConfig
Signed-off-by: David Mehren <git@herrmehren.de>
2021-01-13 21:45:23 +01:00
David Mehren
6301a264dd
NotesService: updateNoteByIdOrAlias should return the new note
Fixes #702

Signed-off-by: David Mehren <git@herrmehren.de>
2021-01-10 20:31:56 +01:00
David Mehren
c9a998ab73
Note E2E tests: Check that create & update dates are updated correctly
Signed-off-by: David Mehren <git@herrmehren.de>
2021-01-10 20:12:39 +01:00
David Mehren
32feb5ee10
NotesService: rename getLastRevision to getLatestRevision
This fixes an inconsistency with `RevisionsService`

Signed-off-by: David Mehren <git@herrmehren.de>
2021-01-10 20:12:39 +01:00
David Mehren
141dc349e3
NotesController: Do not crash on nonexistent notes
This commit adds proper error handling and returns 404 when a note does not exist.
Previously, we leaked the `NotInDBError` and sent a 500 status code.

Signed-off-by: David Mehren <git@herrmehren.de>
2021-01-09 22:58:16 +01:00
David Mehren
f81e67a3a1
Format with Prettier 2
Signed-off-by: David Mehren <git@herrmehren.de>
2021-01-06 23:49:45 +01:00
Tilman Vatteroth
0c56466dc1
Change year in copyright to 2021
Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
2021-01-06 22:10:19 +01:00
David Mehren
f0835f5b62
Fix prettier errors
Signed-off-by: David Mehren <git@herrmehren.de>
2021-01-06 13:05:15 +01:00
Philip Molares
6896daa62a added reuse information
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-01-05 22:12:38 +01:00
David Mehren
85ee6780ad
Remove PUT /notes/{note}/metadata and corresponding service code
Signed-off-by: David Mehren <git@herrmehren.de>
Co-authored-by: Yannick Bungers <git@innay.de>
2020-10-24 22:21:45 +02:00
David Mehren
731e577158
Add E2E tests for note metadata routes
Signed-off-by: David Mehren <git@herrmehren.de>
Co-authored-by: Yannick Bungers <git@innay.de>
2020-10-24 22:21:44 +02:00
David Mehren
26554f7168
Use unique sqlite file for every E2E test
Previously, this lead to locking errors, when multiple test runners accessed the same database and tried to clear it or tried to insert new test data.

Signed-off-by: David Mehren <git@herrmehren.de>
2020-10-24 12:30:23 +02:00
David Mehren
4f3ef414d4
Add E2E tests for the /media route
Signed-off-by: David Mehren <git@herrmehren.de>
2020-10-24 11:50:45 +02:00
David Mehren
ec8cf6d33e
NotesService: Throw NotInDBError when the note wasn't found
Signed-off-by: David Mehren <git@herrmehren.de>
2020-10-17 20:23:28 +02:00
David Mehren
98e2bf106e
Collect coverage information for E2E tests
As proposed in https://github.com/nestjs/nest/issues/3169#issuecomment-588287478

Signed-off-by: David Mehren <git@herrmehren.de>
2020-10-03 18:00:12 +02:00
Yannick Bungers
0dec095ed7
Merge pull request #502 from codimd/custom-logger
Use custom logger
2020-10-02 21:05:06 +02:00
David Mehren
d7f407da2d
Switch to using the new custom logger
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-27 21:48:42 +02:00
Yannick Bungers
fe66add8e0 Changed let to const to make eslint happy
Signed-off-by: Yannick Bungers <git@innay.de>
2020-09-26 23:47:51 +02:00
Yannick Bungers
64a064f9b6 Added await to wait for completion of note creation in tests
Signed-off-by: Yannick Bungers <git@innay.de>
2020-09-26 23:40:15 +02:00
Yannick Bungers
bf1081bcf6 Added tests test functions for /me routes
Note that they don't contain the functions from the services yet.

Signed-off-by: Yannick Bungers <git@innay.de>
2020-09-26 23:30:49 +02:00
David Mehren
b06dc5f967
Note E2E tests: Use response.body to get the note content
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-25 21:37:40 +02:00
David Mehren
c5842d69e1
Note E2E tests: Use the correct revision-id when checking GET /notes/{note}/revisions/{revision-id}
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-25 21:37:40 +02:00
David Mehren
a3ba5bccf7
Note E2E tests: The response for the /notes/<id>/revision route does not contain a revisions property
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-25 21:37:39 +02:00
David Mehren
a98c4fbb1b
Note E2E tests: Await all note-creations and fix test for note-deletion.
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-25 21:37:39 +02:00
David Mehren
53cea4cb1d
Note E2E tests: Use on-disk sqlite to aid debugging
It was helpful to inspect database contents while the code was stopped by the debugger. Therefore the E2E test database is now persisted on disk and cleared before every test-run.

Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-25 21:37:39 +02:00
David Mehren
9da1a88e74
Note E2E tests: Set a non-JSON content-type to avoid Nest trying to parse markdown to JSON.
Nest automatically tries to parse incoming requests with application/json as content-type and responds with HTTP 400 if the parsing fails. As our test-note-content is not valid JSON, we need to set another content-type.

Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-25 21:37:39 +02:00
David Mehren
3436990ac6
Restructure test setup in Note E2E tests to not load the whole application
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-25 21:37:39 +02:00
David Mehren
eb4278dd73
Update Note E2E tests to use new getNoteDtoByIdOrAlias method
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-25 21:37:39 +02:00
David Mehren
4b0729cc9c
Add E2E tests for /notes route
Most tests already test the correct thing, but all obviously fail because nothing is implemented yet.

Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-25 20:46:36 +02:00
David Mehren
959e6e1645
Add Jest config for E2E tests
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-25 20:46:36 +02:00
Philip Molares
fab2607e4d
Move lib and test into src directory
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2020-05-22 14:19:05 +02:00
Sheogorath
b3d4cdbceb
Update RevealJS to version 3.9.2
This update of revealJS helps us to get rid of the headjs depedency
integration using webpack. It updates reveal.js to 3.9.2 and updates the
csp hash accordingly for using the slide mode.

Background for this update is the critical security vulnerability
described by snyk in their disclosure:
https://snyk.io/vuln/SNYK-JS-REVEALJS-543841

Signed-off-by: Sheogorath <sheogorath@shivering-isles.com>
2020-02-01 12:53:15 +01:00
Claudius
4833f300c5 polyfilling scrypt for node 8.5+
Signed-off-by: Claudius <opensource@amenthes.de>
2019-05-13 19:37:21 +02:00
Claudius
1d403e183d asyncified setting and verifying the password
Signed-off-by: Claudius <opensource@amenthes.de>
2019-05-13 19:37:21 +02:00
Claudius
4b579be93e Adding the first few lines of user model test
Signed-off-by: Claudius <opensource@amenthes.de>
2019-05-13 14:37:08 +02:00
Sheogorath
a5133e0f9b
Use libravatar as drop-in replacement for gravatar
Since libravatar got a default fallback to Gravatar and in generell
allows federated image hosting for avatars this shouldn't break any
existing implementations.

The federation functionality is not added yet. This would require to use
the libravatar library.

Details:
https://wiki.libravatar.org/api/

Signed-off-by: Sheogorath <sheogorath@shivering-isles.com>
2019-03-17 23:51:54 +01:00
Sheogorath
1ee9874393
Fix names with spaces in letter-avatars
Seems like there is a possible problem when a name containing a space is
passed to this function. using urlencode on the name should fix possible
problems here.

Signed-off-by: Sheogorath <sheogorath@shivering-isles.com>
2019-03-03 15:46:28 +01:00
Sheogorath
bf229d91c6
Add linting for tests
The tests are currently not linted. This causes a different coding style
than the rest of the sources.

This patch adds the `./test` directory to the eslint testing and fixes
linting for existing tests.

Signed-off-by: Sheogorath <sheogorath@shivering-isles.com>
2019-01-21 17:17:54 +01:00
Sheogorath
d408f4c0fe
Add tests for csp.js
Since we lack of tests but got some great point to start, let's write
more tests.

This patch provides some basic tests for our CSP library. It's more an
integration than a unit test, but gets the job done.

Signed-off-by: Sheogorath <sheogorath@shivering-isles.com>
2019-01-19 13:54:52 +01:00
Daan Sprenkels
318a37d41c Add a test for gravatar urls
Signed-off-by: Daan Sprenkels <hello@dsprenkels.com>
2018-12-22 19:09:45 +01:00