Skip to content

feat(perforce): Add missing perforce test#116006

Draft
evanpurkhiser wants to merge 1 commit into
masterfrom
evanpurkhiser/feat-perforce-add-missing-perforce-test
Draft

feat(perforce): Add missing perforce test#116006
evanpurkhiser wants to merge 1 commit into
masterfrom
evanpurkhiser/feat-perforce-add-missing-perforce-test

Conversation

@evanpurkhiser
Copy link
Copy Markdown
Member

No description provided.

@evanpurkhiser evanpurkhiser requested review from a team as code owners May 21, 2026 14:12
@evanpurkhiser evanpurkhiser requested review from mujacica and removed request for a team May 21, 2026 14:12
Comment on lines +58 to +67
resp = self.client.post(
url,
data={
"p4port": "ssl:perforce.example.com:1666",
"user": "sentry-bot",
"authType": "password",
"password": "secret",
},
format="json",
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Bug: Tests for Perforce SSL connections are missing the required ssl_fingerprint field in the POST data, which will cause them to fail validation.
Severity: LOW

Suggested Fix

Update the POST data in the Perforce SSL tests (test_successful_connection, test_auth_failure_returns_error, test_connection_failure_returns_error) to include a valid ssl_fingerprint field alongside the p4port that uses an 'ssl:' prefix.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: tests/sentry/integrations/perforce/test_pipeline.py#L58-L67

Potential issue: The `PerforceInstallationSerializer` requires an `ssl_fingerprint` when
the `p4port` field starts with `'ssl'`. The newly added tests
(`test_successful_connection`, `test_auth_failure_returns_error`, and
`test_connection_failure_returns_error`) provide an SSL `p4port` but omit the required
`ssl_fingerprint`. This causes the serializer's `is_valid()` check to raise a
`ValidationError`, resulting in an HTTP 400 response. `test_successful_connection` will
fail its status code assertion, while the other tests will fail with a `KeyError` due to
an unexpected error response structure.

Did we get this right? 👍 / 👎 to inform future reviews.

Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit eb01b69. Configure here.

"password": "secret",
},
format="json",
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tests missing required sslFingerprint for SSL connections

Medium Severity

The test_successful_connection, test_auth_failure_returns_error, and test_connection_failure_returns_error tests all post a p4port starting with "ssl:" but omit sslFingerprint. The PerforceInstallationSerializer.validate method raises a ValidationError when p4port starts with "ssl" and ssl_fingerprint is falsy (its default is ""). This means all three tests will fail at serializer validation before reaching the mocked get_depots call. The equivalent tests in test_integration.py correctly include sslFingerprint in the POST data.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit eb01b69. Configure here.

def test_step_data_is_empty(self) -> None:
step = PerforceInstallationApiStep()
data = step.get_step_data(None, None) # type: ignore[arg-type]
assert data == {}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Duplicate test class already exists in another file

Low Severity

The PerforceApiPipelineTest class with its helper methods and four of its five tests (test_successful_connection, test_auth_failure_returns_error, test_connection_failure_returns_error, test_missing_required_fields) is a near-exact copy of the identically named class already in test_integration.py (line 625). The only genuinely new test is test_step_data_is_empty. This duplication risks divergence (as already evidenced by the missing sslFingerprint bug) and increases maintenance burden. The new test could be added to the existing class instead.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit eb01b69. Configure here.

@github-actions
Copy link
Copy Markdown
Contributor

Backend Test Failures

Failures on c56b000 in this run:

tests/sentry/integrations/perforce/test_pipeline.py::PerforceApiPipelineTest::test_auth_failure_returns_errorlog
[gw0] linux -- Python 3.13.1 /home/runner/work/sentry/sentry/.venv/bin/python3
tests/sentry/integrations/perforce/test_pipeline.py:92: in test_auth_failure_returns_error
    assert "Authentication failed" in resp.data["data"]["detail"]
                                      ^^^^^^^^^^^^^^^^^
E   KeyError: 'data'
tests/sentry/integrations/perforce/test_pipeline.py::PerforceApiPipelineTest::test_connection_failure_returns_errorlog
[gw0] linux -- Python 3.13.1 /home/runner/work/sentry/sentry/.venv/bin/python3
tests/sentry/integrations/perforce/test_pipeline.py:115: in test_connection_failure_returns_error
    assert "Failed to connect" in resp.data["data"]["detail"]
                                  ^^^^^^^^^^^^^^^^^
E   KeyError: 'data'
tests/sentry/integrations/perforce/test_pipeline.py::PerforceApiPipelineTest::test_successful_connectionlog
[gw0] linux -- Python 3.13.1 /home/runner/work/sentry/sentry/.venv/bin/python3
tests/sentry/integrations/perforce/test_pipeline.py:68: in test_successful_connection
    assert resp.status_code == 200
E   assert 400 == 200
E    +  where 400 = <Response status_code=400, "application/json">.status_code

@evanpurkhiser
Copy link
Copy Markdown
Member Author

This was hanging around in my commits, it probably needs updated now

@evanpurkhiser evanpurkhiser marked this pull request as draft May 21, 2026 14:35
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.

1 participant