Differential D350 Diff 1272 test_utils/access-strategy-types/create_strategies_with_complex_pipeline.js
Changeset View
Changeset View
Standalone View
Standalone View
test_utils/access-strategy-types/create_strategies_with_complex_pipeline.js
const Promise = require("bluebird"); | const Promise = require("bluebird"); | ||||
module.exports = { | module.exports = { | ||||
allow_deny: function(App) { | allow_deny: function(App) { | ||||
const access_strategies = [ | const access_strategies = [ | ||||
"complex-deny-pipeline", | "complex-deny-pipeline", | ||||
"complex-allow-pipeline", | "complex-allow-pipeline", | ||||
]; | ]; | ||||
for (const strategy of access_strategies) { | for (const strategy of access_strategies) { | ||||
App.createChip(Sealious.AccessStrategyType, { | App.createChip(Sealious.AccessStrategyType, { | ||||
name: strategy, | name: strategy, | ||||
getRestrictingQuery: async function() { | getRestrictingQuery: async function() { | ||||
const query = new App.Query(); | const query = new App.Query(); | ||||
const id = query.lookup({ | const id = query.lookup({ | ||||
from: "numbers", | from: "numbers", | ||||
localField: "body.number", | localField: "number", | ||||
foreignField: "sealious_id", | foreignField: "sealious_id", | ||||
}); | }); | ||||
query.match({ | query.match({ | ||||
[`${id}._id`]: { | [`${id}._id`]: { | ||||
$exists: strategy === "complex-allow-pipeline", | $exists: strategy === "complex-allow-pipeline", | ||||
}, | }, | ||||
}); | }); | ||||
return query; | return query; | ||||
Show All 9 Lines |