|
7 | 7 | from sqlalchemy import select |
8 | 8 |
|
9 | 9 | from testgen.common.auth import authorize_token, decode_jwt_token |
| 10 | +from testgen.common.enums import PublicJobKey |
10 | 11 | from testgen.common.models import Session, _current_session_wrapper, get_current_session |
11 | | -from testgen.common.models.job_execution import PUBLIC_JOB_KEYS, JobExecution |
| 12 | +from testgen.common.models.job_execution import JobExecution |
12 | 13 | from testgen.common.models.project_membership import ProjectMembership |
13 | 14 | from testgen.common.models.table_group import TableGroup |
14 | 15 | from testgen.common.models.test_suite import TestSuite |
@@ -122,15 +123,15 @@ def dependency(test_suite_id: UUID, user: User = _require_user) -> TestSuite: |
122 | 123 | def resolve_job(permission: str, *extra_filters): |
123 | 124 | """Resolve a JobExecution by ``job_id`` path param and verify project permission. |
124 | 125 |
|
125 | | - Only jobs whose ``job_key`` is in ``PUBLIC_JOB_KEYS`` are exposed via the API. |
| 126 | + Only externally-triggerable jobs (``PublicJobKey``) are exposed via the API. |
126 | 127 | Internal kinds (score rollups, recalculations, monitor runs) are filtered out |
127 | 128 | by construction. Extra ORM clauses are appended to the WHERE clause to further |
128 | 129 | restrict by job_key when a caller wants a single kind. |
129 | 130 | """ |
130 | 131 | def dependency(job_id: UUID, user: User = _require_user) -> JobExecution: |
131 | 132 | query = select(JobExecution).where( |
132 | 133 | JobExecution.id == job_id, |
133 | | - JobExecution.job_key.in_(PUBLIC_JOB_KEYS), |
| 134 | + JobExecution.job_key.in_(list(PublicJobKey)), |
134 | 135 | *extra_filters, |
135 | 136 | ) |
136 | 137 | return _check_access(get_current_session().scalars(query).first(), user, permission) |
|
0 commit comments