-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
FIX: Invalid User Tests #944
Comments
@raymondfeng I need some help deciphering this test below, it looks like you were originally responsible for authoring it. The wrong Content-Type test fails when updated as suggested in the original ticket. it('Login a user over REST with the wrong Content-Type', function(done) {
request(app)
.post('/users/login')
.set('Content-Type', null)
.expect('Content-Type', /json/)
.expect(400)
.send(validCredentials)
.end(function(err, res) {
if (err) {
return done(err);
}
done();
});
}); 1) User User.login Login a user over REST with the wrong Content-Type:
Error: expected 400 "Bad Request", got 200 "OK" What is the desired behavior if |
Some troubleshooting information related to the wrong Content-Type test. The combination of {
host: '127.0.0.1:57654',
'accept-encoding': 'gzip, deflate',
cookie: '',
'user-agent': 'node-superagent/0.18.0',
'content-type': 'application/json'',
'content-length': 40
} Updating the send body to Not sure if this is the actual 400 message that is desired but a 400 none the less. Is the intention that we get a generic 400 bad request or will this 400 be sufficient? |
…values of invalidCredentials - strongloop#944
…ailVerified, unit test now passes as desired. - strongloop#944
…rmatting for consistency with existing instances. - strongloop#944
…omatically set to application/json - strongloop#944
…bove REST calls for better grouping of tests - strongloop#944
I've made some fixes to the issues noted and had a review of other tests making REST calls. All seems to be in good shape. Once I can get some confirmation on the test above I'll be sure to submit a pull request. |
@greaterweb Thank you for making efforts to improve the tests. Sorry for the delay as some of us were on holidays. A few comments:
Can you create a pull request from your repo? It would be simpler to add inline comments with the PR. |
…values of invalidCredentials - strongloop#944
…ailVerified, unit test now passes as desired. - strongloop#944
…rmatting for consistency with existing instances. - strongloop#944
…omatically set to application/json - strongloop#944
…bove REST calls for better grouping of tests - strongloop#944
…values of invalidCredentials - strongloop#944
…ailVerified, unit test now passes as desired. - strongloop#944
…rmatting for consistency with existing instances. - strongloop#944
…omatically set to application/json - strongloop#944
…bove REST calls for better grouping of tests - strongloop#944
@raymondfeng I rebased my fix branch with the current loopback master and created the pull request. Please feel free to add your comments to the PR and I'll adjust accordingly. |
Closing as PR has been merged. |
2.8.8 * Fix context middleware to preserve domains (Pham Anh Tuan) * Additional password reset unit tests for API and REST - #944 (Ron Edgecomb) * Small formatting update to have consistency with identical logic in other areas. - #944 (Ron Edgecomb) * Simplify the API test for invalidCredentials (removed create), move above REST calls for better grouping of tests - #944 (Ron Edgecomb) * Force request to send body as string, this ensures headers aren't automatically set to application/json - #944 (Ron Edgecomb) * Ensure error checking logic is in place for all REST calls, expand formatting for consistency with existing instances. - #944 (Ron Edgecomb) * Correct invalidCredentials so that it differs from validCredentialsEmailVerified, unit test now passes as desired. - #944 (Ron Edgecomb) * Update to demonstrate unit test is actually failing due to incorrect values of invalidCredentials - #944 (Ron Edgecomb) * fix jscs warning (Clark Wang) * fix nestRemoting is nesting hooks from other relations (Clark Wang)
…globalize-error-messages * 'master' of github.com:strongloop/loopback: (25 commits) Update strong-remoting dep Allow accessType per remote method v2.9.0 Update juggler dep v2.8.8 Fix context middleware to preserve domains Fix Geo test cases Allow User.hashPassword/validatePassword to be overridden Additional password reset unit tests for API and REST - strongloop#944 Small formatting update to have consistency with identical logic in other areas. - strongloop#944 Simplify the API test for invalidCredentials (removed create), move above REST calls for better grouping of tests - strongloop#944 Force request to send body as string, this ensures headers aren't automatically set to application/json - strongloop#944 Ensure error checking logic is in place for all REST calls, expand formatting for consistency with existing instances. - strongloop#944 Correct invalidCredentials so that it differs from validCredentialsEmailVerified, unit test now passes as desired. - strongloop#944 Update to demonstrate unit test is actually failing due to incorrect values of invalidCredentials - strongloop#944 v2.8.7 API and REST tests added to ensure complete and valid credentials are supplied for verified error message to be returned - tests added as suggested and fail under previous version of User model - strongloop#931 Require valid login credentials before verified email check. - strongloop#931. Change urlNotFound.js to url-not-found.js Add lib/server-app.js ... Conflicts: common/models/user.js
There appear to be a number of issues present with the User model tests.
invalidCredentials
are actually valid (seevalidCredentialsEmailVerified
)invalidCredentials
should actually fail but it doesn't (broader problem, see below).expect
needs to be paired with logic in the.end
callback (eg.if (err) return done(err);
) when testing REST calls, this is not applied to all instances. to confirm these are failing, change one of the.expect
values and note the test still passesinvalidCredentials
and nothing specific for API callRegarding the point of
.expect
usage, it's probably worth looking into any other REST unit tests to make sure they are correct in implementation.A question in general. There is both vanilla
assert
statements and chaiexpect
statements, which is the preferred approach for testing?Additional tests to add
The text was updated successfully, but these errors were encountered: