Commit Graph

740 Commits

Author SHA1 Message Date
marvelm
6f1fe89948 Relative time queries (#4289)
* Add relative time queries

* Encode successful result

* Add integration test

* Add more error cases

* Remove unnecessary new Date

* Error when time has both 'in' and 'ago'

* naturalTimeToDate -> relativeTimeToDate

* Add $relativeTime operator

* Throw error if $relativeTime is invalid

* Add integration test for invalid relative time

* Exclude $exists query

* Only run integration tests on MongoDB

* Add it_only_db test helper
bd2ea87c1d/CONTRIBUTING.md (L23)

* Handle where val might be null or undefined

* Add integration test for multiple results

* Lowercase text before processing

* Always past if not future

* Precompute seconds multiplication

* Add shorthand for interval
hr, hrs
min, mins
sec, secs

* Throw error if $relativeTime is used with $exists, $ne, and $eq

* Improve coverage for relativeTimeToDate

* Add test for erroring on floating point units

* Remove unnecessary dropDatabase function

* Unit test $ne, $exists, $eq

* Verify field type

* Fix unit test for $exists
Unnest query object
2017-10-26 16:23:27 -04:00
Florent Vilmart
1dd58b7527 Adds support for read-only masterKey (#4297)
* Adds support for read-only masterKey

* Adds tests to make sure all endpoints are properly protected

* Updates readme

* nits
2017-10-26 15:35:07 -04:00
Benjamin Wilson Friedman
87b79cedfa Handle possible afterSave exception (#4293)
* capture and log exceptions caused by afterFind

* Wording

* Consolidated promise chaining

* use logger instead of console
2017-10-26 14:28:13 -04:00
marvelm
8a23c00265 Add support for expiration interval in Push (#4202)
* Add support for expiration_interval in Push

* Support expiration_interval for immediate pushes

* Test

* Add 'expiration_interval' to _PushStatus class

* Fix coverage
2017-10-25 17:30:20 -04:00
Florent Vilmart
72888bc539 Adds ability to login with email when specifying it (#4276)
* Adds ability to login with email when specifying it

* Adds tests for corner cases

* nits
2017-10-24 17:50:48 -04:00
Benjamin Wilson Friedman
0db858b04c Enables login over POST in addition to GET (#4268)
* Enables login over POST in addition to GET

* Removes explcit method:POST as rp.post does this naturally
2017-10-24 15:47:26 -04:00
Florent Vilmart
9de4b8b2a7 Refactors configuration management (#4271)
* Adds flow types / Configuration interfaces

* Lets call it options

* Use a single interface to generate the configurations

* Translates options to definitions only if comments are set

* improves logic

* Moves objects around

* Fixes issue affecting logging of circular objects

* fixes undefined env

* Moves all defaults to defaults

* Adds back CLI defaults

* Restored defaults in commander.js

* Merge provided defaults and platform defaults

* Addresses visual nits

* Improves Config.js code

* Adds ability to pass the default value in trailing comments

* Load platform defaults from the definitions file

* proper default values on various options

* Adds ParseServer.start and server.start(options) as quick startup methods

* Moves creating liveQueryServer http into ParseServer.js

* removes dead code

* Adds tests to guarantee we can start a LQ Server from main module

* Fixes incorrect code regading liveQuery init port

* Start a http server for LQ if port is specified

* ensure we dont fail if config.port is not set

* Specify port

* ignore other path skipped in tests

* Adds test for custom middleware setting

* Refactors new Config into Config.get

- Hides AppCache from ParseServer.js, use Config.put which validates

* Extracts controller creation into Controllers/index.js

- This makes the ParseServer init way simpler

* Move serverURL inference into ParseServer

* review nits
2017-10-23 08:43:05 -04:00
Florent Vilmart
e4eeadd4c6 Bumps parse sdk 1.10.1 (#4274)
* Fail test case for Issue#3999

* no message

* Bumps Parse to 1.10.1

Updates Polygon test suite to leverage latest version
2017-10-21 16:03:24 -04:00
Gustav Ahlberg
70ad9e9ffd Add request ip to request object (#4265)
* add the client ip to the request config object

* add the config ip to the trigger request object

* add the config ip to the functions request object

* add tests

* remove log

* remove log
2017-10-18 08:13:09 -04:00
Benjamin Wilson Friedman
9376b4d04a Validate serverURL on Start (#4204)
* Added basic validation of publicServerURL

* Fixed up 'verifyServerUrl' and added tests

* Use Parse.serverURL instead, general cleanup.

* Test server port moved to 13376

* Removed reconfigureServer calls with simple changing of Parse.serverURL

* changed var to const

* Disabled automatic serverURL verification during testing, moved verification call into app.on('mount') callback, removed setTimeout from verification.
2017-10-17 14:49:28 -04:00
Benjamin Wilson Friedman
315d30b426 Fix for beforeSave with increment causing key to be Dropped (#4259)
* Fixes an issue where a beforeSave hook could cause a numeric val to be dropped in response.

* Use hasOwnProperty to check instead

* Remove redundant set
2017-10-15 21:15:30 -07:00
Benjamin Wilson Friedman
9145c88562 Corrected outdated links (#4254) 2017-10-12 22:40:47 -04:00
Florent Vilmart
7fac070435 Allow queries with String array for pointers containedIn (#4188)
* Adds basic failing test

* Adds ability to use [objectId] for $in/$nin pointers

* makes sure to use a set field

* Makes sure field is defined
2017-10-03 13:50:39 -04:00
Florent Vilmart
2a168936fc Adds support for pointer/string pointers comparison in LiveQuery (#4231)
* Adds support for pointer/string pointers comparison in LiveQuery

* nits

* Makes sure needed is set

* Update QueryTools.js

* Update QueryTools.js
2017-10-03 13:50:20 -04:00
Chris Norris
23bffc8883 Add maxLimit server configuration (#4048)
* Add maxLimit server configuration

* Fix maxlimit validation logic to correctly handle maxLimit:0 case
2017-10-02 09:23:09 -04:00
Florent Vilmart
b703ec8a79 Fix for #4194 - me no likey much (#4198)
* Adds failing test for #4194

* Use the rest module instad of the Parse._request

- Some users have an invalid serverUrl passed in the options

* removes console.logs, fixes tests that leveraged Parse._request
2017-09-22 12:05:06 -04:00
Diamond Lewis
9371958a09 Postgres: Properly handle undefined field values (#4186)
Prevents `UnhandledPromiseRejectionWarning: Unhandled promise rejection` when building queries.
2017-09-19 07:59:48 -04:00
Anthony Mosca
cf630ba462 Updating with two GeoPoints fails correctly. (#4162) 2017-09-19 07:12:40 -04:00
marvelm
07ae85eef0 Prefix default push channel with applicationId (#4182) 2017-09-18 15:25:03 -04:00
Florent Vilmart
a5ce9fc175 Refactor pushStatusHandler to use Parse instead of direct access (#4173)
* Refactors pushStatusHandler to use HTTP interface so we can bind CloudCode hooks

* Handle correctly nested dot atomic operations

* Better handling of restricted class names, add support for afterSave _PushStatus

* Adds simple testing for afterSave(PushStatus)

* Reverts jobStatusHandler

* Addresses fixes

* adds delays to all methods
2017-09-18 15:01:07 -04:00
Florent Vilmart
a39d045c7d Fixes issue #4150: Session management (#4152)
* Adds tests

* Provide fix

* Fix post sessions (#4167)

* add tests

* provide fix

* remove console.log
2017-09-18 14:53:11 -04:00
Florent Vilmart
8d8a8b250e Fixes issue affecting liveQuery on location null/undefined values (#4171) 2017-09-17 11:57:11 +03:00
Florent Vilmart
d0184f438d Live Query basic monitoring (#4168)
* Adds uuid based client identification to prevent overflows

* no-super

* Adds cloud code monitoring

* fixes test

* nit
2017-09-15 17:20:51 -04:00
Florent Vilmart
d598d73f36 Adds ability to track sent/failed PerUTCOffset in the PushWorker (#4158)
* Adds ability to track sent/failed PerUTCOffset in the PushWorker

- for scheduled push notifications at a certain time, it helps keep track of the state

* Makes sure we track it all correctly

* Adds to Postgres
2017-09-13 17:28:20 -04:00
Florent Vilmart
3a17904ce8 Push: Cleanup invalid device tokens (#4149)
* Adds collecting invalid / expired device tokens from GCM / APNS

* Cleanup invalid installations based on responses from the adapters

* Adds test for cleanup

* Adds tests for removal
2017-09-12 14:53:05 -04:00
Anthony Mosca
4dce3bd63c Add support for more audience fields. (#4145)
* Add support for more audience fields.

* Only update audience when defined audience_id.
2017-09-11 22:06:21 -04:00
Florent Vilmart
a660a0c25f fix: Issue #4142 (#4144)
* Tweaks test in order to show the error

- Session is effectively created when it should not

* Do not create a session when users need verified accounts on signup
2017-09-11 11:07:39 -04:00
Florent Vilmart
839a117246 Fixes #2885 duplicate sessions (#4143)
* Adds test to repro the issue

* Improved test

* Destroy duplicate sessions for User/Installation-id pair

- Sessions will also be created with action login instead of signup when using 3rd party auth
2017-09-11 09:52:18 -04:00
marvelm
bc3cef2cd9 Support local time for scheduled pushes (#4137)
* Handle local push time

* PR feedback

* Improve timezone detection with regex

* Use indexOf instead of endsWith

* Add documentation

* Add end to end test for scheduled pushes in local time

* Revert changes to npm-git script

* clean up
2017-09-11 09:31:46 -04:00
Florent Vilmart
0f840b6bb8 Fix/issue pointer permissions (#4141)
* Makes sure we don't override roles

* Reduces the query size whith pointer permissions

- Does not return as $and if not needed
- Returns just the query with the additional constraint

* Do not use $in if include is just of length 1
2017-09-09 14:02:07 -04:00
Antonio Davi Macedo Coelho de Castro
019f9e55e1 Fix(MongoTransform): Ignore Audience legacy fields (#4018) 2017-09-09 13:27:54 -04:00
Jeremy May
121d151af9 Add master key override to live query ACL checks (#4133)
* Add master key override to live query ACL checks

* Fix mockClient so masterKey tests work correctly
2017-09-09 13:26:18 -04:00
Florent Vilmart
139b9e1cb3 Finding areas that are untested and need love (#4131)
* Makes InstallationRouter like others

* Adds testing for Range file requests

- Fixes issue with small requests (0-2)

* Revert "Makes InstallationRouter like others"

This reverts commit e2d2a16ebf2757db6138c7b5b33c97c56c69ead6.

* Better handling of errors in FilesRouter

* Fix incorrectness in range requests

* Better/simpler logic

* Only on mongo at it requires Gridstore

* Open file streaming to all adapters supporting it

* Improves coverage of parsers

* Ensures depreciation warning is effective

* Removes unused function

* de-duplicate logic

* Removes necessity of overriding req.params.className on subclasses routers

* Use babel-preset-env to ensure min-version compatible code

* removes dead code

* Leverage indexes in order to infer which field is duplicated upon signup

- A note mentioned that it would be possible to leverage using the indexes on username/email to infer which is duplicated

* Small nit

* Better template to match column name

* Restores original implementation for safety

* nits
2017-09-05 17:51:11 -04:00
Florent Vilmart
3079270b3e Optimizations (#4135)
* removes costly json serialization to InMemoryCacheAdapter

* Always cache a copy of the array

* Use own mapValues

* Makes sure we dont make unnecessary calls to the logger

* Do not bypass loggers with silent logging (only applies to stdout)

* warn is not warning

* use ===

* Wrap logRequest / logResponse in the loggerController for more granular control

Also give the ability to pass functions to the logger so we don't serialize too early in JSON (costly)

* reconfiguring winston would override the transports levels and make subsequent tests fail
2017-09-04 20:47:49 -04:00
Diamond Lewis
5aafc93476 Text Index Support (#4081)
* add text index support

* additional validation

* multiple text index error

* rename function

* Delete text indexes message
2017-09-02 12:31:19 -04:00
Florent Vilmart
6df944704c Adds support for localized push notification in push payload (#4129)
* Adds support for localized push data keys

- passign alert-[lang|locale] or title-[lang|locale] will inject the
  proper locale on the push body based on the installation

* Better handling of the default cases

* Updates changelog

* nits

* nits
2017-09-01 15:22:02 -04:00
Florent Vilmart
2e1ba66fd2 Fix/user update issue (#4123)
* Adds failing test,

the _User object is not updated as soon as you pass some authData part of the PUT

* Do not run the DB call when updating the user with new auth data, just part of the rest
2017-08-29 16:34:59 -04:00
Arthur Cinader
a103871cbc fix some typos. (#4112)
* fix some typos.

* more typos....
2017-08-29 14:20:51 -04:00
Florent Vilmart
ea67d23ef4 Improvements for sending push performance (#4122)
* Adds test for stalled pushStatus when audience is empty

* fixup! Adds test for stalled pushStatus when audience is empty

* Do not enqueue when count is 0, enforce deviceToken exists, stop badge ordering
2017-08-29 11:47:01 -04:00
Diamond Lewis
c6546218f4 PG: Support for nested contains and containedIn (#4109) 2017-08-23 11:33:57 -04:00
Florent Vilmart
92d51def6b Fixes issue affecting linking users to a 3rd party auth (#4047)
* Fixes issue affecting linking users to a 3rd party auth

* Fixes problematic test

* Better fix

* nits
2017-07-25 15:26:34 -04:00
Worathiti Manosroi
7e54265f6d Security: limit Masterkey remote access (#4017)
* update choose_password to have the confirmation

* add comment mark

* First version, no test

* throw error right away instead of just use masterKey false

* fix the logic

* move it up before the masterKey check

* adding some test

* typo

* remove the choose_password

* newline

* add cli options

* remove trailing space

* handle  in case the server is behind proxy

* add getting the first ip in the ip list of xff

* sanity check the ip in config if it is a valid ip address

* split ip extraction to another function

* trailing spaces
2017-07-23 12:26:30 -04:00
Diamond Lewis
811d8b0c7a pg support for null in containedAll (#4026) 2017-07-23 12:11:02 -04:00
Miguel Serrano
3c79cae1b2 feat: add request headers to trigger functions (#4012)
* add request headers to trigger functions

* reverse changes

* add headers in request config and trigger request
2017-07-14 13:19:00 -04:00
Diamond Lewis
e6cc8204b3 Add Polygon Type To Schema / PolygonContain to Query (#3944)
* Added type polygon to schema

* refactoring and more tests

* fix tests

* update test and transform

* add support for polygonContains

* fix transform.mongoObjectToParseObject test

* add indexes for polygon

* index test

* postgres test fix

* remove invalid loop test

* add invalid loop test

* nit
2017-07-11 23:33:45 -04:00
Florent Vilmart
ad52ed64af Lets increment/set badges on all _Installations (#3970)
* Lets increment/set badges on all _Installations

* Makes sure PG update where query is properly formed with empty query
2017-07-03 10:16:04 -04:00
Florent Vilmart
f42ccba5b1 fix(package): update pg-promise to version 6.3.0 (#3982)
* fix(package): update pg-promise to version 6.3.0

Closes #3954

* Restores PG adapter after tests that close the connection

* investigation

* Use isolated parse-server to not impeed on other specs

* Update PostgresInitOptions.spec.js
2017-07-02 14:29:54 -04:00
greenkeeper[bot]
d8a257d951 Update parse-server-push-adapter to the latest version 🚀 (#3983)
* fix(package): update parse-server-push-adapter to version 2.0.0

* Update helper.js

* default push config to android as ios is pickier
2017-07-01 23:34:47 -04:00
Steven Shipton
51d2dd92cb Add config for objectId size (#3950)
* Add objectId config property, default to 10

* Update Config constructor

* Add test for backwards compatibility when changing objectId size
2017-06-27 13:22:43 +03:00
Antonio Davi Macedo Coelho de Castro
b6298feaa7 Read preference option per query (#3865) 2017-06-21 23:18:10 +03:00