-
Notifications
You must be signed in to change notification settings - Fork 0
Handle non-permitted params when comparing rules to request body #1
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
Open
mecampbellsoup
wants to merge
4
commits into
master
Choose a base branch
from
handle-non-permitted-params
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+57
−31
Open
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
7782fc0
Handle non-permitted params when comparing rules to request body
mecampbellsoup a03fdbc
Merge branch 'master' into handle-non-permitted-params
mecampbellsoup e5f2df3
non_permitted_param error for params that aren't whitelisted in rules
mecampbellsoup 92ff733
Return nil when RulesFormat#find fails
mecampbellsoup 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 hidden or 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 hidden or 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 |
---|---|---|
|
@@ -25,10 +25,25 @@ | |
end | ||
|
||
context "when the request body does not adhere to the rules format" do | ||
let(:name) { 1_000 } | ||
context "when a non-specified parameter is included in the request body" do | ||
let(:params) { { name: "M@", email: "[email protected]" } } | ||
|
||
it "returns an object describing the invalid attribute" do | ||
expect(subject).to eq({ "name" => "param_must_be_string" }) | ||
# NOTE: pick one of the following 2 test cases as desired behavior | ||
it "ignores the non-whitelisted param" do | ||
expect(subject).to eq nil | ||
end | ||
|
||
it "adds an error for the non-whitelisted param" do | ||
expect(subject).to eq({ "email" => "non_permitted_param" }) | ||
end | ||
end | ||
|
||
context "when the require parameter is of the wrong type" do | ||
let(:name) { 1_000 } | ||
|
||
it "returns an object describing the invalid attribute" do | ||
expect(subject).to eq({ "name" => "param_must_be_string" }) | ||
end | ||
end | ||
end | ||
end | ||
|
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.
@kurko do you think 'extra' params should simply be ignored, or should we actually mark the request as being invalid (this is what we're doing now).
Example:
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.
Ignored, I think. strong parameters does that.
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.
The two examples below represent (1) ignoring them, not adding an error but filtering out the non-permitted param, or (2) adding an error as we do now in OTX.
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.
@kurko spoke with Jake about this: https://zipmark.slack.com/archives/C32CZ771B/p1490814011401531