-
-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tests: improve coverage #156
Open
jankapunkt
wants to merge
12
commits into
master
Choose a base branch
from
tests/improve-coverage
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
4434ca6
tests: add test skeletons for completely uncovered files
jankapunkt 9fa19fe
tests: coverage improved to overall 66%
jankapunkt 63668bf
fix: prettier lint fix
jankapunkt b5b1f23
tests: cover basic Meteor Methods and Publications
jankapunkt a52ff95
tests: Meteor publication handle tests added
jankapunkt 0d5923c
tests: Data endpoint test fixed
jankapunkt a970f2f
fix: prettier fix lint errors
jankapunkt 144fc4f
Merge branch 'master' into tests/improve-coverage
jankapunkt 49d3213
fix(tests): Data.ddp connection tests fixed
jankapunkt 6bf74c4
deps: bump versions and remove unused packages
jankapunkt 95eaa60
tests: coverage for Accounts.js
jankapunkt a89590d
tests: add coverage to User.js
jankapunkt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
import { Collection } from './Collection'; | ||
|
||
const Mongo = { Collection }; | ||
|
||
/** | ||
* Mongo namespace, contains only Mongo.Collection | ||
* @namespace Mongo | ||
* @see Collection | ||
*/ | ||
export default { | ||
Collection, | ||
}; | ||
export default Mongo; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,18 +11,30 @@ import Meteor from '../Meteor.js'; | |
* @class | ||
* @see https://docs.meteor.com/api/accounts | ||
* @see https://docs.meteor.com/api/passwords | ||
* @see https://github.com/meteor/meteor/blob/devel/packages/accounts-password/password_client.js | ||
*/ | ||
class AccountsPassword { | ||
_hashPassword = hashPassword; | ||
|
||
/** | ||
* | ||
* @param options {object} | ||
* @param options.username {string=} username is optional, if an email is given | ||
* @param options.email {string=} email is optional, if a username is given | ||
* @param callback {function(e:Error)=} optional callback that is invoked with one optional error argument | ||
* Create a new user. | ||
* @param {Object} options | ||
* @param {String} options.username A unique name for this user. | ||
* @param {String} options.email The user's email address. | ||
* @param {String} options.password The user's password. This is __not__ sent in plain text over the wire. | ||
* @param {Object} options.profile The user's profile, typically including the `name` field. | ||
* @param {Function} [callback] Client only, optional callback. Called with no arguments on success, or with a single `Error` argument on failure. | ||
*/ | ||
createUser = (options, callback = () => {}) => { | ||
options = { ...options }; | ||
|
||
if (typeof options.password !== 'string') { | ||
throw new Error('options.password must be a string'); | ||
} | ||
if (!options.password) { | ||
return callback(new Error('Password may not be empty')); | ||
} | ||
|
||
// Replace password with the hashed password. | ||
options.password = hashPassword(options.password); | ||
|
||
|
@@ -44,20 +56,23 @@ class AccountsPassword { | |
* @param callback {function(e:Error)=} optional callback that is invoked with one optional error argument | ||
*/ | ||
changePassword = (oldPassword, newPassword, callback = () => {}) => { | ||
//TODO check Meteor.user() to prevent if not logged | ||
if (!User.user()) { | ||
return callback(new Error('Must be logged in to change password')); | ||
} | ||
|
||
if (typeof newPassword != 'string' || !newPassword) { | ||
// TODO make callback(new Error(...)) instead | ||
return callback('Password may not be empty'); | ||
if (!(typeof newPassword === 'string' || newPassword instanceof String)) { | ||
return callback(new Error('Password must be a string')); | ||
} | ||
|
||
if (!newPassword) { | ||
return callback(new Error('Password may not be empty')); | ||
} | ||
|
||
call( | ||
'changePassword', | ||
oldPassword ? hashPassword(oldPassword) : null, | ||
hashPassword(newPassword), | ||
(err, res) => { | ||
callback(err); | ||
} | ||
callback | ||
); | ||
}; | ||
|
||
|
@@ -69,17 +84,10 @@ class AccountsPassword { | |
*/ | ||
forgotPassword = (options, callback = () => {}) => { | ||
if (!options.email) { | ||
// TODO check this! I doubt it's implemented on the server | ||
// to let the client decide which email to use. | ||
// The only valid scenario is, when users have multiple emails | ||
// but even then the prop should be optional as not ever user | ||
// will have multiple emails | ||
return callback('Must pass options.email'); | ||
return callback(new Error('Must pass options.email')); | ||
} | ||
|
||
call('forgotPassword', options, (err) => { | ||
callback(err); | ||
}); | ||
call('forgotPassword', options, callback); | ||
}; | ||
|
||
/** | ||
|
@@ -90,8 +98,16 @@ class AccountsPassword { | |
* @param callback {function(e:Error)=} optional callback that is invoked with one optional error argument | ||
*/ | ||
resetPassword = (token, newPassword, callback = () => {}) => { | ||
if (!(typeof token === 'string' || token instanceof String)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is the type checking different from e.g the |
||
return callback(new Error('Token must be a string')); | ||
} | ||
|
||
if (!(typeof newPassword === 'string' || newPassword instanceof String)) { | ||
return callback(new Error('Password must be a string')); | ||
} | ||
|
||
if (!newPassword) { | ||
return callback('Must pass a new password'); | ||
return callback(new Error('Password may not be empty')); | ||
} | ||
|
||
call('resetPassword', token, hashPassword(newPassword), (err, result) => { | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it really hashed here? Had a look at Meteors
password_server.js
, looks like the newPassword is hashed on the server sideThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok got it, it sending the object with the sha256 hash, not the string.