-
Notifications
You must be signed in to change notification settings - Fork 351
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
Honor url whitelist when fetching remote grass files #600
Conversation
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.
It rejects and refer to the host not being in the whitelist even though it is.
Try: https://oskarhane-dropshare-eu.s3-eu-central-1.amazonaws.com/grass-crCUgFn9vt/grass.json
I think I found the cause and made a comment on that line.
}) | ||
|
||
describe('Grass remote fetch', () => { | ||
test('should not fetch from url not in the whitelist', () => { |
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.
This test won't work if the function doesn't reject. Try changing urlNotInWhitelist = 'foo'
.
Since Jest 20 you can return promises and expect it to reject. There's one missing piece though, you cannot match on error message. The workaround is to match an object and looks like this:
return expect(fetchRemoteGrass(urlNotInWhitelist, whitelist)).rejects.toMatchObject({
message: 'Hostname is not allowed according to server whitelist'
})
https://facebook.github.io/jest/docs/expect.html#resolves and jestjs/jest#3601
const urlInWhitelist = 'foo' | ||
return fetchRemoteGrass(urlInWhitelist, whitelist) | ||
.then((res) => { | ||
expect(res).toBe(urlInWhitelist) |
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.
Same as above, but using .resolves
: https://facebook.github.io/jest/docs/expect.html#resolves
@@ -207,7 +207,7 @@ const availableCommands = [{ | |||
if (!param.startsWith('http')) { | |||
param = 'http://' + param | |||
} | |||
remote.get(param) | |||
fetchRemoteGrass(param) |
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.
Should the whitelist be passed as a param here?
@oskarhane updated |
lgtm |
The url param when loading remote grass using
:style
needs to be present in the whitelist returned by the neo4j server