Skip to content
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

Issue 442 - blacklisting hosts with config.json #1062

Merged
merged 6 commits into from
Dec 15, 2017
Merged

Conversation

brian-mann
Copy link
Member

@brian-mann brian-mann commented Dec 13, 2017

close #442

@bahmutov bahmutov changed the title Issue 442 Issue 442 - blacklisting hosts with config.json Dec 13, 2017
@@ -103,6 +104,7 @@ defaults = {
validationRules = {
animationDistanceThreshold: v.isNumber
baseUrl: v.isFullyQualifiedUrl
blacklistHosts: v.isStringOrArrayOfStrings
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

string or array of strings here

## else return the host
return host

matches = (urlToCheck, blacklistHosts) ->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would check blackListHosts type here - if type is not string or array of strings, something went wrong. Throw

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, what does this return? needs a jsdoc block I feel, because this is so reusable

expectedHeader = (res, val) ->
expect(res.headers["x-cypress-matched-blacklisted-host"]).to.eq(val)

Promise.all([
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can also use https://github.com/bahmutov/snap-shot-it#data-driven-testing to make the test simpler here


matchesStr = (url, host, val) ->
m = blacklist.matches(url, host)
expect(!!m).to.eq(val, "url: '#{url}' did not pass")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ohhh, the !!m notation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add blacklisting of requests made to specific hosts
2 participants