chore: 🤖 add recursion and filtering to user and group mocks - ICU-4528 (#1190)
* chore: 🤖 add scope column to role principals and group members * chore: 🤖 add recursion and filtering to user and group mocks
This commit is contained in:
1 parent
817d2a44e1
commit
c2083aefab
1 file changed
+40
-6
@@ -141,9 +141,26 @@ export default function () {
|
||||
this.post('/scopes/:id_method', deauthHandler);
|
||||
|
||||
// IAM : Users
|
||||
this.get('/users', ({ users }, { queryParams: { scope_id: scopeId } }) => {
|
||||
return users.where({ scopeId });
|
||||
});
|
||||
this.get(
|
||||
'/users',
|
||||
({ users }, { queryParams: { scope_id, recursive, filter } }) => {
|
||||
let resultSet;
|
||||
if (recursive && scope_id === 'global') {
|
||||
resultSet = users.all();
|
||||
} else if (recursive) {
|
||||
resultSet = users.where((user) => {
|
||||
const userModel = users.find(user.id);
|
||||
return (
|
||||
user.scopeId === scope_id ||
|
||||
userModel?.scope?.scope?.id === scope_id
|
||||
);
|
||||
});
|
||||
} else {
|
||||
resultSet = users.where((user) => user.scopeId === scope_id);
|
||||
}
|
||||
return resultSet.filter(makeBooleanFilter(filter));
|
||||
}
|
||||
);
|
||||
this.post('/users');
|
||||
this.get('/users/:id');
|
||||
this.patch('/users/:id');
|
||||
@@ -175,9 +192,26 @@ export default function () {
|
||||
});
|
||||
|
||||
// IAM: Groups
|
||||
this.get('/groups', ({ groups }, { queryParams: { scope_id: scopeId } }) => {
|
||||
return groups.where({ scopeId });
|
||||
});
|
||||
this.get(
|
||||
'/groups',
|
||||
({ groups }, { queryParams: { scope_id, recursive, filter } }) => {
|
||||
let resultSet;
|
||||
if (recursive && scope_id === 'global') {
|
||||
resultSet = groups.all();
|
||||
} else if (recursive) {
|
||||
resultSet = groups.where((group) => {
|
||||
const groupModel = groups.find(group.id);
|
||||
return (
|
||||
group.scopeId === scope_id ||
|
||||
groupModel?.scope?.scope?.id === scope_id
|
||||
);
|
||||
});
|
||||
} else {
|
||||
resultSet = groups.where((group) => group.scopeId === scope_id);
|
||||
}
|
||||
return resultSet.filter(makeBooleanFilter(filter));
|
||||
}
|
||||
);
|
||||
this.post('/groups');
|
||||
this.get('/groups/:id');
|
||||
this.patch('/groups/:id');
|
||||
|
||||
Reference in new issue
Block a user