-
-
Couldn't load subscription status.
- Fork 13
#16 in range returns incorrect registered port #17
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
#16 in range returns incorrect registered port #17
Conversation
The middle dash character "-" was not the ASCII 0xD2 but some other representation: 0xE28093 preventing the correct comparison in the code logic and ignoring the record
The condition had the wrong operand. Improve test cases to ensure that the result is the one expected, not just the cardinality. Increase coverage by testing a not found port
The results were inconsistent since References are not sorted by single-port first and wide port ranges may match before single port ones. This is not a breaking change since the logic of InRange being used in the app checks first for specific ports
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've never tried this "review" thing, don't really know what I'm doing. I'm just trying to add more information to the PR so it's easy to verify)
| }, | ||
| { | ||
| Name: "1560–1590", | ||
| Name: "1560-1590", |
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.
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 test failing before doing the replacements of chars in files:
=== RUN TestPortsConsistencyValidation
httpref_test.go:96: Invalid port format: 71–74
httpref_test.go:96: Invalid port format: 225–241
httpref_test.go:96: Invalid port format: 249–255
httpref_test.go:96: Invalid port format: 1011–1020
httpref_test.go:96: Invalid port format: 1560–1590
httpref_test.go:96: Invalid port format: 1582–1583
httpref_test.go:96: Invalid port format: 2222–2226
[... redacted... 48 offending rules in total]
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.
Aaaaand this is why the previous test was necessary. 😄
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.
Decide if we want to delete the logic of InRange of single-port-detection
|
Dont sweat the self review too much. That checkbox is there to make sure people have given their code a once over before the formally submit the PR. For me, it's important that you made the right fix and the tests pass. Do you think it's ready? |
|
Hi @dnnrly , yes hi think it's ready. It's my first contribution to an Open Source project and I'm doing the same I usually do at work — I'll be less verbose in future PRs 👍 |
|
Wow, I am honoured that you chose this project to be your first contribution. It shows that you review code at work and it's very much appreciated. As for this PR, I will resolve all of the comments you've made so don't think that I'm ignoring them. I am away from any computers this week so it may take a little while to take it all in. |
| {having: "19150", expect: "10000-20000"}, | ||
| {having: "16406", expect: "10000-20000"}, | ||
| {having: "5988", expect: "5988-5989"}, | ||
| {having: "5989", expect: "5988-5989"}, |
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 like this change. It says what we're testing more succinctly.
| assert.Equal(t, 5, len(n)) | ||
| } | ||
|
|
||
| func TestPortsConsistencyValidation(t *testing.T) { |
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 was going to ask if this test is necessary BUT I think it actually specifies the contract for naming port mappings. Well spotted!
|
Thanks for taking the time to review my comments, I really appreciate it. My first contribution 👏 👏 I'm so happy. |
Description
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.
Fixes #16
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Increased the coverage to 100%
Checklist:
master