@@ -5,12 +5,7 @@ import type { FindCursor } from "mongodb";
55import { Long } from "mongodb" ;
66import { afterEach , beforeEach , describe , expect , it , vi } from "vitest" ;
77import type { ExportsManagerConfig } from "../../../src/common/exportsManager.js" ;
8- import {
9- ensureExtension ,
10- isExportExpired ,
11- ExportsManager ,
12- validateExportName ,
13- } from "../../../src/common/exportsManager.js" ;
8+ import { ensureExtension , isExportExpired , ExportsManager } from "../../../src/common/exportsManager.js" ;
149import type { AvailableExport } from "../../../src/common/exportsManager.js" ;
1510import { config } from "../../../src/common/config.js" ;
1611import { ROOT_DIR } from "../../accuracy/sdk/constants.js" ;
@@ -30,14 +25,10 @@ const exportsManagerConfig: ExportsManagerConfig = {
3025function getExportNameAndPath ( {
3126 uniqueExportsId = new ObjectId ( ) . toString ( ) ,
3227 uniqueFileId = new ObjectId ( ) . toString ( ) ,
33- database = "foo" ,
34- collection = "bar" ,
3528} :
3629 | {
3730 uniqueExportsId ?: string ;
3831 uniqueFileId ?: string ;
39- database ?: string ;
40- collection ?: string ;
4132 }
4233 | undefined = { } ) : {
4334 sessionExportsPath : string ;
@@ -46,7 +37,7 @@ function getExportNameAndPath({
4637 exportURI : string ;
4738 uniqueExportsId : string ;
4839} {
49- const exportName = `${ database } . ${ collection } . ${ uniqueFileId } .json` ;
40+ const exportName = `${ uniqueFileId } .json` ;
5041 // This is the exports directory for a session.
5142 const sessionExportsPath = path . join ( exportsPath , uniqueExportsId ) ;
5243 const exportPath = path . join ( sessionExportsPath , exportName ) ;
@@ -248,7 +239,7 @@ describe("ExportsManager unit test", () => {
248239 } ) ;
249240
250241 it ( "should handle encoded name" , async ( ) => {
251- const { exportName, exportURI } = getExportNameAndPath ( { database : "some database" , collection : "coll " } ) ;
242+ const { exportName, exportURI } = getExportNameAndPath ( { uniqueFileId : "1FOO 2BAR " } ) ;
252243 const { cursor } = createDummyFindCursor ( [ ] ) ;
253244 const exportAvailableNotifier = getExportAvailableNotifier ( encodeURI ( exportURI ) , manager ) ;
254245 await manager . createJSONExport ( {
@@ -611,16 +602,6 @@ describe("#ensureExtension", () => {
611602 } ) ;
612603} ) ;
613604
614- describe ( "#validateExportName" , ( ) => {
615- it ( "should return decoded name when name is valid" , ( ) => {
616- expect ( validateExportName ( encodeURIComponent ( "Test Name.json" ) ) ) . toEqual ( "Test Name.json" ) ;
617- } ) ;
618- it ( "should throw when name is invalid" , ( ) => {
619- expect ( ( ) => validateExportName ( "NoExtension" ) ) . toThrow ( "Provided export name has no extension" ) ;
620- expect ( ( ) => validateExportName ( "../something.json" ) ) . toThrow ( "Invalid export name: path traversal hinted" ) ;
621- } ) ;
622- } ) ;
623-
624605describe ( "#isExportExpired" , ( ) => {
625606 it ( "should return true if export is expired" , ( ) => {
626607 const createdAt = Date . now ( ) - 1000 ;
0 commit comments