Skip to content
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

Add condition for 401 on invalid key and changelog on API Guide #10127

Merged
merged 7 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions doc/release-notes/10060-api-changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
We have started maintaining an API changelog: https://dataverse-guide--10127.org.readthedocs.build/en/10127/api/changelog.html

See also #10060.
13 changes: 13 additions & 0 deletions doc/sphinx-guides/source/api/changelog.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
API Changelog
=============

.. contents:: |toctitle|
:local:
:depth: 1

6.0
-----

Changes
~~~~~~~
- **/api/access/datafile**: When a null or invalid API token is provided to download a public (non-restricted) file with this API call, it will result on a ``401`` error response. Previously, the download was allowed (``200`` response). Please note that we noticed this change sometime between 5.9 and 6.0. If you can help us pinpoint the exact version (or commit!), please get in touch.
1 change: 1 addition & 0 deletions doc/sphinx-guides/source/api/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ API Guide
linkeddatanotification
apps
faq
changelog
11 changes: 6 additions & 5 deletions src/test/java/edu/harvard/iq/dataverse/api/AccessIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ public void testDownloadSingleFile() {
//Not logged in non-restricted
Response anonDownloadOriginal = UtilIT.downloadFileOriginal(tabFile1Id);
Response anonDownloadConverted = UtilIT.downloadFile(tabFile1Id);
Response anonDownloadConvertedNullKey = UtilIT.downloadFile(tabFile1Id, null);

// ... and download the same tabular data file, but without the variable name header added:
Response anonDownloadTabularNoHeader = UtilIT.downloadTabularFileNoVarHeader(tabFile1Id);
// ... and download the same tabular file, this time requesting the "format=tab" explicitly:
Expand All @@ -206,6 +208,8 @@ public void testDownloadSingleFile() {
assertEquals(OK.getStatusCode(), anonDownloadConverted.getStatusCode());
assertEquals(OK.getStatusCode(), anonDownloadTabularNoHeader.getStatusCode());
assertEquals(OK.getStatusCode(), anonDownloadTabularWithFormatName.getStatusCode());
assertEquals(UNAUTHORIZED.getStatusCode(), anonDownloadConvertedNullKey.getStatusCode());

int origSizeAnon = anonDownloadOriginal.getBody().asByteArray().length;
int convertSizeAnon = anonDownloadConverted.getBody().asByteArray().length;
int tabularSizeNoVarHeader = anonDownloadTabularNoHeader.getBody().asByteArray().length;
Expand Down Expand Up @@ -423,10 +427,7 @@ private HashMap<String,ByteArrayOutputStream> readZipResponse(InputStream iStrea
}

String name = entry.getName();
// String s = String.format("Entry: %s len %d added %TD",
// entry.getName(), entry.getSize(),
// new Date(entry.getTime()));
// System.out.println(s);


// Once we get the entry from the zStream, the zStream is
// positioned read to read the raw data, and we keep
Expand Down Expand Up @@ -466,7 +467,7 @@ private HashMap<String,ByteArrayOutputStream> readZipResponse(InputStream iStrea

@Test
public void testRequestAccess() throws InterruptedException {

String pathToJsonFile = "scripts/api/data/dataset-create-new.json";
Response createDatasetResponse = UtilIT.createDatasetViaNativeApi(dataverseAlias, pathToJsonFile, apiToken);
createDatasetResponse.prettyPrint();
Expand Down
Loading