|
@@ -10,6 +10,7 @@ import PageTagRelation from '../../../src/server/models/page-tag-relation';
|
|
|
import Tag from '../../../src/server/models/tag';
|
|
import Tag from '../../../src/server/models/tag';
|
|
|
import UserGroup from '../../../src/server/models/user-group';
|
|
import UserGroup from '../../../src/server/models/user-group';
|
|
|
import UserGroupRelation from '../../../src/server/models/user-group-relation';
|
|
import UserGroupRelation from '../../../src/server/models/user-group-relation';
|
|
|
|
|
+import { generalXssFilter } from '../../../src/services/general-xss-filter';
|
|
|
import { getInstance } from '../setup-crowi';
|
|
import { getInstance } from '../setup-crowi';
|
|
|
|
|
|
|
|
describe('PageService page operations with non-public pages', () => {
|
|
describe('PageService page operations with non-public pages', () => {
|
|
@@ -31,7 +32,7 @@ describe('PageService page operations with non-public pages', () => {
|
|
|
let Page;
|
|
let Page;
|
|
|
let Revision;
|
|
let Revision;
|
|
|
let User;
|
|
let User;
|
|
|
- let xssSpy;
|
|
|
|
|
|
|
+ let generalXssFilterProcessSpy;
|
|
|
|
|
|
|
|
let rootPage;
|
|
let rootPage;
|
|
|
|
|
|
|
@@ -290,7 +291,7 @@ describe('PageService page operations with non-public pages', () => {
|
|
|
},
|
|
},
|
|
|
]);
|
|
]);
|
|
|
|
|
|
|
|
- xssSpy = jest.spyOn(crowi.xss, 'process').mockImplementation(path => path);
|
|
|
|
|
|
|
+ generalXssFilterProcessSpy = jest.spyOn(generalXssFilter, 'process');
|
|
|
|
|
|
|
|
dummyUser1 = await User.findOne({ username: 'v5DummyUser1' });
|
|
dummyUser1 = await User.findOne({ username: 'v5DummyUser1' });
|
|
|
dummyUser2 = await User.findOne({ username: 'v5DummyUser2' });
|
|
dummyUser2 = await User.findOne({ username: 'v5DummyUser2' });
|
|
@@ -1139,7 +1140,7 @@ describe('PageService page operations with non-public pages', () => {
|
|
|
expect(page3Renamed.parent).toStrictEqual(page2Renamed._id);
|
|
expect(page3Renamed.parent).toStrictEqual(page2Renamed._id);
|
|
|
expect(normalizeGrantedGroups(page2Renamed.grantedGroups)).toStrictEqual(normalizeGrantedGroups(_page2.grantedGroups));
|
|
expect(normalizeGrantedGroups(page2Renamed.grantedGroups)).toStrictEqual(normalizeGrantedGroups(_page2.grantedGroups));
|
|
|
expect(normalizeGrantedGroups(page3Renamed.grantedGroups)).toStrictEqual(normalizeGrantedGroups(_page3.grantedGroups));
|
|
expect(normalizeGrantedGroups(page3Renamed.grantedGroups)).toStrictEqual(normalizeGrantedGroups(_page3.grantedGroups));
|
|
|
- expect(xssSpy).toHaveBeenCalled();
|
|
|
|
|
|
|
+ expect(generalXssFilterProcessSpy).toHaveBeenCalled();
|
|
|
});
|
|
});
|
|
|
test('Should throw with NOT grant normalized pages', async() => {
|
|
test('Should throw with NOT grant normalized pages', async() => {
|
|
|
const _pathD = '/np_rename4_destination';
|
|
const _pathD = '/np_rename4_destination';
|
|
@@ -1206,7 +1207,7 @@ describe('PageService page operations with non-public pages', () => {
|
|
|
expect(page2Renamed).toBeTruthy();
|
|
expect(page2Renamed).toBeTruthy();
|
|
|
expect(page3Renamed).toBeNull();
|
|
expect(page3Renamed).toBeNull();
|
|
|
expect(page2Renamed.parent).toBeNull();
|
|
expect(page2Renamed.parent).toBeNull();
|
|
|
- expect(xssSpy).toHaveBeenCalled();
|
|
|
|
|
|
|
+ expect(generalXssFilterProcessSpy).toHaveBeenCalled();
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
describe('Duplicate', () => {
|
|
describe('Duplicate', () => {
|
|
@@ -1240,7 +1241,7 @@ describe('PageService page operations with non-public pages', () => {
|
|
|
|
|
|
|
|
const duplicatedPage = await Page.findOne({ path: newPagePath });
|
|
const duplicatedPage = await Page.findOne({ path: newPagePath });
|
|
|
const duplicatedRevision = await Revision.findOne({ pageId: duplicatedPage._id });
|
|
const duplicatedRevision = await Revision.findOne({ pageId: duplicatedPage._id });
|
|
|
- expect(xssSpy).toHaveBeenCalled();
|
|
|
|
|
|
|
+ expect(generalXssFilterProcessSpy).toHaveBeenCalled();
|
|
|
expect(duplicatedPage).toBeTruthy();
|
|
expect(duplicatedPage).toBeTruthy();
|
|
|
expect(duplicatedPage._id).not.toStrictEqual(_page._id);
|
|
expect(duplicatedPage._id).not.toStrictEqual(_page._id);
|
|
|
expect(duplicatedPage.grant).toBe(_page.grant);
|
|
expect(duplicatedPage.grant).toBe(_page.grant);
|
|
@@ -1271,7 +1272,7 @@ describe('PageService page operations with non-public pages', () => {
|
|
|
const duplicatedPage2 = await Page.findOne({ path: '/dup_np_duplicate2/np_duplicate3' }).populate({ path: 'revision', model: 'Revision' });
|
|
const duplicatedPage2 = await Page.findOne({ path: '/dup_np_duplicate2/np_duplicate3' }).populate({ path: 'revision', model: 'Revision' });
|
|
|
const duplicatedRevision1 = duplicatedPage1.revision;
|
|
const duplicatedRevision1 = duplicatedPage1.revision;
|
|
|
const duplicatedRevision2 = duplicatedPage2.revision;
|
|
const duplicatedRevision2 = duplicatedPage2.revision;
|
|
|
- expect(xssSpy).toHaveBeenCalled();
|
|
|
|
|
|
|
+ expect(generalXssFilterProcessSpy).toHaveBeenCalled();
|
|
|
expect(duplicatedPage1).toBeTruthy();
|
|
expect(duplicatedPage1).toBeTruthy();
|
|
|
expect(duplicatedPage2).toBeTruthy();
|
|
expect(duplicatedPage2).toBeTruthy();
|
|
|
expect(duplicatedRevision1).toBeTruthy();
|
|
expect(duplicatedRevision1).toBeTruthy();
|
|
@@ -1316,7 +1317,7 @@ describe('PageService page operations with non-public pages', () => {
|
|
|
const duplicatedPage3 = await Page.findOne({ path: '/dup_np_duplicate4/np_duplicate6' }).populate({ path: 'revision', model: 'Revision' });
|
|
const duplicatedPage3 = await Page.findOne({ path: '/dup_np_duplicate4/np_duplicate6' }).populate({ path: 'revision', model: 'Revision' });
|
|
|
const duplicatedRevision1 = duplicatedPage1.revision;
|
|
const duplicatedRevision1 = duplicatedPage1.revision;
|
|
|
const duplicatedRevision3 = duplicatedPage3.revision;
|
|
const duplicatedRevision3 = duplicatedPage3.revision;
|
|
|
- expect(xssSpy).toHaveBeenCalled();
|
|
|
|
|
|
|
+ expect(generalXssFilterProcessSpy).toHaveBeenCalled();
|
|
|
expect(duplicatedPage1).toBeTruthy();
|
|
expect(duplicatedPage1).toBeTruthy();
|
|
|
expect(duplicatedPage2).toBeNull();
|
|
expect(duplicatedPage2).toBeNull();
|
|
|
expect(duplicatedPage3).toBeTruthy();
|
|
expect(duplicatedPage3).toBeTruthy();
|
|
@@ -1352,7 +1353,7 @@ describe('PageService page operations with non-public pages', () => {
|
|
|
const duplicatedPage2 = await Page.findOne({ path: '/dup_np_duplicate7/np_duplicate8' }).populate({ path: 'revision', model: 'Revision' });
|
|
const duplicatedPage2 = await Page.findOne({ path: '/dup_np_duplicate7/np_duplicate8' }).populate({ path: 'revision', model: 'Revision' });
|
|
|
const duplicatedPage3 = await Page.findOne({ path: '/dup_np_duplicate7/np_duplicate9' }).populate({ path: 'revision', model: 'Revision' });
|
|
const duplicatedPage3 = await Page.findOne({ path: '/dup_np_duplicate7/np_duplicate9' }).populate({ path: 'revision', model: 'Revision' });
|
|
|
const duplicatedRevision1 = duplicatedPage1.revision;
|
|
const duplicatedRevision1 = duplicatedPage1.revision;
|
|
|
- expect(xssSpy).toHaveBeenCalled();
|
|
|
|
|
|
|
+ expect(generalXssFilterProcessSpy).toHaveBeenCalled();
|
|
|
expect(duplicatedPage1).toBeTruthy();
|
|
expect(duplicatedPage1).toBeTruthy();
|
|
|
expect(duplicatedPage2).toBeFalsy();
|
|
expect(duplicatedPage2).toBeFalsy();
|
|
|
expect(duplicatedPage3).toBeFalsy();
|
|
expect(duplicatedPage3).toBeFalsy();
|
|
@@ -1394,7 +1395,7 @@ describe('PageService page operations with non-public pages', () => {
|
|
|
const duplicatedRevision1 = duplicatedPage1.revision;
|
|
const duplicatedRevision1 = duplicatedPage1.revision;
|
|
|
const duplicatedRevision2 = duplicatedPage2.revision;
|
|
const duplicatedRevision2 = duplicatedPage2.revision;
|
|
|
const duplicatedRevision3 = duplicatedPage3.revision;
|
|
const duplicatedRevision3 = duplicatedPage3.revision;
|
|
|
- expect(xssSpy).toHaveBeenCalled();
|
|
|
|
|
|
|
+ expect(generalXssFilterProcessSpy).toHaveBeenCalled();
|
|
|
expect(duplicatedPage1).toBeTruthy();
|
|
expect(duplicatedPage1).toBeTruthy();
|
|
|
expect(duplicatedPage2).toBeTruthy();
|
|
expect(duplicatedPage2).toBeTruthy();
|
|
|
expect(duplicatedPage3).toBeTruthy();
|
|
expect(duplicatedPage3).toBeTruthy();
|