Skip to content
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

[#218] Change redirects default behaviour #233

Merged
merged 1 commit into from
Dec 12, 2022

Conversation

aeqz
Copy link
Contributor

@aeqz aeqz commented Dec 7, 2022

Description

Problem: Xrefcheck currently always follows redirect links.

Solution: We are changing its default behaviour regarding redirect links to fail and report permanent redirects, and to pass for temporary redirects. Further PRs will allow the user to configure other policies.

Related issue(s)

Fixes #218
Relates #25

✅ Checklist for your Pull Request

Ideally a PR has all of the checkmarks set.

If something in this list is irrelevant to your PR, you should still set this
checkmark indicating that you are sure it is dealt with (be that by irrelevance).

Related changes (conditional)

  • Tests

    • If I added new functionality, I added tests covering it.
    • If I fixed a bug, I added a regression test to prevent the bug from
      silently reappearing again.
  • Documentation

    • I checked whether I should update the docs and did so if necessary:
  • Public contracts

    • Any modifications of public contracts comply with the Evolution
      of Public Contracts
      policy.
    • I added an entry to the changelog if my changes are visible to the users
      and
    • provided a migration guide for breaking changes if possible

Stylistic guide (mandatory)

Copy link
Member

@Martoon-00 Martoon-00 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, thank you 👍

Leaving a couple of insignificant concerns, and a medium one.

@Martoon-00
Copy link
Member

Also, if you claim you resolve #218, it should be appropriate to add a test. We will touch the redirection logic a lot in the next PRs, and there is a chance to forget about #218 and leave no way to handle that issue.

Feel free to resolve this here or in a separate pull request (in the latter case, you can leave Relates #218 too).

@Martoon-00
Copy link
Member

Oh, and one more thing: make sure to fit commit descriptions into 80 characters.

@aeqz aeqz force-pushed the aeqz/#25-#218-redirect-links-management branch from 6f8e690 to 628e45a Compare December 8, 2022 11:28
@aeqz aeqz requested a review from Martoon-00 December 8, 2022 11:37
Copy link
Member

@Martoon-00 Martoon-00 left a comment

Choose a reason for hiding this comment

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

Nice to see tests added 👍 I think you can add a tick to the PR description.

Leaving one more comment, would like to know your opinion.

"http://127.0.0.1:5000/redirect"
(Just "http://127.0.0.1:5000/other")
(VerifyResult [PermanentRedirectError "http://127.0.0.1:5000/redirect" (Just "http://127.0.0.1:5000/other")])
]
Copy link
Member

Choose a reason for hiding this comment

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

This is only my opinion, but I believe there is no reason to provide that high coverage, since e.g. handling of 302 and 303 in the code is exactly the same. E.g. having 302 w/ loc, 302 w/o loc, 307 w/ loc would be sufficient to cover the temporary redirects.

Using formal terms, we don't usually practice automated "black box" testing when the implementation is only one and concrete.

What do you think?

Copy link
Contributor

@YuriRomanowski YuriRomanowski Dec 8, 2022

Choose a reason for hiding this comment

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

I think that it's OK to check all the possible variants. But it seems that the way these tests are written is a bit verbose. We could for example make a separate function which tests two options (location present/absent) for a given code, and pass to this function as a parameter whether these tests should succeed or not. I believe that the code will get much shorter this way.

Copy link
Member

Choose a reason for hiding this comment

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

If test cases can be turned into one- or two-liners, that approach sounds good.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we are not doing "black box" testing that is right, the three cases mentioned by @Martoon-00 would provide enough coverage. However, let's try to cover all the possible variants with a more concise style.

Copy link
Member

Choose a reason for hiding this comment

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

Looks nice 👍

@aeqz aeqz requested a review from Martoon-00 December 8, 2022 16:53
@Martoon-00
Copy link
Member

@aeqz The comment of @YuriRomanowski seems to be also addressed, so in theory, you can merge this PR.

But indeed it is better to wait for his approval or a "feel free to merge without my approval" message.

@Martoon-00
Copy link
Member

Martoon-00 commented Dec 8, 2022

Don't forget to squash your commits after @YuriRomanowski's review is finished, as the 2nd and 3rd seem to be just additions to the 1st commit.

@aeqz aeqz force-pushed the aeqz/#25-#218-redirect-links-management branch from ae0094c to bf74b27 Compare December 12, 2022 09:14
Problem: Xrefcheck currently always follows redirect links.

Solution: We are changing its default behaviour regarding redirect
links to fail and report permanent redirects, and to pass for temporary
redirects. Further PRs will allow the user to configure other policies.
@aeqz aeqz force-pushed the aeqz/#25-#218-redirect-links-management branch from bf74b27 to 9c5f5f8 Compare December 12, 2022 09:19
@aeqz aeqz merged commit 2b9bf25 into master Dec 12, 2022
@aeqz aeqz deleted the aeqz/#25-#218-redirect-links-management branch December 12, 2022 09:32
@int-index int-index mentioned this pull request Dec 27, 2024
5 tasks
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.

[BUG] Investigate 503
3 participants