-
-
Notifications
You must be signed in to change notification settings - Fork 77
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
Various fixes #60
Merged
Merged
Various fixes #60
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
15afe79
Added .auth, .jar and .cookie implementations along with correspondin…
dgkanatsios d6a840f
revert
dgkanatsios 6ad6f09
formatting updated + version bump
dgkanatsios 5b3f6d1
minor fix
dgkanatsios c80272b
split various.test.js in auth.test.js and cookie.test.js
dgkanatsios 9619999
Update package.json
FGRibreau 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,5 @@ node_modules | |
npm-debug.log | ||
.env | ||
coverage | ||
.vscode | ||
package-lock.json |
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
'use strict'; | ||
|
||
var request = require('../'); | ||
var t = require('chai').assert; | ||
|
||
describe('Auth', function () { | ||
it('should work with Basic Authentication', function (done) { | ||
var r = request.defaults({ | ||
json: true | ||
}); | ||
r('http://httpbin.org/basic-auth/user/passwd', function (err, response, body) { | ||
t.strictEqual(response.statusCode, 200); | ||
t.strictEqual(body.authenticated, true); | ||
t.strictEqual(body.user, 'user'); | ||
done(); | ||
}).auth('user', 'passwd', false); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
'use strict'; | ||
|
||
var request = require('../'); | ||
var t = require('chai').assert; | ||
|
||
describe('Cookie', function () { | ||
it('should work with custom cookie jar', function (done) { | ||
const j = request.jar(); | ||
var url = 'http://httpbin.org/cookies/set?k2=v2&k1=v1'; | ||
request({ | ||
url, | ||
jar: j, | ||
json: true | ||
}, function (err, response, body) { | ||
t.strictEqual(response.statusCode, 200); | ||
var cookies = j.getCookies(url); | ||
t.strictEqual(cookies.length, 2); | ||
t.strictEqual(cookies.filter(c => c.key === 'k1')[0].value, 'v1'); | ||
t.strictEqual(cookies.filter(c => c.key === 'k2')[0].value, 'v2'); | ||
done(); | ||
}); | ||
}); | ||
}); |
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 |
---|---|---|
|
@@ -94,4 +94,4 @@ describe('Helpers', function () { | |
} | ||
}); | ||
|
||
}); | ||
}); |
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.
Hum, why not. I prefer to ensure that the response is as it should be (because it's free here to do so), why would we want to prefer isNumber here?
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.
As mentioned in PR comment, filltext.com does not return 1 but a random integer, e.g. try running
For me, it returns 17120, so the strictEqual tests were failing. I replaced them with isNumber so that they pass.
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.
👍