Commit Graph

736 Commits

Author SHA1 Message Date
Tom J
2aa14adf87 Only allow basic auth credentials with a known appId (#2574)
* Only allow basic auth credentials with a known appId

* Update middlewares.js

* Updating basic auth tests to use valid appId
2016-08-25 13:04:23 -04:00
Nurdaulet
8eafe45664 vk.com provider registered (#2579)
* vk.com auth data manager implemented

* vk.com provider registered

* Removed all the unnecessary changes

* Revert "Removed all the unnecessary changes"

This reverts commit 7dec6297421045c149aa49e4b888a02c38b96f9e.

* Revert "vk.com provider registered"

This reverts commit 25705d3d1272e44d5c5801050adf8eafec95cd27.

* Reverted all the unnecessary changes

* vk.com auth manager bugs fixed
2016-08-25 13:03:48 -04:00
Florent Vilmart
9ab488b6a0 Postgres: $all, $and CLP and more (#2551)
* Adds passing tests

* Better containsAll implementation

* Full Geopoint support, fix inverted lat/lng

* Adds support for $and operator / PointerPermissions specs

* Fix issue updating CLPs on schema

* Extends query support

* Adds RestCreate to the specs

* Adds User specs

* Adds error handlers for failing tests

* nits

* Proper JSON update of AuthData

* fix for #1259 with PG

* Fix for Installations _PushStatus test

* Adds support for GlobalConfig

* Enables relations tests

* Exclude spec as legacy

* Makes corner case for 1 in GlobalConfig
2016-08-20 16:07:48 -04:00
Florent Vilmart
3a08ec9ce8 Adds bcrypt native binding for better login performance (#2549)
* Adds bcrypt native binding for better login performance

* Swaps bcrypt-nodejs for bcryptjs as compatible with bcrypt native

* Fixes package versions
2016-08-19 13:53:57 -07:00
Arthur Cinader
5f67caefde Make parse-server cloud code logging closer parse.com legacy (#2550)
* Make parse-server cloud code logging much to parse.com legacy. (fixes #2501)

1. More closely mimic the wording.  Include the user id.

2. Truncate input and result at 1k char.

3. Use more sensible metadata that would makes sense to index.  The guideline I used was: if it makes sense to filter on, put it in metadata.  If it makes sense to "free text" search on, then put it in the message.

  - file and console output, logging an object does not do what on might expect.  For example, logging a function's "params":

  ```
  expected:

    info: Ran cloud function aFunction for user qWHLVEsbEe with:
      Input: {"foo":"bar","bar":"baz"}
      Result: "it worked!" functionName=aFunction, params= { foo: "bar", "bar": baz }, user=qWHLVEsbEe

  what you actually get:

    info: Ran cloud function aFunction for user qWHLVEsbEe with:
      Input: {"foo":"bar","bar":"baz"}
      Result: "it worked!" functionName=aFunction, foo=bar, bar=baz, user=qWHLVEsbEe
  ```
  - logging highly variable metadata is pretty useless for indexing when logs are sent to a logging repository like elastic search.  In that use case, you want to index stuff you expect to filter on like user, hook type.

  - finally, putting the same input and result data in both the metadata and the message makes each message much larger with no additional value (that I know of anyway :).

4. Change some of the naming of functions in trigger.js to make future work easier.  I was confused about why there were three logging functions in trigger and it took me awhile to get that before hooks and after hooks are logged differently.  I just changed the names to make it obvious at first glance.

5. Add some try/catches to help any future futzers  see syntax errors, etc instead of just hanging.

Some log examples from unit test output:

```
info: Ran cloud function loggerTest for user YUD2os1i5B with:
  Input: {}
  Result: {} functionName=loggerTest, user=YUD2os1i5B

info: beforeSave triggered for MyObject for user nssehQ3wtz:
  Input: {}
  Result: {} className=MyObject, triggerType=beforeSave, user=nssehQ3wtz

info: afterSave triggered for MyObject for user XdznQgTD0p:
  Input: {"createdAt":"2016-08-19T01:11:31.249Z","updatedAt":"2016-08-19T01:11:31.249Z","objectId":"POoOOLL89U"} className=MyObject, triggerType=afterSave, user=XdznQgTD0p

error: beforeSave failed for MyObject for user 7JHqCZgnhf:
  Input: {}
  Error: {"code":141,"message":"uh oh!"} className=MyObject, triggerType=beforeSave, code=141, message=uh oh!, user=7JHqCZgnhf

info: Ran cloud function aFunction for user YR3nOoT3r9 with:
  Input: {"foo":"bar"}
  Result: "it worked!" functionName=aFunction, user=YR3nOoT3r9

error: Failed running cloud function aFunction for user Xm6NpOyuMC with:
  Input: {"foo":"bar"}
  Error: {"code":141,"message":"it failed!"} functionName=aFunction, code=141, message=it failed!, user=Xm6NpOyuMC

info: Ran cloud function aFunction for user CK1lvkmaLg with:
  Input: {"longString":"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus lobortis semper diam, ac euismod diam pharetra sed. Etiam eget efficitur neque. Proin nec diam mi. Sed ut purus dolor. Nulla nulla nibh, ornare vitae ornare et, scelerisque rutrum eros. Mauris venenatis tincidunt turpis a mollis. Donec gravida eget enim in luctus.\n\nSed porttitor commodo orci, ut pretium eros convallis eget. Curabitur pretium velit in odio dictum luctus. Vivamus ac tristique arcu, a semper tellus. Morbi euismod purus dapibus vestibulum sagittis. Nunc dapibus vehicula leo at scelerisque. Donec porta mauris quis nulla imperdiet consectetur. Curabitur sagittis eleifend arcu eget elementum. Aenean interdum tincidunt ornare. Pellentesque sit amet interdum tortor. Pellentesque blandit nisl eget euismod consequat. Etiam feugiat felis sit amet porta pulvinar. Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n\nNulla faucibus sem ipsum, at rhoncus diam pulvinar at. Vivamus consectetur, diam... (truncated)
  Result: {"longString":"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus lobortis semper diam, ac euismod diam pharetra sed. Etiam eget efficitur neque. Proin nec diam mi. Sed ut purus dolor. Nulla nulla nibh, ornare vitae ornare et, scelerisque rutrum eros. Mauris venenatis tincidunt turpis a mollis. Donec gravida eget enim in luctus.\n\nSed porttitor commodo orci, ut pretium eros convallis eget. Curabitur pretium velit in odio dictum luctus. Vivamus ac tristique arcu, a semper tellus. Morbi euismod purus dapibus vestibulum sagittis. Nunc dapibus vehicula leo at scelerisque. Donec porta mauris quis nulla imperdiet consectetur. Curabitur sagittis eleifend arcu eget elementum. Aenean interdum tincidunt ornare. Pellentesque sit amet interdum tortor. Pellentesque blandit nisl eget euismod consequat. Etiam feugiat felis sit amet porta pulvinar. Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n\nNulla faucibus sem ipsum, at rhoncus diam pulvinar at. Vivamus consectetur, diam... (truncated) functionName=aFunction, user=CK1lvkmaLg
```

* Implement PR comments:
- add back params to metadata and add back to the test
- use screaming snake case for conts

* fix typo
2016-08-19 16:39:51 -04:00
Florent Vilmart
9ecb9a3595 Postgres: Operations, Hooks, OAuth login, Files support (#2528)
* Adds files related tests through fs-adapter with PG

* Schema deletions implementations

* Adds Hooks spec

* Fix test

* Adds support for containsAll (numbers and strings)

* Better support for deleteFields and deleteClass

* Recursive JSON update for authData

* Adds node_modules to travis cache

* Disable temporarily to make tests pass

* Adds _perishable_token support for _User class

* ignore when a table creation fails at init (table exists)

* Adds support for AddUnique and Remove

* PG 9.4 compatible functions

* Re-enable tests

* nit

* Better handling of schema creation race
2016-08-18 18:05:26 -04:00
Marko Matić
3164b478ea Syncing afterSave/afterDelete trigger calls (Issue #2489) (#2499)
* Implemented syncing afterSave/afterDelete trigger calls with REST request execution flow (Issue 2489). After this change, afterSave and afterDelete triggers CAN return a promise, which needs to be resolved inside a trigger for REST request flow to continue. If trigger doesn't return a promise, request flow continues.

* Added {} to multiline if.

* Fixed bad commit.

* Fixed problem with beforeSave triggers becoming async.
2016-08-17 09:26:42 -04:00
Florent Vilmart
c0249283ac Advancements with postgres (#2510)
* Start DB runner from tests

* Connect GridstoreAdapter only when needed

* removes unused package

* better test errors reporting

* Adds support for __op.Delete

* Better test error reporting

* Makes sure all tests can run without crashing

* Use xdescribe to skip test suite

* Removes unused dependencies

* Let volatiles classes be created with PG on start

* Do not fail if class dont exist

* adds index.spec.js to the pg suite

* Use a new config each test to prevent side effects

* Enable EmailVerificationToken specs with pg

* Makes sure failure output is not cut

* Reduces number of ignored tests in ParseObject.spec

* Inspect reconfiguration errors

* Mark GlobalConfig is incompatible with PG

- Problem is with nested updates (param.prop = value)

* PG: Nested JSON queries and updates

- Adds support for nested json and . operator queries
- Adds debug support for PG adapter
- Adds loglevel support in helper

* Enable working specs in ParseUser

* Sets default logLevel in tests to undefined

* Adds File type support, retores purchaseValidation specs

* Adds support for updating jsonb objects

- Restores PushController tests

* Proper implementation of deleteByQuery and ORs

- Adds ParseInstallation spec to the test suite

* xit only failing tests

* Nit on ParseAPI spec

* add sorting operator

* properly bound order keys

* reverts describe_only_db behavior

* Enables passing tests

* Adds basic support for relations, upsertOneObject aliased to createObject

* progress on queries options

* Fix ACL update related problems

* Creates relation tables on class creation

* Adds Relation tests

* remove flaky tests

* use promises instead of CB

* disable flaky test

* nits

* Fixes on schema spec

- Next thing is to implemenet geopoint and files correctly

* fix failues

* Basic GeoPoint support

* Adds support for $nearSphere/$maxDistance geopoint queries

* enable passing tests

* drop tables afterEach for PG, clean up relation tables too

* Better initialization/dropTables
2016-08-15 16:48:39 -04:00
Florent Vilmart
2f1ee2186b Makes sure _acl is set as empty {} (#2495)
* regression test for #2465

* Makes sure _acl is set when locked down

- Fixes #2465
2016-08-12 13:15:55 -07:00
Andrew Lane
80de86c8ae Implement Janrain Capture and Janrain Engage auth provider (#2436)
* Janrain engage auth provider
* Modeled after the existing providers in /src/authDataManager/ and also after https://github.com/janrain/Janrain-Sample-Code/blob/master/widget-examples/server.js
* See also: http://developers.janrain.com/overview/social-login/identity-providers/user-profile-data/#normalized-user-profile-data

* Janrain capture auth provider
* Modeled after the existing providers in /src/authDataManager/
* See also: https://docs.janrain.com/api/registration/entity/#entity

* Janrain engage auth provider
* Modeled after the existing providers in /src/authDataManager/ and also after https://github.com/janrain/Janrain-Sample-Code/blob/master/widget-examples/server.js
* See also: http://developers.janrain.com/overview/social-login/identity-providers/user-profile-data/#normalized-user-profile-data

* Janrain capture auth provider
* Modeled after the existing providers in /src/authDataManager/
* See also: https://docs.janrain.com/api/registration/entity/#entity

* Adding missing newlines at EOF
2016-08-12 13:34:24 -04:00
Florent Vilmart
a5a172918e Refactor logging to provide common logger from LoggerAdapter (#2478)
* Refactor logging to provide common logger from LoggerAdapter

Move logger logic de WinstonLoggerAdapter

Further improvements in configuration

Use logger instead of getLogger

- Removes PLog module

Reverts name changes

nits

* Adds additional logging levels as requirements

* Adds tests for logging configuration

* removes flaky test

* investigate...

* further investigation

* Adds silent option to disable console output

* Restores logs with VERBOSE in tests

* Expose controller instead of adapter, reduces method requirements for adapter

* Shuffles initializations around

* Fix doc

* Load cloudCode last to make sure the logger is available

* Adds test to make sure we can load an adapter from npm module

* extract defaults

* Adds defaultMongoURI to defaults

* fix defaults values

* Proper error for PG failures

* Disable flaky test
2016-08-12 10:25:24 -07:00
CongHoang
6e0a25dea0 fix export Bytes data type to JSON (#2409) 2016-08-09 12:05:46 -04:00
Antoine Lenoir
452887bd05 Change pushHash with stringified data (#2397)
* Change pushHash with stringify data

* stringify data.alert for pushHash

* stringify data.alert if object for pushHash

* test push notification when data.alert is an object
2016-08-09 12:00:56 -04:00
Florent Vilmart
fc3ebd0bd0 Style improvements (#2475)
* HooksRouter is enabled by default

* Adds middleswares on PromiseRouter, fixes #2410

* Move testing line to helper

* Modernize middlewares.js

* Moves DB uniqueness initialization to DBController, modernize

* Moves testing related code to spec folder

* remove unused _removeHook function

* Adds tests, docs for Analytics and improvements

* nit

* moves back TestUtils
2016-08-07 20:02:53 -07:00
Drew
ae36200d1f Disable tests that don't work in Postgres, and don't start a mongo for postgres tests (#2481)
* Disable tests that don't work in Postgres, and don't start a mongo for postgres tests

* Remove unnecessary chages

* remove more unnecessary chagnes
2016-08-07 22:21:01 -04:00
Jeremy Louie
f27dff0ae6 Handle queries with equalTo on objectId and relation conditions (#2472)
* Add test for notEqualTo on relation with equalTo on objectId

* Properly handles queries with equalTo on objectId and relation conditions

This is done by converting shorthand $eq condition to $eq condition instead of clobbering.
2016-08-07 18:58:32 -07:00
Arthur Cinader
fa736f1df7 Allow logger to add transports (#2363)
- Move all of the winston logic from FileLoggerAdapter to WinstonLoggerAdapter
- Export WinstonLoggerAdapter so it can be sublcassed
- Expost the ability to add adittional transports to logger
- Import FirehoseLoggerAdapter alongside other adapters so it can be configured.
2016-08-06 08:29:19 -04:00
sud
e4c2e65263 Non trivial before save pointer clobber (#2406)
* test case to check beforeSave changes clobbers fetched pointer fields
Basically if beforeSave makes any changes to the object it is trying to save, the fetched pointer fields on the client gets clobbered to only pointer.

* propogate only changed fields to response.
Earlier we were returning all fields even if any changes happened in beforeSave. This causes the fetched pointer fields on the client to get clobbered to only pointers.
This fix returns only the changed fields thus avoiding pointer clobber.

* The goal of this comparision seems to be checking that the all returns the user correctly.
Also it is consistent with the hosted parse that user.username not returned from PUT request.
2016-08-05 08:53:54 -04:00
Florent Vilmart
7964d0a999 Adds support for multiple twitter auths options (#2256)
* Adds support for multiple twitter auths options

* Adds user test
2016-07-23 12:02:45 -07:00
Florent Vilmart
c9fc80984a Makes sure we don't strip authData or session token from users using masterKey (#2348)
* Makes sure we don't strip auth data or session token from users queried with masterKey (#2342))

* nit: test title
2016-07-23 11:14:53 -07:00
Florent Vilmart
3b2da1d734 Cloud code logs (#2370)
* Adds logging (info/error) when running cloudCode triggers

* Adds logs for cloud-function calls

- Match parse.com original logging
2016-07-23 11:10:06 -07:00
Florent Vilmart
09bd9e3b2c Adds schema caching capabilities (5s by default) (#2286)
* Adds schema caching capabilities (off by default)

* Use InMemoryCacheAdapter

* Uses proper adapter to generate a cache

* Fix bugs when running disabled cache

* nits

* nits

* Use options object instead of boolean

* Imrpove concurrency of loadSchema

* Adds testing with SCHEMA_CACHE_ON

* Use CacheController instead of generator

- Makes caching SchemaCache use a generated prefix
- Makes clearing the SchemaCache clear only the cached schema keys
- Enable cache by default (ttl 5s)
2016-07-22 21:23:59 -07:00
Arthur Cinader
ac1f762f07 Fix minor typos in test names (#2351) 2016-07-20 12:32:18 -04:00
Florent Vilmart
dfac9725dd Update Mongodb client to 2.2.4 (#2329)
* chore(package): update mongodb to version 2.2.4

https://greenkeeper.io/

* fix for mongo 2.2.4

* Delete schema promise on error...

- Just because this way we can let the adapter an opportunity to yield a new error....
OR A SUCCESS

* Fixes test

* Restore fix
2016-07-19 21:40:01 -04:00
Florent Vilmart
8719afdc1b Parses correctly Parse.Files and Dates when sent to Cloud Code Functions (#2297)
* fix for #2294

* fail tests

* Makes sure dates are compatible with Parse.com CloudCode #2214

* Adds regression tests for #2204
2016-07-18 23:14:32 -07:00
Diwakar Cherukumilli
6f292059ba Adds ability to expire email verify token (#2216) 2016-07-18 23:10:36 -07:00
Florent Vilmart
033bc317e6 Report validation errors with correct error code (#2299) 2016-07-18 23:03:43 -07:00
Dan Huang
c81f48aae6 don't serve null authData values (#2320) 2016-07-18 23:00:16 -07:00
Florent Vilmart
025482ea1a Fix null relation problem (#2319)
* Add null check for relation type map.

For relations that are not explicitly defined in the schema, we need a null check here.

* Making change to force rebuild.

* Reverting change.

* Adds test
2016-07-18 22:58:37 -07:00
Florent Vilmart
f310e6678e Fix flaky tests (#2324)
* Fix flaky test (There were open connections to the server left after the test finished)

* fix test that's happening on the end of the minute

* remove focus testing
2016-07-18 21:43:34 -07:00
Sen Palanisami
7d234e054b Log objects rather than JSON strings and option for single line logs (#2028)
* Log objects rather than JSON strings and option for single line logs

This reverts commit fcd914bdfd.

* Better password stripping tests
2016-07-15 16:18:50 -04:00
Florent Vilmart
069275d3df Fix for #1840, Strip operations from results, forwards delete operations to SDKs (#1946)
* Adding a test demonstrating issue #1840.

* Fixes #1840

* Adds failing test with other use case

- That test fails on parse.com as well

* Bumps parse to 1.9.0

* exclude pg db

* Exclude pg on other test

* Adds clientSDK compatibility check for forward deletion

- Mark js1.9.0 as compatible

* Strips all operations from result

- fix for #1606
2016-07-15 09:24:53 -04:00
Florent Vilmart
9bf21ef093 Restores ability to include non pointer keys (#2263)
- Matches the behaviour on parse.com
- fixes #2262
2016-07-13 09:14:54 -04:00
Florent Vilmart
32f7230aca Creates a new sessionToken when updating password (#2266)
* Creates a new sessionToken when updating password

* Adds test ensuring email is properly sent when upgrading from anon
2016-07-13 07:18:24 -04:00
Nikita Lutsenko
18235352c4 Merge pull request #2259 from ParsePlatform/client-sdk-info
Exposes the ClientSDK infos if available
2016-07-12 11:17:52 -07:00
Greenkeeper
868ad5bdfd Update parse to version 1.9.0 🚀 (#2233)
* chore(package): update parse to version 1.9.0

https://greenkeeper.io/

* Removes Hooks client API as provided by node SDK
2016-07-12 10:09:16 -04:00
Florent Vilmart
2498a954ce Exposes clientSDK into RestQuery, RestWrite and rest 2016-07-12 10:06:13 -04:00
Florent Vilmart
a55466fde8 Fixes #2221: Nested Or queries (#2231)
* Adds repro for #2221

* Fixes nested or queries

* not for PG yet
2016-07-08 22:03:13 -07:00
Florent Vilmart
61aa5a8d62 Let auth data be updated on login (#2219)
* Let user update authData token upon login

* Adds tests that ensures linked authData isnt overriden

* fixes focused testing problem
2016-07-08 21:49:46 -07:00
Blayne Chard
8338783075 Adding more information to the permission denied error (#2210) 2016-07-07 11:30:29 -04:00
Tyler Brock
2f2ff377eb Better e-mail adapter testing (#2208) 2016-07-05 12:08:46 -07:00
Diwakar Cherukumilli
08c63f324a Adds ability to prevent login with unverified emails (#2175) 2016-07-04 13:56:35 -04:00
Steven Shipton
d1cdea00af Expose InMemoryCacheAdapter. Update tests (#2186) 2016-07-02 06:08:13 -07:00
Tyler Brock
799e59618c Stop requiring verifyUserEmails for password reset functionality (#2166) 2016-06-28 22:25:44 -04:00
David Keita
19080ed7e7 #506 fix: Deleting a file does not delete from fs.files (#1758)
* #506 fix: Deleting a file does not delete from fs.files

* test added to check that GridStoreAdapter deleteFile removes from fs.files and fs.chunks
2016-06-27 00:40:43 -04:00
Florent Vilmart
147b493e23 Results invalid session when providing an invalid session token (#2154)
* Results invalid session when providing an invalid session token

* Reverts unsafe loggers

* Fixes failing tests

- The tests were failin when run in sequence as we called done() before the JSSDK had a chance to register the session token, therefore having a proper logout call in afterEach
2016-06-26 23:20:02 -04:00
Hussam Moqhim
a861c4e506 Fix issue #2134: creating an anonymous user (#2155)
* fix issue #2134

* username is returned only when generated

* fix unit tests

* incorporate @flovilmart review
2016-06-26 23:19:37 -04:00
Florent Vilmart
3e413683f7 Makes HTTPResponse serializable (#2143)
* Use the callback body instead of response.body that may not be set

* Adds test to handle undefined responses

* Adds toJSON method to properly serialize HTTPResponse

* Use ES5 defineProperty to make keys enumerable

* removes body key from serialization

* Indent nits
2016-06-25 10:56:02 -07:00
Drew
006540cda5 Implement pointer types in postgres. (#2086)
* Support pointers in postgres

* implement count

* Fix bug in createClass
2016-06-17 11:09:42 -07:00
Drew
ab06055369 Postgres exclude failing tests (#2081)
* reload the right data

More passing postgres tests

Handle schema updates, and $in for non array columns

remove authdata from user and implement ensureUniqueness

Make some tests work, detect existing classes

Throw proper error for unique index violation

fix findOneAndUpdate

Support more types

support more type

Support boolean, fix _rperm/_wperm, add TODO

Support string types and also simplify tests

Move operator flattening into Parse Server and out of mongo adapters

Move authdata transform for create into Parse Server

Move authdata transforms completely in to Parse Server

Fix test setup

inline addSchema

Inject default schema to response from DB adapter

* Mark tests that don't work in Postgres

* Exclude one more test

* Exclude some more failing tests

* Exclude more tests
2016-06-17 12:59:16 -04:00