-
Notifications
You must be signed in to change notification settings - Fork 756
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(snippet): Add black/white lists - fixes #373
- Loading branch information
1 parent
bbf6b06
commit 6a2a296
Showing
8 changed files
with
221 additions
and
12 deletions.
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
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
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,103 @@ | ||
"use strict"; | ||
|
||
var browserSync = require("../../../../index"); | ||
|
||
var connect = require("connect"); | ||
var serveStatic = require("serve-static"); | ||
var request = require("supertest"); | ||
var assert = require("chai").assert; | ||
|
||
describe("E2E proxy test with snippet options: Whitelist", function () { | ||
|
||
var instance, server, options; | ||
|
||
before(function (done) { | ||
|
||
browserSync.reset(); | ||
|
||
var app = connect(); | ||
app.use(serveStatic("./test/fixtures")); | ||
server = app.listen(); | ||
var proxytarget = "http://localhost:" + server.address().port; | ||
|
||
var config = { | ||
proxy: proxytarget, | ||
logLevel: "silent", | ||
open: false, | ||
snippetOptions: { | ||
whitelist: ["/index-large.html"] | ||
} | ||
}; | ||
|
||
instance = browserSync.init([], config, function (err, bs) { | ||
options = bs.options; | ||
done(); | ||
}).instance; | ||
}); | ||
|
||
after(function () { | ||
instance.cleanup(); | ||
server.close(); | ||
}); | ||
|
||
it("can init proxy & serve a page with whitelist option (injects snippet even without html headers)", function (done) { | ||
|
||
assert.isDefined(instance.server); | ||
|
||
request(instance.server) | ||
.get("/index-large.html") | ||
.expect(200) | ||
.end(function (err, res) { | ||
assert.include(res.text, options.get("snippet")); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
describe("E2E proxy test with snippet options: blacklist", function () { | ||
|
||
var instance, server, options; | ||
|
||
before(function (done) { | ||
|
||
browserSync.reset(); | ||
|
||
var app = connect(); | ||
app.use(serveStatic("./test/fixtures")); | ||
server = app.listen(); | ||
var proxytarget = "http://localhost:" + server.address().port; | ||
|
||
var config = { | ||
proxy: proxytarget, | ||
logLevel: "silent", | ||
open: false, | ||
snippetOptions: { | ||
blacklist: ["/index-large.html"] | ||
} | ||
}; | ||
|
||
instance = browserSync.init([], config, function (err, bs) { | ||
options = bs.options; | ||
done(); | ||
}).instance; | ||
}); | ||
|
||
after(function () { | ||
instance.cleanup(); | ||
server.close(); | ||
}); | ||
|
||
it("can init proxy & serve a page with whitelist option", function (done) { | ||
|
||
assert.isDefined(instance.server); | ||
|
||
request(instance.server) | ||
.get("/index-large.html") | ||
.set("accept", "text/html") | ||
.expect(200) | ||
.end(function (err, res) { | ||
assert.notInclude(res.text, options.get("snippet")); | ||
done(); | ||
}); | ||
}); | ||
}); |