From 0e8903c3f71bf02c64287f4ed16627847b7df524 Mon Sep 17 00:00:00 2001 From: dyedwiper Date: Thu, 25 Jan 2024 17:02:06 +0100 Subject: [PATCH] Remove legacy code --- src/services/school/docs/openapi.yaml | 42 ---------------- .../school/hooks/publicSchools.hooks.js | 21 -------- src/services/school/index.js | 17 ------- src/services/school/services/schoolsList.js | 30 ------------ test/routes/whitelist.js | 2 - test/services/school/index.test.js | 48 ------------------- .../school/services/permissions.test.js | 2 - 7 files changed, 162 deletions(-) delete mode 100644 src/services/school/hooks/publicSchools.hooks.js delete mode 100644 src/services/school/services/schoolsList.js diff --git a/src/services/school/docs/openapi.yaml b/src/services/school/docs/openapi.yaml index e91a426563b..20d6e65c039 100644 --- a/src/services/school/docs/openapi.yaml +++ b/src/services/school/docs/openapi.yaml @@ -110,48 +110,6 @@ components: skip: type: integer paths: - /schoolsList: - get: - parameters: - - description: Number of results to return - in: query - name: $limit - schema: - type: integer - - description: Number of results to skip - in: query - name: $skip - schema: - type: integer - - description: Property to sort results - in: query - name: $sort - style: deepObject - schema: - type: object - - description: Query parameters to filter - in: query - name: filter - style: form - explode: true - schema: - $ref: '#/components/schemas/schools' - responses: - '200': - description: success - content: - application/json: - schema: - $ref: '#/components/schemas/schools_list' - '401': - description: not authenticated - '500': - description: general error - description: Retrieves a list of all schools. - summary: '' - tags: - - schoolsList - security: [ ] /schools: get: parameters: diff --git a/src/services/school/hooks/publicSchools.hooks.js b/src/services/school/hooks/publicSchools.hooks.js deleted file mode 100644 index ba0522e2a0c..00000000000 --- a/src/services/school/hooks/publicSchools.hooks.js +++ /dev/null @@ -1,21 +0,0 @@ -const { disallow } = require('feathers-hooks-common'); - -exports.before = { - all: [], - find: [], - get: [disallow()], - create: [disallow()], - update: [disallow()], - patch: [disallow()], - remove: [disallow()], -}; - -exports.after = { - all: [], - find: [], - get: [], - create: [], - update: [], - patch: [], - remove: [], -}; diff --git a/src/services/school/index.js b/src/services/school/index.js index b897ce13440..f762506daa7 100644 --- a/src/services/school/index.js +++ b/src/services/school/index.js @@ -5,11 +5,9 @@ const path = require('path'); const schoolModels = require('./model'); const hooks = require('./hooks'); -const publicSchoolsHooks = require('./hooks/publicSchools.hooks'); const schoolGroupHooks = require('./hooks/schoolGroup.hooks'); const { SchoolMaintenanceService } = require('./maintenance'); const { HandlePermissions, handlePermissionsHooks } = require('./services/permissions'); -const { SchoolsListService } = require('./services/schoolsList'); module.exports = function schoolServices() { const app = this; @@ -31,21 +29,6 @@ module.exports = function schoolServices() { const schoolService = app.service('/schools'); schoolService.hooks(hooks); - // public endpoint, called from login - app.use('/schoolsList/api', staticContent(path.join(__dirname, './docs/openapi.yaml'))); - app.use( - '/schoolsList', - new SchoolsListService({ - Model: schoolModels.schoolModel, - paginate: { - default: 2, - max: 3, - }, - }) - ); - const schoolsListService = app.service('schoolsList'); - schoolsListService.hooks(publicSchoolsHooks); - app.use('/schools/:schoolId/maintenance', new SchoolMaintenanceService()); /* schoolGroup service */ diff --git a/src/services/school/services/schoolsList.js b/src/services/school/services/schoolsList.js deleted file mode 100644 index 66fa5e65799..00000000000 --- a/src/services/school/services/schoolsList.js +++ /dev/null @@ -1,30 +0,0 @@ -const { schoolModel } = require('../model'); - -class SchoolsListService { - constructor(options) { - this.options = options || {}; - this.docs = {}; - } - - async find() { - const schoolQuery = { - purpose: { $ne: 'expert' }, - }; - const systemsQuery = { - path: 'systems', - select: '_id type alias oauthConfig.provider', - match: { - $or: [{ type: { $ne: 'ldap' } }, { 'ldapConfig.active': { $eq: true } }], - }, - }; - return schoolModel.find(schoolQuery).populate(systemsQuery).select(['name', 'systems']).sort('name').lean().exec(); - } - - setup(app) { - this.app = app; - } -} - -module.exports = { - SchoolsListService, -}; diff --git a/test/routes/whitelist.js b/test/routes/whitelist.js index 1e0e61e31ae..b982a89d26d 100644 --- a/test/routes/whitelist.js +++ b/test/routes/whitelist.js @@ -10,7 +10,6 @@ const whitelistNoJwt = { 'oauth2/baseUrl': { get: 200 }, registrationlink: { post: 201 }, roster: { get: 200 }, - schoolsList: { get: 200 }, 'tools/link': { post: 404 }, years: { get: 200 }, 'system_info/haproxy': { get: 200 }, @@ -20,7 +19,6 @@ const whitelistNoJwt = { const whitelistInvalidJwt = { ...whitelistNoJwt, - schoolsList: { get: 401 }, years: { get: 401 }, gradeLevels: { get: 401 }, }; diff --git a/test/services/school/index.test.js b/test/services/school/index.test.js index f1817289b53..12d6c2cc44e 100644 --- a/test/services/school/index.test.js +++ b/test/services/school/index.test.js @@ -628,51 +628,3 @@ describe('years service', () => { assert.ok(app.service('gradeLevels')); }); }); - -describe('schoolsList service', () => { - let app; - let server; - let schoolsListService; - - before(async () => { - app = await appPromise(); - server = await app.listen(); - schoolsListService = app.service('schoolsList'); - }); - - after(async () => { - await testObjects.cleanup(); - await server.close(); - }); - - it('registered the schoolsList services', () => { - assert.ok(schoolsListService); - }); - - describe('find', () => { - before('load data and set samples', async () => { - await createSchool(); - }); - - it('can be accessed unautorized', async () => { - const params = { - provider: 'rest', - headers: { - authorization: undefined, - }, - account: undefined, - query: {}, - }; - const result = await schoolsListService.find(params); - expect(result.length).gt(0); - }); - - it('should return only certain fields', async () => { - const schoolsList = await schoolsListService.find(); - const fields = ['name', '_id', 'systems']; - schoolsList.forEach((school) => { - expect(Object.keys(school).every((field) => fields.includes(field))).to.be.true; - }); - }); - }); -}); diff --git a/test/services/school/services/permissions.test.js b/test/services/school/services/permissions.test.js index 1709d3bc138..e565f576c4f 100644 --- a/test/services/school/services/permissions.test.js +++ b/test/services/school/services/permissions.test.js @@ -32,8 +32,6 @@ describe('permissons service', () => { app.unuse('schools'); app.unuse('schools/api'); app.unuse('/schools/:schoolId/maintenance'); - app.unuse('schoolsList'); - app.unuse('schoolsList/api'); app.unuse('schoolGroup'); app.unuse('gradeLevels'); app.unuse('/school/teacher/studentvisibility');