Skip to content
Open
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
"@znemz/cesium-navigation": "4.0.0",
"ajv": "8.18.0",
"assert": "2.0.0",
"axios": "0.30.3",
"axios": "0.32.0",
"bootstrap": "3.4.1",
"buffer": "6.0.3",
"canvas-to-blob": "0.0.0",
Expand Down
17 changes: 16 additions & 1 deletion utility/build/postInstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,20 @@ const nodeModules = [
}
];

// Patch for axios-mock-adapter to support null-prototype headers introduced in axios 0.32.0.
// Remove when https://github.com/ctimmerm/axios-mock-adapter/issues/415 is fixed and released.
function patchAxiosMockAdapter(nodeModulesPath) {
const filePath = path.resolve(nodeModulesPath, 'axios-mock-adapter/src/handle_request.js');
if (!fs.existsSync(filePath)) return;
const original = 'config.headers.constructor.name === "AxiosHeaders"';
const patched = 'config.headers.constructor?.name === "AxiosHeaders"';
const content = fs.readFileSync(filePath, 'utf8');
if (content.includes(original)) {
console.log('* patching axios-mock-adapter handle_request.js (null-prototype compat)');
fs.writeFileSync(filePath, content.replace(original, patched), 'utf8');
}
}

function removeModules(nodeModulesPath) {
const removeModulesList = [
'leaflet-simple-graticule/node_modules'
Expand All @@ -45,6 +59,7 @@ function removeModules(nodeModulesPath) {
nodeModules.forEach((nodeModule) => {
if (fs.existsSync(nodeModule.path) && nodeModule.valid) {
console.log('remove in node_modules path', nodeModule.path);
removeModules(nodeModule.path)
removeModules(nodeModule.path);
patchAxiosMockAdapter(nodeModule.path);
}
});
4 changes: 2 additions & 2 deletions web/client/api/__tests__/GeoNode-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ describe('Test correctness of the GeoNode APIs (mock axios)', () => {
mockAxios.onGet().reply((config) => {
try {
expect(config.url).toBe('https://example.com/api/v2/resources');
expect(config.params).toEqual({
expect({...config.params}).toEqual({
'filter{metadata_only}': false,
include: [
'advertised',
Expand Down Expand Up @@ -135,7 +135,7 @@ describe('Test correctness of the GeoNode APIs (mock axios)', () => {
mockAxios.onGet().reply((config) => {
try {
expect(config.url).toBe('https://example.com/api/v2/resources');
expect(config.params).toEqual({
expect({...config.params}).toEqual({
'filter{metadata_only}': false,
include: [
'advertised',
Expand Down
2 changes: 1 addition & 1 deletion web/client/api/__tests__/GeoStoreDAO-test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ describe('Test correctness of the GeoStore APIs', () => {
try {
expect(data.baseURL).toBe('/rest/geostore/');
expect(data.url).toBe('/resources/tag');
expect(data.params).toEqual({ nameLike: '%Search%' });
expect({...data.params}).toEqual({ nameLike: '%Search%' });
} catch (e) {
done(e);
}
Expand Down
14 changes: 7 additions & 7 deletions web/client/api/__tests__/ResourcesCatalog-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('ResourceCatalog api', () => {
mockAxios.onPost().replyOnce((config) => {
try {
expect(config.url).toBe('/extjs/search/list');
expect(config.params).toEqual({ includeAttributes: true, includeTags: true, start: 0, limit: 12, sortBy: 'name', sortOrder: 'asc' });
expect({...config.params}).toEqual({ includeAttributes: true, includeTags: true, start: 0, limit: 12, sortBy: 'name', sortOrder: 'asc' });
expect(config.testConfig).toBe('test');
let json;
xml2js.parseString(config.data, { explicitArray: false }, (ignore, result) => {
Expand Down Expand Up @@ -79,7 +79,7 @@ describe('ResourceCatalog api', () => {
mockAxios.onPost().replyOnce((config) => {
try {
expect(config.url).toBe('/extjs/search/list');
expect(config.params).toEqual({ includeAttributes: true, includeTags: true, start: 0, limit: 12, sortBy: 'name', sortOrder: 'asc' });
expect({...config.params}).toEqual({ includeAttributes: true, includeTags: true, start: 0, limit: 12, sortBy: 'name', sortOrder: 'asc' });
expect(config.testConfig).toBe('test');
let json;
xml2js.parseString(config.data, { explicitArray: false }, (ignore, result) => {
Expand Down Expand Up @@ -127,7 +127,7 @@ describe('ResourceCatalog api', () => {
mockAxios.onPost().replyOnce((config) => {
try {
expect(config.url).toBe('/extjs/search/list');
expect(config.params).toEqual({ includeAttributes: true, includeTags: true, start: 0, limit: 12, sortBy: 'name', sortOrder: 'asc' });
expect({...config.params}).toEqual({ includeAttributes: true, includeTags: true, start: 0, limit: 12, sortBy: 'name', sortOrder: 'asc' });
expect(config.testConfig).toBe('test');
let json;
xml2js.parseString(config.data, { explicitArray: false }, (ignore, result) => {
Expand Down Expand Up @@ -179,7 +179,7 @@ describe('ResourceCatalog api', () => {
mockAxios.onPost().replyOnce((config) => {
try {
expect(config.url).toBe('/extjs/search/list');
expect(config.params).toEqual({ includeAttributes: true, includeTags: true, start: 24, limit: 24, sortBy: 'name', sortOrder: 'asc', favoritesOnly: true });
expect({...config.params}).toEqual({ includeAttributes: true, includeTags: true, start: 24, limit: 24, sortBy: 'name', sortOrder: 'asc', favoritesOnly: true });
let json;
xml2js.parseString(config.data, { explicitArray: false }, (ignore, result) => {
json = result;
Expand Down Expand Up @@ -277,7 +277,7 @@ describe('ResourceCatalog api', () => {
mockAxios.onPost().replyOnce((config) => {
try {
expect(config.url).toBe('/extjs/search/list');
expect(config.params).toEqual({ includeAttributes: true, includeTags: true, start: 24, limit: 24, sortBy: 'name', sortOrder: 'asc', favoritesOnly: true });
expect({...config.params}).toEqual({ includeAttributes: true, includeTags: true, start: 24, limit: 24, sortBy: 'name', sortOrder: 'asc', favoritesOnly: true });
let json;
xml2js.parseString(config.data, { explicitArray: false }, (ignore, result) => {
json = result;
Expand Down Expand Up @@ -382,7 +382,7 @@ describe('ResourceCatalog api', () => {
mockAxios.onPost().replyOnce((config) => {
try {
expect(config.url).toBe('/extjs/search/list');
expect(config.params).toEqual({ includeAttributes: true, includeTags: true, start: 24, limit: 24, sortBy: 'name', sortOrder: 'asc', favoritesOnly: true });
expect({...config.params}).toEqual({ includeAttributes: true, includeTags: true, start: 24, limit: 24, sortBy: 'name', sortOrder: 'asc', favoritesOnly: true });
let json;
xml2js.parseString(config.data, { explicitArray: false }, (ignore, result) => {
json = result;
Expand Down Expand Up @@ -492,7 +492,7 @@ describe('ResourceCatalog api', () => {
mockAxios.onPost().replyOnce((config) => {
try {
expect(config.url).toBe('/extjs/search/list');
expect(config.params).toEqual({ includeAttributes: true, includeTags: true, start: 0, limit: 12, sortBy: 'name', sortOrder: 'asc' });
expect({...config.params}).toEqual({ includeAttributes: true, includeTags: true, start: 0, limit: 12, sortBy: 'name', sortOrder: 'asc' });
} catch (e) {
done(e);
}
Expand Down
16 changes: 8 additions & 8 deletions web/client/api/geofence/__tests__/RuleService-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe('RuleService API for GeoFence StandAlone', () => {
mockAxios.onGet().reply(config => {
expect(config.url).toBe(`/rules/count`);
expect(config.baseURL).toBe(`${BASE_URL}`);
expect(config.params).toEqual(EXPECTED_PARAMS);
expect({...config.params}).toEqual(EXPECTED_PARAMS);
return [200, '2'];
});
RuleService.getRulesCount(PARAMS)
Expand All @@ -61,7 +61,7 @@ describe('RuleService API for GeoFence StandAlone', () => {
mockAxios.onGet().reply(config => {
expect(config.url).toBe(`/rules/count`);
expect(config.baseURL).toBe(`${BASE_URL}`);
expect(config.params).toEqual(EXPECTED_PARAMS);
expect({...config.params}).toEqual(EXPECTED_PARAMS);
return [200, "2"];
});
RuleService.getRulesCount(PARAMS)
Expand All @@ -77,7 +77,7 @@ describe('RuleService API for GeoFence StandAlone', () => {
mockAxios.onGet().reply(config => {
expect(config.url).toBe(`/rules`);
expect(config.baseURL).toBe(`${BASE_URL}`);
expect(config.params).toEqual({...EXPECTED_PARAMS, page: 1, entries: 10});
expect({...config.params}).toEqual({...EXPECTED_PARAMS, page: 1, entries: 10});
return [200, RULES];
});
RuleService.loadRules(1, PARAMS, 10).then(v => {
Expand All @@ -87,15 +87,15 @@ describe('RuleService API for GeoFence StandAlone', () => {
expect(v.rules[0].grant).toBe("ALLOW");
expect(v.rules[2].rolename).toBe("TEST_ROLE");
done();
});
}).catch(e => done(e));
});
it('loadRules with [field]Any param with/without value for its [field]', (done) => {
const PARAMS = { roleName: "ADMIN", workspaceAny: true, service: "WFS", serviceAny: false };
const EXPECTED_PARAMS = { roleName: "ADMIN", roleNameAny: true, service: "WFS", serviceAny: false }; // will skip workspaceAny as no value set for workspace + roleNameAny will be true
mockAxios.onGet().reply(config => {
expect(config.url).toBe(`/rules`);
expect(config.baseURL).toBe(`${BASE_URL}`);
expect(config.params).toEqual({...EXPECTED_PARAMS, page: 1, entries: 10});
expect({...config.params}).toEqual({...EXPECTED_PARAMS, page: 1, entries: 10});
return [200, RULES];
});
RuleService.loadRules(1, PARAMS, 10).then(v => {
Expand All @@ -105,18 +105,18 @@ describe('RuleService API for GeoFence StandAlone', () => {
expect(v.rules[0].grant).toBe("ALLOW");
expect(v.rules[0].workspace).toBe("WORKSPACE");
done();
});
}).catch(e => done(e));
});
it('moveRules', (done) => {
mockAxios.onGet().reply(config => {
expect(config.url).toBe(`/rules/move`);
expect(config.baseURL).toBe(`${BASE_URL}`);
expect(config.params).toEqual({ targetPriority: 1, rulesIds: '1,2' });
expect({...config.params}).toEqual({ targetPriority: 1, rulesIds: '1,2' });
return [200, RULES];
});
RuleService.moveRules(1, [{id: 1 }, { id: 2 }]).then(() => {
done();
});
}).catch(e => done(e));
});
it('addRule', (done) => {
mockAxios.onPost().reply(config => {
Expand Down
16 changes: 8 additions & 8 deletions web/client/api/geoserver/geofence/__tests__/RuleService-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('RuleService API for GeoFence StandAlone', () => {
mockAxios.onGet().reply(config => {
expect(config.url).toBe(`/rules/count`);
expect(config.baseURL).toBe(`${BASE_URL}`);
expect(config.params).toEqual(EXPECTED_PARAMS);
expect({...config.params}).toEqual(EXPECTED_PARAMS);
return [200, RULES];
});
RuleService.getRulesCount(PARAMS)
Expand All @@ -57,7 +57,7 @@ describe('RuleService API for GeoFence StandAlone', () => {
mockAxios.onGet().reply(config => {
expect(config.url).toBe(`/rules/count`);
expect(config.baseURL).toBe(`${BASE_URL}`);
expect(config.params).toEqual(EXPECTED_PARAMS);
expect({...config.params}).toEqual(EXPECTED_PARAMS);
return [200, RULES];
});
RuleService.getRulesCount(PARAMS)
Expand All @@ -74,7 +74,7 @@ describe('RuleService API for GeoFence StandAlone', () => {
mockAxios.onGet().reply(config => {
expect(config.url).toBe(`/rules`);
expect(config.baseURL).toBe(`${BASE_URL}`);
expect(config.params).toEqual({...EXPECTED_PARAMS, page: 1, entries: 10});
expect({...config.params}).toEqual({...EXPECTED_PARAMS, page: 1, entries: 10});
return [200, RULES];
});
RuleService.loadRules(1, PARAMS, 10).then(v => {
Expand All @@ -84,15 +84,15 @@ describe('RuleService API for GeoFence StandAlone', () => {
expect(v.rules[0].grant).toBe("ALLOW");
expect(v.rules[0].rolename).toBe("ADMIN");
done();
});
}).catch(e => done(e));
});
it('loadRules with [field]Any param with/without value for its [field]', (done) => {
const PARAMS = { roleName: "ADMIN", workspaceAny: true, service: "WFS", serviceAny: false };
const EXPECTED_PARAMS = { roleName: "ADMIN", roleNameAny: true, service: "WFS", serviceAny: false }; // will skip workspaceAny as no value set for workspace + roleNameAny will be true
mockAxios.onGet().reply(config => {
expect(config.url).toBe(`/rules`);
expect(config.baseURL).toBe(`${BASE_URL}`);
expect(config.params).toEqual({...EXPECTED_PARAMS, page: 1, entries: 10});
expect({...config.params}).toEqual({...EXPECTED_PARAMS, page: 1, entries: 10});
return [200, RULES];
});
RuleService.loadRules(1, PARAMS, 10).then(v => {
Expand All @@ -102,20 +102,20 @@ describe('RuleService API for GeoFence StandAlone', () => {
expect(v.rules[0].grant).toBe("ALLOW");
expect(v.rules[0].rolename).toBe("ADMIN");
done();
});
}).catch(e => done(e));
});
it('moveRules', (done) => {
mockAxios.onGet().reply(config => {
expect(config.url).toBe(`/rules/move`);
expect(config.baseURL).toBe(`${BASE_URL}`);
expect(config.params).toEqual({ targetPriority: 1, rulesIds: '1,2' });
expect({...config.params}).toEqual({ targetPriority: 1, rulesIds: '1,2' });
return [200, RULES];
});
RuleService.moveRules(1, [{id: 1 }, { id: 2 }]).then(v => {
expect(v.rules).toExist();
expect(v.rules.length).toBe(2);
done();
});
}).catch(e => done(e));
});
it('addRule', (done) => {
mockAxios.onPost().reply(config => {
Expand Down
Loading