Skip to content

Submission API: Enforce phase start/end window on submission creation - #2496

Open
ihsaan-ullah wants to merge 1 commit into
developfrom
submission_api
Open

Submission API: Enforce phase start/end window on submission creation#2496
ihsaan-ullah wants to merge 1 commit into
developfrom
submission_api

Conversation

@ihsaan-ullah

Copy link
Copy Markdown
Collaborator

Description

Phase.is_active returned True unconditionally when end was unset, never checking start — a not-yet-started phase with no end date was treated as active. SubmissionCreationSerializer.validate() also never checked is_active or can_user_make_submissions(), so submissions could be created via the API before a phase started or after it ended.

  • Fix Phase.is_active to check start regardless of whether end is set
  • Reject submission creation when the target phase is not active or the user has hit their submission limit, returning a 400 error
  • Add tests for both new fixes

Issues this PR resolves

Any relevant files for testing

  • Put all the following files in one folder,
  • create .env with CODABENCH_USERNAME and CODABENCH_PASSWORD
  • Update BASE_URL, COMPETITION_ID, PHASE_ID and SUBMISSION_FILE in `config.py
  • Run command pyton3 submission.py to upload a submission
    auth.py
    config.py
    submission.py

A checklist for hand testing

  • submission upload works when phase is active
  • submission upload fails when phase is not active

Checklist

  • Code review by me
  • Hand tested by me
  • I'm proud of my work
  • Code review by reviewer
  • Hand tested by reviewer
  • CircleCi tests are passing
  • Ready to merge

Phase.is_active returned True unconditionally when end was unset,
never checking start — a not-yet-started phase with no end date was
treated as active. SubmissionCreationSerializer.validate() also never
checked is_active or can_user_make_submissions(), so submissions could
be created via the API before a phase started or after it ended.

- Fix Phase.is_active to check start regardless of whether end is set
- Reject submission creation when the target phase is not active or
  the user has hit their submission limit, returning a 400 error
- Add tests for both new fixes
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.

Create submission API - can upload submission even if phase has ended

1 participant