Commit Graph

23 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
ian
72a19477a7 Fix inconsistent revisions after batch update (#13250)
* Sort keys to ensure order

* Set query limit as the number of keys

* Add query limit only when reading by keys

* Update test

* Check if keys is of array type
2022-05-16 13:10:31 -04:00
Rijk van Zanten
a36c7eabeb Use json parser wrapper function to prevent pollution attacks (#13191) 2022-05-09 14:57:38 -04:00
Josh Soref
0b01923b0d Spelling (#13072) 2022-05-02 13:16:03 -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
Rijk van Zanten
d8b81f07c7 Throw 400 on file upload with missing filename (#12785)
Fixes #8101
2022-04-15 17:36:42 -04:00
Rijk van Zanten
e3f3d7e3b2 Throw payload error when using file upload without providing a file (#12682)
* Throw error on file upload if the number of uploaded files is 0

Fixes #12678

* Add unit test

* Mock env

* Fix mocks
2022-04-11 12:04:45 -04:00
ian
68066eccb7 Remove UTC conversion from date, time and datetime fields (#10956)
* Remove UTC conversion from date, time and datetime fields

* Fix mysql / maria timestamps when not in UTC timezone

* Add sequential tests with node timezone change

* Increase connection attempt check

* Add error catching in tests flow setup

* Check for server connectivity

* Fix promises

* Fix timestamp inconsistencies

* Revert to previously used parseISO

* Ensure database and directus connection

* Add another timezone to test positive and negative GMT

* Set local server hostname to localhost

* Add tests for SQLite

* Use notNullable primary key

* Revert connection testing sleep duration

* Fix nested transactions on SQLite

* Increase MSSQL request timeout

* Add type override flag for SQLite

* Remove commented code

* Add type override flags for Oracle

* Updated test file path

* Increase test servers launch timeout

* Increase test servers launch timeout

* Update format of tests

* Fix typo

* Increase test timeout for CockroachDB

* Add type overrides when creating fields through collections service

* Remove time field type conversion for Oracle

* Update collections list in test

* Remove check for time field in Oracle

* Add missing continue...

* Remove database override

* Add note for SQLite

* Rename flags and extract shared util

* Abstract remaining DB specific checks

* Revert flags renaming except renaming of test files

* Use date helper to add field flag

* Move field date typecasting upstream

* Use timestamp helper for date-created and date-updated

* Fix tests

* Remove unused vars

* Add tests for date-created

* Increase connection attempt count

* Fix test for mariadb

* Increase allowable difference to account for delays

* Add tests for date-updated

* Fix tests again for mariadb

* Add date helpers post merge

Co-authored-by: rijkvanzanten <rijkvanzanten@me.com>
2022-04-06 16:15:22 -04:00
ian
307cef8f5e Add permissions check for relational field only if child has filter (#12549)
* Add permissions check for relational field only if child has filter

* Allow id field for actions such as update and delete

* Use primary key instead of id

* Add test
2022-04-06 11:30:50 -04:00
Wryn (yage) Wagner
0930c2df97 Safe Metadata Upload (#12511)
* [Related to #11292] Safe Metadata Upload
- Created FILE_METADATA_ALLOWLIST
- Added test library for `FilesService`

* Rename ALLOWLIST->ALLOW_LIST to be consistent with other env vars

* Make sure it still works for files without Exif

* Prevent breaking changes in metadata formatting

* Allow * for all

* Fix md sup

Co-authored-by: rijkvanzanten <rijkvanzanten@me.com>
2022-04-04 20:43:56 -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
ian
8139b5b467 Fix filter permissions for relational fields (#12426)
* Fix filter permissions for relational fields

* Add tests for filtering of top level relational field with and without permissions on relational table

* Find read permission only

* Update test with more permissions
2022-04-01 14:20:44 -04:00
Rijk van Zanten
175fb849c4 Add field-level validation (#12363)
* Add field validation column

* Add frontend config for validation

* Make it work

* Add regex to filter configuration

* Fix const/let

* Add custom validation message support

* Add custom validation message tooltip inline

* Fix custom names in validation errors up top

* Fix type error

* Nog eentje om het af te leren

* resolve unused import warnings
2022-03-25 18:03:36 -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
ian
e2eb2801c5 Prefix existing field typecasting flags with "cast-" (#12141)
* Prefix typecasting field flags

* Fix payload test

* Update flags for system tables and for field creation in app

* Revert cast-hash and cast-uuid

* Rename migrations file to current date
2022-03-21 14:46:48 -04:00
ian
72180f7027 Add query filter validation with permissions (#12190)
* Add query filter validation with permissions

* Allow all fields in test

* Revert test and add check for permissions with empty fields

* Add check for deep filters

* Add tests

Co-authored-by: rijkvanzanten <rijkvanzanten@me.com>
2022-03-21 18:19:37 +00: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
ian
bc45dd5f05 Empty {} supersedes other permissions/validations in _OR merge (#11554)
* Empty {} supersedes other permissions/validations in _OR merge

* Add unit test

* Fix typo

* Add a different conditional filter for comparison
2022-02-28 12:03:24 -05:00
Azri Kahar
cb8b71f263 Remove unused variables for lint checks (#11319) 2022-01-28 12:52:29 +00:00
Jay Cammarano
d8c9257058 Bearer token no longer case sensitive for API authenticatiom (#11307)
* seemingly fixes issues/11300

* Add unit tests for extract-token

Co-authored-by: rijkvanzanten <rijkvanzanten@me.com>
2022-01-27 14:28:26 -05:00
Rijk van Zanten
7164dd8ae3 Return empty string as empty array in CSV type (#11256)
* Fix empty strings in CSV being returned wrong

Fixes #11194

* Add tests for CSV
2022-01-25 00:47:57 +00: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