Skip to content

feature(API): Adds input validation in all API methods and validates empty user Id. #170

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

Merged
merged 6 commits into from
Nov 27, 2018

Conversation

mfahadahmed
Copy link
Contributor

No description provided.

@coveralls
Copy link

coveralls commented Sep 28, 2018

Coverage Status

Coverage decreased (-0.08%) to 97.243% when pulling 8f6d793 on fahad/input-validation into 249e64f on master.

@mikeproeng37
Copy link
Contributor

@mfahadahmed this needs to be accompanied by a PR to change up the failing Compat Suite test. Please check it out.

@mikeproeng37
Copy link
Contributor

build

Copy link
Contributor

@mikeproeng37 mikeproeng37 left a comment

Choose a reason for hiding this comment

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

Looks good mostly. I just have a coupla small suggestions

@@ -334,7 +334,8 @@ Optimizely.prototype.getVariation = function(experimentKey, userId, attributes)
*/
Optimizely.prototype.setForcedVariation = function(experimentKey, userId, variationKey) {
try {
return projectConfig.setForcedVariation(this.configObj, experimentKey, userId, variationKey, this.logger);
return this.__validateInputs({ experiment_key: experimentKey, user_id: userId })
Copy link
Contributor

Choose a reason for hiding this comment

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

very nitpicky: explicitily return false if !this.__validateInputs... and then keep the previous return value

@@ -368,6 +373,16 @@ Optimizely.prototype.getForcedVariation = function(experimentKey, userId) {
*/
Optimizely.prototype.__validateInputs = function(stringInputs, userAttributes, eventTags) {
try {
// Empty user Id is valid value.
Copy link
Contributor

Choose a reason for hiding this comment

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

It's better to document what is NOT a valid value :)

@mikeproeng37 mikeproeng37 merged commit 45f6794 into master Nov 27, 2018
@mikeproeng37 mikeproeng37 deleted the fahad/input-validation branch December 14, 2018 20:06
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.

3 participants