EES-5913 - fix issues with using Preview Tokens on draft DataSets #5687
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.
This hotfix PR fixes various issues around the usage of Preview Tokens and the Preview Token page.
Specifically this PR fixes:
Preview Token page examples
The Preview Tokens page was using the draft DataSetVersion Id in the code example tabs (e.g. the cURL example shown in the screenshot below).
This PR fixes this to use the DataSet Id instead, as per all of the other examples on the page.
This PR also adds Jest tests around the checking of the URLs and code example block on this page.
Preview Token permissions to query the DataSet summary
Previously we had support for using Preview Tokens to call API endpoints when targeting specific DataSetVersions on the DataSet (by using the dataSetVersion query parameter that is included in all of the example endpoints on this page other than the Data set summary endpoint).
We would also get away with being able to call the Data set summary endpoint of a Data set that's already published, as the auth handler responsible for making this decision would see that the DataSet is already public and so allow access, valid Preview Token or no.
What we were failing on was using a Preview Token against a DataSet that's not yet had a published version gone out, and thus is still unavailable to the public.
This PR adds support for the use of Preview Tokens to view a Data set summary of a DataSet that's not yet publicly available. It does this by checking that the DataSet being called has a draft DataSetVersion that has a matching valid token to the one being used.
Missing test cases
This PR adds lots of additional tests around Preview Tokens for all of the endpoints listed on the Preview Tokens page that didn't yet have Preview Tokens tests. Specifically, this was for the Data set summary, Download CSV, and Get Metadata endpoints.