Skip to content

Commit

Permalink
BC-5566 - fix merlin feathers service (#4480)
Browse files Browse the repository at this point in the history
Rename the merlinToken feathers service path to a unique path instead of subpath of edu-shraring

Not clear why, but feathers service was suddenly mapped wrong and calling edu-sharing service instead of merlinToken service.
Changing the order of the services load helped, but then lots of tests fail.
  • Loading branch information
virgilchiriac authored Oct 19, 2023
1 parent f2f0b36 commit fa3a4f7
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 47 deletions.
4 changes: 2 additions & 2 deletions src/services/edusharing/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class EduSharingPlayer {
throw new MethodNotAllowed('This feature is disabled on this instance');
}
const esPlayer = EduSharingConnectorV7.getPlayerForNode(uuid);

return esPlayer;
}
}
Expand All @@ -49,7 +49,7 @@ class MerlinToken {
module.exports = (app) => {
const eduSharingRoute = '/edu-sharing';
const eduSharingPlayerRoute = '/edu-sharing/player';
const merlinRoute = '/edu-sharing/merlinToken';
const merlinRoute = '/edu-sharing-merlinToken';
const docRoute = '/edu-sharing/api';

app.use(eduSharingRoute, new EduSharing());
Expand Down
90 changes: 46 additions & 44 deletions src/services/lesson/hooks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const convertMerlinUrl = async (context) => {
await Promise.all(
content.content.resources.map(async (resource) => {
if (resource && resource.merlinReference) {
resource.url = await context.app.service('edu-sharing/merlinToken').find({
resource.url = await context.app.service('edu-sharing-merlinToken').find({
...context.params,
query: { ...context.params.query, merlinReference: resource.merlinReference },
});
Expand All @@ -82,7 +82,7 @@ const convertMerlinUrl = async (context) => {
await Promise.all(
materialIds.map(async (material) => {
if (material.merlinReference) {
material.url = await context.app.service('edu-sharing/merlinToken').find({
material.url = await context.app.service('edu-sharing-merlinToken').find({
...context.params,
query: {
...context.params.query,
Expand Down Expand Up @@ -229,48 +229,50 @@ const populateWhitelist = {
],
};

exports.before = () => ({
all: [authenticate('jwt'), mapUsers],
find: [
hasPermission('TOPIC_VIEW'),
iff(isProvider('external'), validateLessonFind),
iff(isProvider('external'), getRestrictPopulatesHook(populateWhitelist)),
iff(isProvider('external'), restrictToUsersCoursesLessons),
],
get: [
hasPermission('TOPIC_VIEW'),
iff(isProvider('external'), getRestrictPopulatesHook(populateWhitelist)),
iff(isProvider('external'), restrictToUsersCoursesLessons),
],
create: [
checkIfCourseGroupLesson.bind(this, 'COURSEGROUP_CREATE', 'TOPIC_CREATE', true),
injectUserId,
checkCorrectCourseOrTeamId,
setPosition,
iff(isProvider('external'), preventPopulate),
],
update: [
iff(isProvider('external'), preventPopulate),
permitGroupOperation,
ifNotLocal(checkCorrectCourseOrTeamId),
iff(isProvider('external'), restrictToUsersCoursesLessons),
checkIfCourseGroupLesson.bind(this, 'COURSEGROUP_EDIT', 'TOPIC_EDIT', false),
],
patch: [
attachMerlinReferenceToLesson,
checkIfCourseGroupLesson.bind(this, 'COURSEGROUP_EDIT', 'TOPIC_EDIT', false),
permitGroupOperation,
ifNotLocal(checkCorrectCourseOrTeamId),
iff(isProvider('external'), restrictToUsersCoursesLessons),
iff(isProvider('external'), preventPopulate),
],
remove: [
checkIfCourseGroupLesson.bind(this, 'COURSEGROUP_CREATE', 'TOPIC_CREATE', false),
permitGroupOperation,
iff(isProvider('external'), restrictToUsersCoursesLessons),
iff(isProvider('external'), preventPopulate),
],
});
exports.before = () => {
return {
all: [authenticate('jwt'), mapUsers],
find: [
hasPermission('TOPIC_VIEW'),
iff(isProvider('external'), validateLessonFind),
iff(isProvider('external'), getRestrictPopulatesHook(populateWhitelist)),
iff(isProvider('external'), restrictToUsersCoursesLessons),
],
get: [
hasPermission('TOPIC_VIEW'),
iff(isProvider('external'), getRestrictPopulatesHook(populateWhitelist)),
iff(isProvider('external'), restrictToUsersCoursesLessons),
],
create: [
checkIfCourseGroupLesson.bind(this, 'COURSEGROUP_CREATE', 'TOPIC_CREATE', true),
injectUserId,
checkCorrectCourseOrTeamId,
setPosition,
iff(isProvider('external'), preventPopulate),
],
update: [
iff(isProvider('external'), preventPopulate),
permitGroupOperation,
ifNotLocal(checkCorrectCourseOrTeamId),
iff(isProvider('external'), restrictToUsersCoursesLessons),
checkIfCourseGroupLesson.bind(this, 'COURSEGROUP_EDIT', 'TOPIC_EDIT', false),
],
patch: [
attachMerlinReferenceToLesson,
checkIfCourseGroupLesson.bind(this, 'COURSEGROUP_EDIT', 'TOPIC_EDIT', false),
permitGroupOperation,
ifNotLocal(checkCorrectCourseOrTeamId),
iff(isProvider('external'), restrictToUsersCoursesLessons),
iff(isProvider('external'), preventPopulate),
],
remove: [
checkIfCourseGroupLesson.bind(this, 'COURSEGROUP_CREATE', 'TOPIC_CREATE', false),
permitGroupOperation,
iff(isProvider('external'), restrictToUsersCoursesLessons),
iff(isProvider('external'), preventPopulate),
],
};
};

exports.after = {
all: [],
Expand Down
2 changes: 1 addition & 1 deletion test/services/edusharing/services/merlinGenerator.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('Merlin Token Generator', () => {

before(async () => {
app = await appPromise();
MerlinTokenGeneratorService = app.service('edu-sharing/merlinToken');
MerlinTokenGeneratorService = app.service('edu-sharing-merlinToken');
server = await app.listen(0);
nestServices = await setupNestServices(app);
});
Expand Down

0 comments on commit fa3a4f7

Please sign in to comment.