Skip to content

EES-5913 - fix issues with using Preview Tokens on draft DataSets #5687

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 17, 2025

Conversation

duncan-at-hiveit
Copy link
Collaborator

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).

image

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.

@duncan-at-hiveit duncan-at-hiveit force-pushed the EES-5913-hotfix-fix-preview-tokens branch from de1f700 to 5368d9f Compare March 14, 2025 12:18
mmyoungman
mmyoungman previously approved these changes Mar 14, 2025
@duncan-at-hiveit duncan-at-hiveit force-pushed the EES-5913-hotfix-fix-preview-tokens branch from 5368d9f to 2e358b1 Compare March 14, 2025 14:43
]);
var context = CreateAnonymousAuthContext<ViewDataSetRequirement, DataSet>(dataSet);

handler.HandleAsync(context);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is surely missing an await?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good spot! I've made all test methods for this project's auth handlers async, and awaited these ta.

…s ver to being async, and awaiting HandleAsync calls.
…sion being nullable now that it can be called with preview tokens prior to the DataSet having its first published version.
@duncan-at-hiveit duncan-at-hiveit merged commit 58e302f into master Mar 17, 2025
11 checks passed
@duncan-at-hiveit duncan-at-hiveit deleted the EES-5913-hotfix-fix-preview-tokens branch March 17, 2025 10:45
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.

3 participants