Commit graph

1291 commits

Author SHA1 Message Date
Philip Molares
1c67622bf8 test(notes.service): a forbidden id throws a ForbiddenIdError in getNoteByIdOrAlias method
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2022-02-07 00:08:41 +01:00
Philip Molares
c891a95588 feat: checkNoteIdOrAlias in more alias service methods
This should prevent any interaction by a forbidden id

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2022-02-07 00:08:41 +01:00
Philip Molares
6269c7f7bc test: fix expected error codes in multiple test
In the e2e tests the global filter must be added via the special provider 'APP_FILTER' and not with useGlobalFilters, because if not the filter breaks, because of the way supertest handles the http-connection.

See: https://github.com/nestjs/nest/issues/1160#issuecomment-468698640

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2022-02-07 00:08:41 +01:00
Philip Molares
796b8294cf docs: improved auto-generated openapi docs
With these additional annotations the openapi docs under `/apidoc` and `/private/apidoc` will be improved by adding errors that the requests can return

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2022-02-07 00:08:41 +01:00
Philip Molares
2bc8c0d6da refactor(public-api): use TokenAuthGuard on controller not method level
As the public api is nearly completely protected by the TokenAuthGuard it seems unnecessarily verbose to add the guard to every method in the controllers, when an annotation at the top of the controller would be sufficient.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2022-02-07 00:08:41 +01:00
Philip Molares
d142cbadeb refactor: remove try catches from controllers
This is handled by the ErrorExceptionMapping class

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2022-02-07 00:08:41 +01:00
Philip Molares
2cd4f412e5 feat: add ErrorExceptionMapping as a global filter
This filters all error that the controller will throw and either maps
them to the correct HttpException if they are internal errors like
NotInDBError, or just leaves them be if they are not part in the map.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2022-02-07 00:08:41 +01:00
Philip Molares
2c7e82680e feat: add additional default descriptions for HttpExceptions
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2022-02-07 00:08:41 +01:00
Philip Molares
d0477a5e34 refactor: omit error mapping in GetNoteInterceptor
Because this mapping will now be done with the ErrorExceptionMapping class, the mapping will be omitted in the interceptor.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2022-02-07 00:08:41 +01:00
Philip Molares
4ad7ad368c feat: add error-mapping
The ErrorExceptionMapping class maps internal error to nestjs's appropriate HttpException.
The object returned by those HttpExceptions is now changed to include the name of the intern error code and error message instead of statusCode and error message as is default. This makes it possible to more easily programmatically distinguish between two errors that map to the same HttpException and only differ in the error message.
The statusCode was unnecessary, because any user of the api gets this information already by which HttpException was used.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2022-02-07 00:08:41 +01:00
Philip Molares
451dedef15 refactor: getNoteByIdOrAlias throws NotInDBError instead of ForbiddenIdError for an id on the forbidden list
It's not really necessary to tell the user via get that this id is forbidden, it will not be there and as such NotInDBError is the correct message to the user

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2022-02-07 00:08:41 +01:00
Philip Molares
4500caf882 refactor: move error messages from controller to service
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2022-02-07 00:08:41 +01:00
Philip Molares
f672c5179f test: remove controller tests
These test files are only autogenerated and don't have any benefit. Any behaviour one would test with them are (or at least should) already be covered by our e2e tests.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2022-02-06 20:57:34 +01:00
Renovate Bot
d2db5a0cb8 chore(deps): update dependency mkdocs-material to v8.1.10
Signed-off-by: Renovate Bot <bot@renovateapp.com>
2022-02-06 12:14:58 +00:00
Renovate Bot
4b34f94730 chore(deps): update dependency jest to v27.5.0
Signed-off-by: Renovate Bot <bot@renovateapp.com>
2022-02-05 12:27:24 +01:00
Renovate Bot
39eab69c6c chore(deps): update dependency @types/node to v16.11.22
Signed-off-by: Renovate Bot <bot@renovateapp.com>
2022-02-05 11:34:48 +01:00
Renovate Bot
c0f7178891 chore(deps): update linters to v5.10.2
Signed-off-by: Renovate Bot <bot@renovateapp.com>
2022-02-05 11:34:25 +01:00
Renovate Bot
cde9a2f66a chore(deps): update dependency @trivago/prettier-plugin-sort-imports to v3.2.0
Signed-off-by: Renovate Bot <bot@renovateapp.com>
2022-02-05 11:34:09 +01:00
Yannick Bungers
42ad99e20b Replace fs.rmdir recursive by fs.rm recursive
fs.rmdir(path, { recursive: true}) is deprecated and
is replaced by fs.rm(path, { recursive: true}).

Signed-off-by: Yannick Bungers <git@innay.de>
2022-01-31 08:55:42 +01:00
Renovate Bot
e4a9562455 chore(deps): lock file maintenance
Signed-off-by: Renovate Bot <bot@renovateapp.com>
2022-01-31 02:19:21 +00:00
Philip Molares
2d8d29cf20 refactor(config): type config mocks
To minimize type errors, when the config objects are changed, this commit introduces types to the mock config object accordingly.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2022-01-30 22:19:50 +01:00
Philip Molares
6c82b95ea2 refactor(config): introduce new interface MediaBackendConfig
This interface is needed to help to use types in some cases, where it didn't work before.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2022-01-30 22:19:50 +01:00
Philip Molares
f4a580cf2a refactor(config): extract note config from app config
This commit separates the app config object from a new note config object. This was done to separate different concerns in different config files. Especially if the number of settings that are about notes increase, it is a good idea to keep them separate from the app config.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2022-01-30 22:19:50 +01:00
Renovate Bot
baa6606729 chore(deps): update dependency mkdocs-material to v8.1.9
Signed-off-by: Renovate Bot <bot@renovateapp.com>
2022-01-30 11:20:21 +00:00
Renovate Bot
407bd27617 chore(deps): update dependency eslint-plugin-jest to v26
Signed-off-by: Renovate Bot <bot@renovateapp.com>
2022-01-29 17:21:30 +01:00
Renovate Bot
84320f6203 fix(deps): update dependency @nestjs/swagger to v5.2.0
Signed-off-by: Renovate Bot <bot@renovateapp.com>
2022-01-29 17:20:42 +01:00
Renovate Bot
d249263632 chore(deps): update dependency eslint to v8.8.0
Signed-off-by: Renovate Bot <bot@renovateapp.com>
2022-01-29 17:20:13 +01:00
Renovate Bot
18b265cf09 fix(deps): update dependency joi to v17.6.0
Signed-off-by: Renovate Bot <bot@renovateapp.com>
2022-01-29 17:13:18 +01:00
Renovate Bot
472452115d fix(deps): update dependency @types/minio to v7.0.12
Signed-off-by: Renovate Bot <bot@renovateapp.com>
2022-01-29 05:35:47 +00:00
Renovate Bot
bb81873229 chore(deps): update linters to v5.10.1
Signed-off-by: Renovate Bot <bot@renovateapp.com>
2022-01-29 03:58:46 +00:00
David Mehren
ac1cdc63e0 style(e2e-tests): remove unused imports
Signed-off-by: David Mehren <git@herrmehren.de>
2022-01-27 21:05:17 +01:00
David Mehren
4499ad4d96 test(e2e/public/alias): code cleanup
Signed-off-by: David Mehren <git@herrmehren.de>
2022-01-27 21:05:17 +01:00
David Mehren
54eefa9f6b feat(test-setup): create notes in withUsers
Signed-off-by: David Mehren <git@herrmehren.de>
2022-01-27 21:05:17 +01:00
David Mehren
d1dbd1bb22 feat(test-setup): restructure to synchronous builder
The previous pattern used async methods for the builder pattern,
which were hideous to use when chained multiple times.

This extracts the builder into a separate class
and uses normal functions in the builder.
These queue async functions in arrays, which are executed
at the correct time, when the new async `build` function is called.

Signed-off-by: David Mehren <git@herrmehren.de>
2022-01-27 21:05:17 +01:00
David Mehren
8f1aeab934 test(e2e/public/alias): test all error scenarios
Signed-off-by: David Mehren <git@herrmehren.de>
2022-01-27 21:05:17 +01:00
David Mehren
64b136fb8b test(e2e/public/alias): use real authentication
Signed-off-by: David Mehren <git@herrmehren.de>
2022-01-27 21:05:17 +01:00
David Mehren
28bd07597a test: create auth tokens in testSetup
Signed-off-by: David Mehren <git@herrmehren.de>
2022-01-27 21:05:17 +01:00
David Mehren
ff500f1be0 test: allow disabling mocked authentication
This adds a (default true) parameter `withMockAuth` to the
TestSetup class.
If it is false, the TokenAuthGuard is not overridden with a mock
implementation, allowing to test with the real authentication.

Signed-off-by: David Mehren <git@herrmehren.de>
2022-01-27 21:05:17 +01:00
David Mehren
bcb75a1d04 build(eslint): allow numbered agent objects
Signed-off-by: David Mehren <git@herrmehren.de>
2022-01-27 21:05:17 +01:00
David Mehren
ae52f70ef9 test(e2e/private/alias): test all error scenarios
Signed-off-by: David Mehren <git@herrmehren.de>
2022-01-27 21:05:17 +01:00
David Mehren
b2802d4c29 test(e2e/private/alias): use testSetup with users
Signed-off-by: David Mehren <git@herrmehren.de>
2022-01-27 21:05:17 +01:00
David Mehren
2096e23e35 test: allow creating testSetup with users
Signed-off-by: David Mehren <git@herrmehren.de>
2022-01-27 21:05:17 +01:00
David Mehren
8cfe4896bc test: cleanup test_uploads folders
Signed-off-by: David Mehren <git@herrmehren.de>
2022-01-27 21:05:17 +01:00
Renovate Bot
90cc5b3f9f chore(deps): lock file maintenance
Signed-off-by: Renovate Bot <bot@renovateapp.com>
2022-01-24 01:34:17 +00:00
David Mehren
8ea28bf1c7 ci(eslint): fail on warnings
Signed-off-by: David Mehren <git@herrmehren.de>
2022-01-23 23:01:45 +01:00
David Mehren
bf743b4266 build(eslint): disable return type warnings in tests
Signed-off-by: David Mehren <git@herrmehren.de>
2022-01-23 23:01:45 +01:00
David Mehren
898abc08f3 style: remove unused variables
Signed-off-by: David Mehren <git@herrmehren.de>
2022-01-23 23:01:45 +01:00
David Mehren
91eba0d3af
Update mailmap and AUTHORS
Signed-off-by: David Mehren <git@herrmehren.de>
2022-01-23 22:13:54 +01:00
Renovate Bot
d6ebc85ebf
chore(deps): update linters to v5.10.0
Signed-off-by: Renovate Bot <bot@renovateapp.com>
2022-01-23 19:34:22 +00:00
Renovate Bot
aa61f7f987
fix(deps): update nestjs packages
Signed-off-by: Renovate Bot <bot@renovateapp.com>
2022-01-23 19:33:55 +00:00