@@ -3,6 +3,7 @@ const { expect } = chai;
33
44import { granuleToStac } from "../items" ;
55import { generateGranules } from "../../utils/testUtils" ;
6+ import { RelatedUrlType , UrlContentType } from "../../models/GraphQLModels" ;
67
78const [ baseGranule ] = generateGranules ( 1 ) ;
89
@@ -268,4 +269,112 @@ describe("granuleToStac", () => {
268269 } ) ;
269270 } ) ;
270271 } ) ;
272+ describe ( "given it provides AWS S3 links in related urls" , ( ) => {
273+ it ( "should return a STACItem" , ( ) => {
274+ const [ granule ] = generateGranules ( 1 ) ;
275+ granule . relatedUrls ?. push (
276+ {
277+ urlContentType : UrlContentType . DISTRIBUTION_URL ,
278+ url : "s3://myBucket/path/to/object/A.01.tif" ,
279+ description : "S3 Download" ,
280+ type : RelatedUrlType . GET_DATA_VIA_DIRECT_ACCESS ,
281+ } ,
282+ {
283+ urlContentType : UrlContentType . DISTRIBUTION_URL ,
284+ url : "s3://myBucket/path/to/object/A.02.tif" ,
285+ description : "S3 Download" ,
286+ type : RelatedUrlType . GET_DATA_VIA_DIRECT_ACCESS ,
287+ }
288+ ) ;
289+ const item = granuleToStac ( granule ) ;
290+ expect ( item ) . to . deep . equal ( {
291+ type : "Feature" ,
292+ id : granule . title ,
293+ stac_version : "1.0.0" ,
294+ stac_extensions : [ "https://stac-extensions.github.io/storage/v2.0.0/schema.json" ] ,
295+ bbox : [ - 180 , - 90 , 180 , 90 ] ,
296+ geometry : null ,
297+ properties : {
298+ datetime : "2009-09-14T00:00:00.000Z" ,
299+ start_datetime : "2009-09-14T00:00:00.000Z" ,
300+ end_datetime : "2010-09-14T00:00:00.000Z" ,
301+ "storage:schemes" : {
302+ aws : {
303+ bucket : "myBucket" ,
304+ platform : "https://{bucket}.s3.{region}.amazonaws.com" ,
305+ region : "us-west-2" ,
306+ type : "aws-s3" ,
307+ } ,
308+ } ,
309+ } ,
310+ collection : "TEST_COLLECTION_1" ,
311+ links : [
312+ {
313+ href : "undefined/search/concepts/G000000000-TEST_PROV.json" ,
314+ rel : "via" ,
315+ title : "CMR JSON metadata for item" ,
316+ type : "application/json" ,
317+ } ,
318+ {
319+ href : "undefined/search/concepts/G000000000-TEST_PROV.umm_json" ,
320+ rel : "via" ,
321+ title : "CMR UMM_JSON metadata for item" ,
322+ type : "application/vnd.nasa.cmr.umm+json" ,
323+ } ,
324+ ] ,
325+ assets : {
326+ B09 : {
327+ description : "Browse image for Earthdata Search" ,
328+ href : "ftp://e4ftl014.cr.usgs.gov/MODIS_Composites/MOTA/.B09.tif" ,
329+ title : "Direct Download [0]" ,
330+ roles : [ "data" ] ,
331+ } ,
332+ asset_key : {
333+ description : "Example of bad url data" ,
334+ href : "ftp://e4ftl015/ExampleBadUrl" ,
335+ title : "Direct Download [1]" ,
336+ roles : [ "data" ] ,
337+ } ,
338+ s3_01 : {
339+ href : "s3://myBucket/path/to/object/A.01.tif" ,
340+ title : "S3 Direct Download [0]" ,
341+ description : "S3 Download" ,
342+ roles : [ "data" ] ,
343+ "storage:refs" : [ "aws" ] ,
344+ } ,
345+ s3_02 : {
346+ href : "s3://myBucket/path/to/object/A.02.tif" ,
347+ title : "S3 Direct Download [1]" ,
348+ description : "S3 Download" ,
349+ roles : [ "data" ] ,
350+ "storage:refs" : [ "aws" ] ,
351+ } ,
352+ provider_metadata : {
353+ href : "ftp://e4ftl01.cr.usgs.gov/MODIS_Composites/MOTA/MCD43A4.005/2009.09.14/MCD43A4.A2009257.h29v03.005.2009276045828.hdf.xml" ,
354+ description : "metadata" ,
355+ title : "Provider Metadata" ,
356+ roles : [ "metadata" ] ,
357+ } ,
358+ thumbnail_0 : {
359+ href : "ftp://e4ftl01.cr.usgs.gov/MODIS_Composites/MOTA/MCD43A4.005/2009.09.14/MCD43A4.A2009257.h29v03.005.2009276045828.vinr.img" ,
360+ title : "Thumbnail [0]" ,
361+ description : "Browse image for Earthdata Search" ,
362+ roles : [ "thumbnail" ] ,
363+ } ,
364+ thumbnail_1 : {
365+ href : "ftp://e4ftl012/ExampleBadUrl" ,
366+ title : "Thumbnail [1]" ,
367+ description : "Browse image for Earthdata Search" ,
368+ roles : [ "thumbnail" ] ,
369+ } ,
370+ metadata : {
371+ href : "undefined/search/concepts/G000000000-TEST_PROV.xml" ,
372+ roles : [ "metadata" ] ,
373+ title : "CMR XML metadata for G000000000-TEST_PROV" ,
374+ type : "application/xml" ,
375+ } ,
376+ } ,
377+ } ) ;
378+ } ) ;
379+ } ) ;
271380} ) ;
0 commit comments