Skip to content

refact(API): Adds missing input validations in all API methods and validates empty user Id. #127

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

rashidsp
Copy link
Contributor

@rashidsp rashidsp commented Sep 28, 2018

  1. Aattributes validation in APIs(is_feature_enabled, get_enabled_features and get_feature_variables).
  2. Allow empty user id.

@coveralls
Copy link

coveralls commented Sep 28, 2018

Coverage Status

Coverage remained the same at 100.0% when pulling 9a053be on rashid/input-validations into ff19d0a on master.

@msohailhussain msohailhussain requested review from mikeproeng37 and a team October 2, 2018 05:56
@mikeproeng37
Copy link
Contributor

build

@mikeproeng37
Copy link
Contributor

build

}, @logger, Logger::ERROR
)

unless user_id.is_a?(String)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd rather we refactor a bit and avoid using this same logic everywhere in the code. Let's mimic what the C# SDK does here: https://github.com/optimizely/csharp-sdk/blob/master/OptimizelySDK/Optimizely.cs#L642

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@msohailhussain
Copy link
Contributor

it's ready for review.

@@ -258,6 +258,8 @@ def is_feature_enabled(feature_flag_key, user_id, attributes = nil)
}, @logger, Logger::ERROR
)

return false unless user_inputs_valid?(attributes)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we combine Optimizely::Helpers::Validator.inputs_valid? with user_inputs_valid?? Seems like we could just put all user inputs into one dictionary and have them all validated

Copy link
Contributor Author

@rashidsp rashidsp Nov 23, 2018

Choose a reason for hiding this comment

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

Combined validations: rashid/input-validations...rashid/input-validations-2
It resulted in a big change plz confirm to continue with this PR?

@mikeproeng37 mikeproeng37 merged commit af05d73 into master Nov 27, 2018
@oakbani oakbani deleted the rashid/input-validations branch November 28, 2018 05:04
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.

4 participants