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
refactor(IP Address): Update all IP Addresses in tests to use RFC-5735 TEST-NET-* addresses. #15470
base: main
Are you sure you want to change the base?
Conversation
…o use RFC-5735 TEST-NET-* addresses
Hey @miketheman , as far as I've researched on the issue #13186
I've updated all the IP Addresses in |
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.
Nice work, a couple of comments inline to think about.
…d emote_addr_salted fixtures
@miketheman I've made the changes you suggested me, let me know if there are any more changes to be made in this PR :) |
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.
@Mr-Sunglasses This is coming along nicely, thanks for continuing the effort!
There's a few more cases of non-replaced IP address strings - I haven't exhaustively identified each one, but we're getting closer!
@@ -130,13 +138,14 @@ def test_accepts_x_forwarded_headers(self, remote_addr_salted): | |||
|
|||
resp = wsgi.ProxyFixer(app, token=None, ip_salt="pepa")(environ, start_response) | |||
|
|||
expected_remote_addr_hashed = calculate_hashed_value("1.2.3.4", "pepa") |
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.
question: Can you help me understand why we're back to using a 1.2.3.4 here?
In my head, all the REMOTE_ADDR
entries above could be replaced by the remove_addr
fixture, and the REMOTE_ADDR_HASHED
below could be replaced with the remote_addr_hashed
fixture, and the calculate_hashed_value()
function could go away.
Created statically to prevent needing to calculate it every run. | ||
""" | ||
return "6694f83c9f476da31f5df6bcc520034e7e57d421d247b9d34f49edbfc84a764c" | ||
@pytest.fixture(scope="function") |
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.
Shouldn't all of these be scoped to session
, so they effectively become set once per test suite run?
@pytest.fixture(scope="function") | |
@pytest.fixture(scope="session") |
if remote_addr is None: | ||
return None |
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.
question: How could remote_addr
be None
? Do we ever override the input to this fixture function, or should this condition be removed?
@@ -101,12 +101,12 @@ def test_identity_credentials_fail(self, monkeypatch): | |||
pretend.stub( | |||
matched_route=None, | |||
banned=pretend.stub(by_ip=lambda ip_address: False), | |||
remote_addr="1.2.3.4", | |||
remote_addr="192.0.2.1", |
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.
These should also probably be replaced by remote_addr
fix: #13186