|
@@ -23,20 +23,26 @@
|
|
| 23 |
assert.ok(service, 'Registered the service');
|
| 24 |
});
|
| 25 |
|
| 26 |
-
it
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
|
| 32 |
-
|
| 33 |
-
|
|
|
|
| 34 |
|
| 35 |
-
|
|
|
|
|
|
|
| 36 |
|
| 37 |
-
|
|
|
|
|
|
|
|
|
|
| 38 |
|
| 39 |
-
|
| 40 |
-
|
| 41 |
});
|
| 42 |
});
|
| 23 |
assert.ok(service, 'Registered the service');
|
| 24 |
});
|
| 25 |
|
| 26 |
+
it('creates a user and encrypts the password ', async () => {
|
| 27 |
+
const user = await app.service('users').create({
|
| 28 |
+
email: 'test@example.com',
|
| 29 |
+
password: 'secret'
|
| 30 |
+
});
|
| 31 |
|
| 32 |
+
// Makes sure the password got encrypted
|
| 33 |
+
assert.ok(user.password !== 'secret');
|
| 34 |
+
});
|
| 35 |
|
| 36 |
+
it('removes password for external requests', async () => {
|
| 37 |
+
// Setting `provider` indicates an external request
|
| 38 |
+
const params = { provider: 'rest' };
|
| 39 |
|
| 40 |
+
const user = await app.service('users').create({
|
| 41 |
+
email: 'test2@example.com',
|
| 42 |
+
password: 'secret'
|
| 43 |
+
}, params);
|
| 44 |
|
| 45 |
+
// Make sure password has been removed
|
| 46 |
+
assert.ok(!user.password);
|
| 47 |
});
|
| 48 |
});
|