Skip to content
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: 2 additions & 1 deletion src/webdav/services/webdav-folder.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ export class WebDavFolderService {
// all ancestors MUST already exist, or the method MUST fail
// with a 409 (Conflict) status code
throw new ConflictError(
`Parent folders not found on Internxt Drive at ${WebDavUtils.decodeUrl(parentPath, false)}`,
`Parent folders not found on Internxt Drive at ${WebDavUtils.decodeUrl(parentPath, false)},
createFullPath flag is set to: ${createFullPath}`,
);
}
const folders = parentPath.split('/').filter((f) => f.length > 0);
Expand Down
52 changes: 52 additions & 0 deletions test/services/config.service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,4 +178,56 @@ describe('Config service', () => {
expect(webdavConfigResult).to.be.deep.equal(defaultWebdavConfig);
expect(fsStub).toHaveBeenCalledWith(ConfigService.WEBDAV_CONFIGS_FILE, 'utf8');
});

it('should default to true when webdav config exists but createFullPath property is missing', async () => {
const partialWebdavConfig = {
host: '192.168.1.1',
port: '8080',
protocol: 'https',
timeoutMinutes: 30,
};
const stringConfig = JSON.stringify(partialWebdavConfig);

const fsStub = vi.spyOn(fs, 'readFile').mockResolvedValue(stringConfig);

const webdavConfigResult = await ConfigService.instance.readWebdavConfig();
expect(webdavConfigResult.createFullPath).to.be.equal(true);
expect(webdavConfigResult.host).to.be.equal(partialWebdavConfig.host);
expect(webdavConfigResult.port).to.be.equal(partialWebdavConfig.port);
expect(fsStub).toHaveBeenCalledWith(ConfigService.WEBDAV_CONFIGS_FILE, 'utf8');
});

it('shoud return false when webdav config has createFullPath explicitly set to false', async () => {
const webdavConfig = {
host: '192.168.1.1',
port: '8080',
protocol: 'https',
timeoutMinutes: 30,
createFullPath: false,
};
const stringConfig = JSON.stringify(webdavConfig);

const fsStub = vi.spyOn(fs, 'readFile').mockResolvedValue(stringConfig);

const webdavConfigResult = await ConfigService.instance.readWebdavConfig();
expect(webdavConfigResult.createFullPath).to.be.equal(false);
expect(fsStub).toHaveBeenCalledWith(ConfigService.WEBDAV_CONFIGS_FILE, 'utf8');
});

it('should return true when webdav config has createFullPath explicitly set to true', async () => {
const webdavConfig = {
host: '192.168.1.1',
port: '8080',
protocol: 'https',
timeoutMinutes: 30,
createFullPath: true,
};
const stringConfig = JSON.stringify(webdavConfig);

const fsStub = vi.spyOn(fs, 'readFile').mockResolvedValue(stringConfig);

const webdavConfigResult = await ConfigService.instance.readWebdavConfig();
expect(webdavConfigResult.createFullPath).to.be.equal(true);
expect(fsStub).toHaveBeenCalledWith(ConfigService.WEBDAV_CONFIGS_FILE, 'utf8');
});
});