You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[Parse Server Configuration](#parse-server-configuration)
20
22
-[Code of Conduct](#code-of-conduct)
@@ -84,6 +86,14 @@ Once you have babel running in watch mode, you can start making changes to parse
84
86
* All the tests should point to sources in the `lib/` folder.
85
87
* The `lib/` folder is produced by `babel` using either the `npm run build`, `npm run watch`, or the `npm run prepare` step.
86
88
* The `npm run prepare` step is automatically invoked when your package depends on forked parse-server installed via git for example using `npm install --save git+https://github.com/[username]/parse-server#[branch/commit]`.
89
+
* The tests are run against a single server instance. You can change the server configurations using `await reconfigureServer({ ... some configuration })` found in `spec/helper.js`.
90
+
* The tests are ran at random.
91
+
* Caches and Configurations are reset after every test.
92
+
* Users are logged out after every test.
93
+
* Cloud Code hooks are removed after every test.
94
+
* Database is deleted after every test (indexes are not removed for speed)
95
+
* Tests are located in the `spec` folder
96
+
* For better test reporting enable `PARSE_SERVER_LOG_LEVEL=debug`
87
97
88
98
### Troubleshooting
89
99
@@ -108,13 +118,14 @@ Once you have babel running in watch mode, you can start making changes to parse
108
118
* Run the tests for the whole project to make sure the code passes all tests. This can be done by running the test command for a single file but removing the test file argument. The results can be seen at *<PROJECT_ROOT>/coverage/lcov-report/index.html*.
109
119
* Lint your code by running `npm run lint` to make sure the code is not going to be rejected by the CI.
110
120
***Do not** publish the *lib* folder.
121
+
* Mocks belong in the `spec/support` folder.
111
122
* Please consider if any changes to the [docs](http://docs.parseplatform.org) are needed or add additional sections in the case of an enhancement or feature.
112
123
113
124
### Test against Postgres
114
125
115
126
If your pull request introduces a change that may affect the storage or retrieval of objects, you may want to make sure it plays nice with Postgres.
116
127
117
-
* Run the tests against the postgres database with `PARSE_SERVER_TEST_DB=postgres PARSE_SERVER_TEST_DATABASE_URI=postgres://postgres:password@localhost:5432/parse_server_postgres_adapter_test_database npm run testonly`. You'll need to have postgres running on your machine and setup [appropriately](https://github.com/parse-community/parse-server/blob/master/.travis.yml#L43) or use [`Docker`](#run-a-parse-postgres-with-docker).
128
+
* Run the tests against the postgres database with `PARSE_SERVER_TEST_DB=postgres PARSE_SERVER_TEST_DATABASE_URI=postgres://postgres:password@localhost:5432/parse_server_postgres_adapter_test_database npm run testonly`. You'll need to have postgres running on your machine and setup [appropriately](https://github.com/parse-community/parse-server/blob/master/scripts/before_script_postgres.sh) or use [`Docker`](#run-a-parse-postgres-with-docker).
118
129
* The Postgres adapter has a special debugger that traces all the sql commands. You can enable it with setting the environment variable `PARSE_SERVER_LOG_LEVEL=debug`
119
130
* If your feature is intended to only work with MongoDB, you should disable PostgreSQL-specific tests with:
120
131
@@ -137,7 +148,7 @@ If your pull request introduces a change that may affect the storage or retrieva
137
148
[PostGIS images (select one with v2.2 or higher) on docker dashboard](https://hub.docker.com/r/postgis/postgis) is based off of the official [postgres](https://registry.hub.docker.com/_/postgres/) image and will work out-of-the-box (as long as you create a user with the necessary extensions for each of your Parse databases; see below). To launch the compatible Postgres instance, copy and paste the following line into your shell:
@@ -189,13 +200,61 @@ A security check needs to be added for every new feature or enhancement that all
189
200
190
201
For example, allowing public read and write to a class may be useful to simplify development but should be disallowed in a production environment.
191
202
192
-
Security checks are added in [SecurityChecks.js](https://github.com/parse-community/parse-server/blob/master/src/SecurityChecks.js).
203
+
Security checks are added in [CheckGroups](https://github.com/parse-community/parse-server/tree/master/src/Security/CheckGroups).
204
+
205
+
#### Add Security Check
206
+
Adding a new security check for your feature is easy and fast:
207
+
1. Look into [CheckGroups](https://github.com/parse-community/parse-server/tree/master/src/Security/CheckGroups) whether there is an existing `CheckGroup[Category].js` file for the category of check to add. For example, a check regarding the database connection is added to `CheckGroupDatabase.js`.
208
+
2. If you did not find a file, duplicate an existing file and replace the category name in `setName()` and the checks in `setChecks()`:
209
+
```js
210
+
classCheckGroupNewCategoryextendsCheckGroup {
211
+
setName() {
212
+
return'House';
213
+
}
214
+
setChecks() {
215
+
return [
216
+
newCheck({
217
+
title:'Door locked',
218
+
warning:'Anyone can enter your house.',
219
+
solution:'Lock the door.',
220
+
check: () => {
221
+
return; // Example of a passing check
222
+
}
223
+
}),
224
+
newCheck({
225
+
title:'Camera online',
226
+
warning:'Security camera is offline.',
227
+
solution:'Check the camera.',
228
+
check:async () => {
229
+
throw1; // Example of a failing check
230
+
}
231
+
}),
232
+
];
233
+
}
234
+
}
235
+
```
236
+
237
+
3. If you added a newfilein the previous step, reference the file in [CheckGroups.js](https://github.com/parse-community/parse-server/blob/master/src/Security/CheckGroups/CheckGroups.js), which is the collector of all security checks:
238
+
```
239
+
export { default as CheckGroupNewCategory } from './CheckGroupNewCategory';
240
+
```
241
+
4. Add a test that covers the newcheck to [SecurityCheckGroups.js](https://github.com/parse-community/parse-server/blob/master/spec/SecurityCheckGroups.js) for the cases of success and failure.
242
+
243
+
#### Wording Guideline
244
+
Consider the following when adding a newsecurity check:
245
+
-*Group.name*: The category name; ends without period as this is a headline.
246
+
-*Check.title*: Is the positive hypothesis that should be checked, for example "Door locked" instead of"Door unlocked"; ends without period as this is a title.
247
+
-*Check.warning*: The warning if the test fails; ends with period as this is a description.
248
+
-*Check.solution*: The recommended solution if the test fails; ends with period as this is an instruction.
249
+
- The wordings must not contain any sensitive information such as keys, as the security report may be exposed in logs.
250
+
- The wordings should be concise and not contain verbose explanations, for example "Door locked" instead of"Door has been locked securely".
251
+
- Do not use pronouns such as "you" or "your" because log files can have various readers with different roles. Do not use pronouns such as "I" or "me" because although we love it dearly, Parse Server is not a human.
193
252
194
253
### Parse Error
195
254
196
255
Introducing newParse Errors requires the following steps:
197
256
198
-
1. Research whether an existing Parse Error already covers the error scenario. Keep in mind that reusing an already existing Parse Error does not allow to distinguish between scenarios in which the same error is thrown, so it may be necessary to add a new and more specific Parse Error, eventhough an more general Parse Error already exists.
257
+
1. Research whether an existing Parse Error already covers the error scenario. Keepin mind that reusing an already existing Parse Error does not allow to distinguish between scenarios in which the same error is thrown, so it may be necessary to add a newand more specific Parse Error, even though a more general Parse Error already exists.
199
258
⚠️ Currently (as of Dec. 2020), there are inconsistencies between the Parse Errors documented in the Parse Guides, coded in the Parse JSSDK and coded in Parse Server, therefore research regarding the availability of error codes has to be conducted in all of these sources.
200
259
1. Add the newParseError to [/src/ParseError.js](https://github.com/parse-community/Parse-SDK-JS/blob/master/src/ParseError.js) in the Parse JavaScript SDK. This is the primary reference for Parse Errors for the Parse JavaScript SDK and Parse Server.
201
260
1. Create a pull request for the Parse JavaScript SDK including the newParseErrors. ThePR needs to be merged and a newParseJSSDK version needs to be released.
0 commit comments