Skip to content

Commit

Permalink
Merge branch 'main' into harmony-1872-2
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-durbin committed Dec 16, 2024
2 parents c878ec0 + ecf8c6d commit f019da9
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
4 changes: 2 additions & 2 deletions services/harmony/app/markdown/apis.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ As such it accepts parameters in the URL path as well as query parameters.
| maxResults | limits the number of input files processed in the request |
| skipPreview | if "true", override the default API behavior and never auto-pause jobs |
| ignoreErrors | if "true", continue processing a request to completion even if some items fail. If "false" immediately fail the request. Defaults to true |
| destinationUrl | destination url specified by the client; currently only s3 link urls are supported (e.g. s3://my-bucket-name/mypath) and will result in the job being run asynchronously |
| destinationUrl | destination url specified by the client; currently only s3 link urls are supported (e.g. s3://my-bucket-name/mypath) and will result in the job being run asynchronously |
| variable | the variable(s) to be used for variable subsetting. Multiple variables can be specified as a comma-separated list. This parameter is only used if the url `variable` path element is "parameter_vars" |
| average | requests the data to be averaged over either time or area |
---
Expand Down Expand Up @@ -120,7 +120,7 @@ Currently only the `/position`, `/cube`, `/trajectory` and `/area` routes are su
|-----------|-------------|
| concatenate | requests results to be concatenated into a single result |
| forceAsync | if "true", override the default API behavior and always treat the request as asynchronous |
| destinationUrl | destination url specified by the client; currently only s3 link urls are supported (e.g. s3://my-bucket-name/mypath) and will result in the job being run asynchronously |
| destinationUrl | destination url specified by the client; currently only s3 link urls are supported (e.g. s3://my-bucket-name/mypath) and will result in the job being run asynchronously |
| granuleId | the CMR Granule ID for the granule which should be retrieved |
| granuleName | passed to the CMR search as the readable_granule_name parameter. Supports * and ? wildcards for multiple and single character matches. Wildcards can be used any place in the name, but leading wildcards are discouraged as they require a lot of resources for the underlying search |
| grid | the name of the output grid to use for regridding requests. The name must match the UMM |grid name in the CMR.
Expand Down
2 changes: 1 addition & 1 deletion services/harmony/app/middleware/parameter-validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ async function validateDestinationUrlWritable(req: HarmonyRequest, destinationUr
*/
async function validateDestinationUrlParameter(req: HarmonyRequest): Promise<void> {
const keys = keysToLowerCase(req.query);
const destUrl = keys.destinationurl?.toLowerCase();
const destUrl = keys.destinationurl?.replace('S3://', 's3://');
if (destUrl) {
if (!destUrl.startsWith('s3://')) {
throw new RequestValidationError(`Invalid destinationUrl '${destUrl}', must start with s3://`);
Expand Down
30 changes: 30 additions & 0 deletions services/harmony/test/destination-url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,36 @@ describe('when setting destinationUrl on ogc request', function () {
});
});

describe('when making a request with a valid mixed case destinationUrl', function () {
hookGetBucketRegion('us-west-2');
reprojectAndZarrQuery.destinationUrl = 's3://dummy/UPPERCASE_PATH/p1';
hookRangesetRequest('1.0.0', collection, 'all', { query: { ...reprojectAndZarrQuery } });
hookRedirect('anonymous');
hookTransaction();

it('returns 200 status code for the job', async function () {
expect(this.res.status).to.equal(200);
});

it('does not include the dataExpiration field in the job status', function () {
expect(this.res.body.dataExpiration).to.be.undefined;
});

it('the job has harmony-job-status-link file created with the job status link', async function () {
expect(this.res.status).to.equal(200);
const jobId = JSON.parse(this.res.text).jobID;
const s3Url = 's3://dummy/UPPERCASE_PATH/p1/' + jobId + '/harmony-job-status-link';
const statusLink = await defaultObjectStore().getObject(s3Url);
// this.res.request.url is the job status link
expect(statusLink).to.equal(this.res.request.url);
});

it('sets the destination_url on the job in db', async function () {
const retrieved = await Job.forUser(this.trx, 'anonymous');
expect(retrieved.data[0].destination_url).to.eq('s3://dummy/UPPERCASE_PATH/p1');
});
});

describe('when making a request with an invalid destinationUrl with invalid S3 url format', function () {
StubService.hook({ params: { status: 'successful' } });
hookRangesetRequest('1.0.0', collection, 'all', { query: { destinationUrl: 'abcd' } });
Expand Down

0 comments on commit f019da9

Please sign in to comment.