6 kyu
Single-Use Tickets: Don't Let Anyone Sneak In!
338yaphi1
Loading description...
Security
Fundamentals
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
It would be helpful if you could see what the test cases are so I can actually fix my code instead of guessing at the problem.
This comment has been hidden.
The purpose of this kata is to disallow tampering with instance attributes, so you can forget about removing those tests.
Closures are a common technique for preventing access on object properties. This causes your random tests to fail as they expect read access to
ticket.code
andticket.used
.I think you need to be clearer about this in the description.
This comment has been hidden.
I get through all of your standard test cases fine, but when it get to the random test cases, it fails on the final test per random object, clearly after you've tampered with ticket.used = true;
I have no idea why it would fail on that step on every random test, but work perfect on your hardcoded test cases...
Yep, when I console.log the variables, it shows EVERY of the random ones expects to be false, so I hardcoded the true non-random ones into my answer and passed even though my code was wrong.
This comment has been hidden.
Ok... This is kind of a trick question. This is a 2 part question, so here's a hint. Don't assume anything and solve the 2 problems seperately.
Thanks for wasting my time =) Fix your test!
Please check the test case 7, it always fail whatever i try!
Test case 7 always fails because the tests check the ticket twice without using the ticket. You're probably using the ticket as part of your check (at least, that's the problem I was having).
Thank you, i'll give it a try :)
You need to more clearly articulate the exact flow for everything in this kata, provide some example test cases, and/or provide much better error messages (pick at least two).
Everything worked well for me. I'd say 6 kyu seems about right, although I have no idea how to mark an estimated rank.
Are you sure that your random tests are correct? I have no idea why it expects false when the ticket is not used and the code is correct. I use closures so there are no ways to change used param directly. Please give me some clue what I'm duing wrong. P.S. I read the comments below and they didn't help.
I'm pretty sure some of your test cases want me to say a newly created ticket is invalid even though it matches correctCode.
It will seem that way! Some of the tests have tickets that are just pretending to be newly created. Once a ticket has been used, remember to block it from being changed manually. The point of this is to prevent a situation where hackers would try to take a used ticket and manually change ticket.used from true to false so they can reuse the same ticket. I hope this helps!
Still can brute force the test cases.
I'll add some more random expected return values when I have time. Thanks again.
The best way to go about your test cases could potentially be accomplished with a few test functions:
I've just started to see a few of what seem to be abandoned kata on Beta (as it's been a few months since I first completed all published kata for the first time). This is a great kata and I hope you'll follow through with it. If you want some help with test cases, feel free to ask.
This has been immensely helpful. I've updated my test cases to use Test.sample, so now my tests are much more robust while the code for those tests is much cleaner. I really appreciate this, and I'm glad you like the kata! As before, if there's anything else I've missed, I welcome the feedback.
Libraries are helpful, and to add to that, you can contrubute to the source code for test fixtures.
This comment has been hidden.
Good points. Looking back, the only part I randomized was whether or not the codes matched. I'll fix that. I'll also update the description to clarify whether the ticket.code and ticket.used need to be publicly accessible. Thanks for the feedback.
Hopefully it should all be fixed now. Thanks again for alerting me to the issues, and if anything else needs to be clarified or changed, I'll be happy to do so.