Skip to content

Commit

Permalink
Merge pull request IQSS#10127 from jp-tosca/10070-api-doc-changelog
Browse files Browse the repository at this point in the history
Add condition for 401 on invalid key and changelog on API Guide
  • Loading branch information
pdurbin authored Nov 17, 2023
2 parents 1343de7 + 70edaa7 commit 9186b06
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
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

0 comments on commit 9186b06

Please sign in to comment.