Skip to content

Commit

Permalink
Merge pull request #114 from kevva/http-auth
Browse files Browse the repository at this point in the history
Add support for basic HTTP auth
  • Loading branch information
kevva committed Sep 9, 2014
2 parents 7187515 + 01d02fa commit b49288f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ function showHelp() {
--cookie <cookie> Browser cookie, can be set multiple times
--name <template> Custom filename
--selector <element> Capture DOM element
--username <username> Username for HTTP auth
--password <password> Password for HTTP auth
<url> can also be a local file path.
Expand Down
14 changes: 14 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ Options
--cookie <cookie> Browser cookie, can be set multiple times
--name <template> Custom filename
--selector <element> Capture DOM element
--username <username> Username for HTTP auth
--password <password> Password for HTTP auth
<url> can also be a local file path.
Expand Down Expand Up @@ -154,6 +156,18 @@ Type: `string`

Capture a specific DOM element.

##### username

Type: `string`

Username for authenticating with HTTP auth.

##### password

Type: `string`

Password for authenticating with HTTP auth.


### pageres.src(url, sizes, options)

Expand Down
16 changes: 16 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,22 @@ test('generate screenshot using the CLI', function (t) {
});
});

test('auth using username and password', function (t) {
t.plan(3);

var pageres = new Pageres({username: 'user', password: 'passwd'})
.src('httpbin.org/basic-auth/user/passwd', ['120x120']);

pageres.run(function (err, streams) {
t.assert(!err, err);
t.assert(streams.length === 1);

streams[0].once('data', function (data) {
t.assert(data.length);
});
});
});

function cookieTest (port, input, t) {
t.plan(6);
var server = new Server(port);
Expand Down

0 comments on commit b49288f

Please sign in to comment.