-
Notifications
You must be signed in to change notification settings - Fork 8
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
Further work on message validation #1758
Conversation
Pull reviewers statsStats of the last 30 days for popstellar:
|
…alidations in ElectionQuestion
ElectionQuestion : added validation at Question creation + added tests
Hint for reviewers: The construction of a Question is now validated. I also am checking the question handed in the ElectionQuestion for the exact same constraints. This means we are validating the question twice, thus reducing coverage (since we can't construct any invalid question to hand to the ElectionQuestion constructor). It may not be needed to validate the question in ElectionQuestion, but I stil did just in case. I am open to suggestion about it. |
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.
Really good work! Just some picky comments
...a/com/github/dedis/popstellar/model/network/method/message/data/election/ElectionQuestion.kt
Outdated
Show resolved
Hide resolved
...a/com/github/dedis/popstellar/model/network/method/message/data/election/ElectionQuestion.kt
Outdated
Show resolved
Hide resolved
fe2-android/app/src/main/java/com/github/dedis/popstellar/utility/MessageValidator.kt
Outdated
Show resolved
Hide resolved
fe2-android/app/src/main/java/com/github/dedis/popstellar/utility/MessageValidator.kt
Outdated
Show resolved
Hide resolved
fe2-android/app/src/main/java/com/github/dedis/popstellar/utility/MessageValidator.kt
Outdated
Show resolved
Hide resolved
.../java/com/github/dedis/popstellar/model/network/method/message/data/election/CastVoteTest.kt
Outdated
Show resolved
Hide resolved
…ed inputs CastVoteTest : actually using defined vote variables to avoid hardcoded inputs
Thanks a lot @matteosz for your insightful review 👍 |
Just a reminder also for future PRs (you can skip it for this one): try to keep commits number as low as possible. Commits are a great mechanism for tracking history, but if multiple commits have the same purpose this simply increases the entropy of the codebase and "obfuscate" a good commit history. So try to squash together all the commits that serve to the same purpose. Simply run |
init { | ||
verify().isNotEmptyBase64(electionId, "election ID").validQuestions(listOf(question)) |
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.
Saw that you did a commit named ElectionQuestion : removed overlapping Question validations
but it's actually an empty commit (just some formatting), so I guess you forgot to remove the validQuestions check here
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.
I actually removed the redundant checks performed in validQuestions
, line 245 of MessageValidator
(calling validQuestion
for each Question in the list). validQuestions is still used, as it checks for duplicates and requires the list not to be empty. Maybe it makes it not relevant anymore to be a function in MessageValidator
tho.
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.
Yeah the point was: why are you still calling .validQuestions(listOf(question))
in ElectionQuestion
? The fact that the list is not empty and without duplicates is given by the construction of it (a list of 1 element)
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.
oh yes that makes a lot of sense, I overlooked
…ed inputs CastVoteTest : actually using defined vote variables to avoid hardcoded inputs
formatting
…on' into work-fe2-maxime-message-validation
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.
Seems OK to me
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.
LGTM!
Quality Gate passed for 'PoP - PoPCHA-Web-Client'Issues Measures |
Quality Gate passed for 'PoP - Be1-Go'Issues Measures |
Quality Gate passed for 'PoP - Be2-Scala'Issues Measures |
Quality Gate passed for 'PoP - Fe2-Android'Issues Measures |
Quality Gate passed for 'PoP - Fe1-Web'Issues Measures |
Addressing #1751
This PR will hold new message data object validation, to help the effort of complete message validation depicted in #1751.
Note to myself: remember to update the list of validated data in #1751, after this PR gets approved.