test(api): request tests for certification ships endpoint#515
Open
dhamariT wants to merge 5 commits into
Open
Conversation
…arams are specified
Exclude ships of soft-deleted projects, default to a 24h window instead of returning the whole table when no time params are given, return 400 on unparseable time params rather than silently substituting defaults, and drop the extra COUNT query.
Covers auth rejection, the default 24h window, explicit since/until windows, the status filter, the soft-deleted project exclusion, and 400s on invalid time params.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Request tests for the certification ships endpoint from #215, kept out of that PR to keep its diff focused. They cover auth rejection, the default 24 hour window, explicit since/until windows, the status filter, the soft-deleted project exclusion, and the 400s on invalid time params.
This branches off #215 so the diff shows its commits too until it merges, after which this collapses to just the test file. Merge #215 first.
One note on the setup: you can't stub Rails.application.credentials with minitest's stub because EncryptedConfiguration's method_missing swallows the call as a credential lookup, and mutating credentials.config does nothing since dig reads a memoized options hash. The test injects the API key by mutating that options hash in setup and removing it in teardown.
Note
Medium Risk
New external read API exposes certification and project data including Slack IDs; risk is mitigated by Bearer API keys and read-only access but credential scope and data exposure warrant review.
Overview
Adds a read-only JSON API for certification shipwrights at
GET /api/v1/certification/ships, wired underApi::V1::Certificationwith API keys fromcertification_shipwrightscredentials (separate from ambassador referral keys).The index action returns certification ships in a configurable time window (default last 24 hours via
hours, orsince/until), optionalstatusfiltering, excludes soft-deleted projects, and serializes ship review metadata plus nested project, owner, and reviewer fields (including Slack IDs). Invalid time/hoursparams return 400 viaInvalidParam.Integration tests exercise Bearer auth rejection, the default window,
since/until, status filter, deleted-project exclusion, and bad params; setup mutates the memoized credentialsoptionshash becauseRails.application.credentialscannot be stubbed normally.Reviewed by Cursor Bugbot for commit 2aaf7cf. Bugbot is set up for automated code reviews on this repo. Configure here.