8 Commits

Author SHA1 Message Date
ian
8f52fdf1f9 Validate type of items' primary keys (#13276)
* Validate type of items' primary keys

* Update tests

* Update validations

* Remove DB specific check for statusCode in existing e2e test

* Extract as util function

* Add unit test

* Refactor to generic validateKeys
2022-05-24 11:11:28 -04:00
Rijk van Zanten
a36c7eabeb Use json parser wrapper function to prevent pollution attacks (#13191) 2022-05-09 14:57:38 -04:00
Rob Lee
b62456fca8 first attempt at nested sorting (#12084)
* first attempt at nested sorting

* pull out addJoin so it can be reused

* Move get-relation-info to file, add tests

* Extract get-column-path, add tests

* Little cleanup

* Prevent the regex from blowing up with malicious input

* Allow sorting on m2o fields in the tabular layout

Co-authored-by: rijkvanzanten <rijkvanzanten@me.com>
2022-04-27 15:02:10 -04:00
Azri Kahar
d0b0818cca Return 401 status code for expired tokens (#12281)
* Refresh token when it's expired & retry request

* move refresh token interceptor in autoRefresh flag

* add TOKEN_EXPIRED exception

* update interceptor condition & fix autoRefreshJob

* update docs

* revert auth drivers changes

* remove unused imports

* undo sdk auth refresh changes
2022-04-04 09:23:28 -04:00
Azri Kahar
ce0169d5c8 fix LOGGER_LEVELS array being split as string (#12342)
* fix LOGGER_LEVELS array being split as string

* use toArray

* some basic tests
2022-03-24 09:08:43 -04:00
Rijk van Zanten
eea9f45624 Add authenticate hook to implement custom auth checks against current request (#11942)
* Add "authenticate" filter hook that allows custom auth check

* Start on test

* Update Jest, restructure API tests, start implementing authenticate test

* Move access token verify to util function

* Ensure jest can show inline warnings on correct lines

* Update is-directus-jwt to use jsonwebtoken decode + add tests

* Remove unused package

* Tweak and finish + test authenticate

* Tweak test

* Add authenticate filter to docs

* Don't scan tests for codeql

* No seriously, ignore tests
2022-03-03 16:29:13 -05:00
rijkvanzanten
eb2af9cfb9 Split up integration / unit tests 2022-01-24 15:11:13 -05:00
Jay Cammarano
ef9b30c0e1 Integration tests set up and examples (#10419)
* tsconfig loosened to match api

* integration test folder and script

* .env mock isn't needed

* mock-env, locations of tests

* I was wrong.

* Updated progress

* schemas => getSchema(), exported getColumnPreprocessor()

* change imports to allow build

* add MockClient as DB Client (should mock getDBClient())

* move authservice into. not used elsewhere

* test passing

* remove unneeded test for this PR

* removed unneded fields from rawItem

* formatting

* createOne test passing

* typo

* removed int specific jest.config

* use systemSchema over getSchema()

* this.knex over getDatabase()

* mock getDatabaseClient

* removed unused mock-env

* formatting

* removed unused collections from schema

* response => responseOnce

* more direct

* unused var

* more tests please!

* test for: createOne no permissions

* removed broken test for now

* clean up

* readOne tests what does into db and returned

* added bindings check

* added into db sql check

* moved tests outside src

* changed ts config

* cli test location changed

* removed looking for tests in src

* readding it for e2e tests? Seems fishy

* Integration tests for ItemsService user tables (#11208)

* renamed ItemsService test to match src file name

* add user table schema

* system/user tables use .each, formatting needed

* format system and user better in title

* tables/table=> schemas/schema

* filter _eq test passing

* comment for later and formatting

* everything in it's right place

* future proofing as more fields are added

* removed duplicate test

* formatting

* readMany() filter: _or

Co-authored-by: Jay Cammarano <jaycammarano@gmail.com>

* added knex check before getDatabase()

* Move util test to tests folder

Co-authored-by: Jay Cammarano <jaycammarano@gmail.com>
Co-authored-by: rijkvanzanten <rijkvanzanten@me.com>
2022-01-24 19:55:08 +00:00