-
Notifications
You must be signed in to change notification settings - Fork 14
[OGUI-1581] Split action for taking/releasing all locks in API router #2672
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
graduta
merged 12 commits into
dev
from
feature/pepijndik/OGUI-1581/Splitactionfortaking/releasingalllocksinAPIrouter
Dec 3, 2024
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
e70c329
Added Locks Manage All Detectors endpoint
cbe65d1
Add Expected Results to test
123cb0e
Merge branch 'dev' into feature/pepijndik/OGUI-1581/Splitactionfortak…
bcfb562
Added Tests: Locks/All needs Global role
47b890f
Added DetectorId Middleware
2df8970
Merge branch 'dev' into feature/pepijndik/OGUI-1581/Splitactionfortak…
9e8953f
Resolved Issues
da25fdc
Resolve DetectorIDState Naming
33a4068
Resolved New Line end of file
083903f
Removed Should integrate with a express route
3e01c3a
Fixed CodeScanning
7512a91
Removed unrelated comments
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| /** | ||
| * @license | ||
| * Copyright 2019-2024 CERN and copyright holders of ALICE O2. | ||
| * See http://alice-o2.web.cern.ch/copyright for details of the copyright holders. | ||
| * All rights not expressly granted are reserved. | ||
| * | ||
| * This software is distributed under the terms of the GNU General Public | ||
| * License v3 (GPL Version 3), copied verbatim in the file "COPYING". | ||
| * | ||
| * In applying this license CERN does not waive the privileges and immunities | ||
| * granted to it by virtue of its status as an Intergovernmental Organization | ||
| * or submit itself to any jurisdiction. | ||
| */ | ||
|
|
||
| /** | ||
| * Enum for detector IDs. | ||
| */ | ||
| const DetectorId = Object.freeze({ | ||
| ALL: 'ALL', | ||
| }); | ||
|
|
||
| exports.DetectorId = DetectorId; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| /** | ||
| * @license | ||
| * Copyright 2019-2024 CERN and copyright holders of ALICE O2. | ||
| * See http://alice-o2.web.cern.ch/copyright for details of the copyright holders. | ||
| * All rights not expressly granted are reserved. | ||
| * | ||
| * This software is distributed under the terms of the GNU General Public | ||
| * License v3 (GPL Version 3), copied verbatim in the file "COPYING". | ||
| * | ||
| * In applying this license CERN does not waive the privileges and immunities | ||
| * granted to it by virtue of its status as an Intergovernmental Organization | ||
| * or submit itself to any jurisdiction. | ||
| */ | ||
|
|
||
| /** | ||
| * Middleware function to add detectorID to the request object | ||
| * @param {Request} req - HTTP Request object | ||
| * @param {Next} next - HTTP Next object to use if checks pass | ||
| * @param {Response} res - HTTP Response object | ||
| * @return {void} | ||
| */ | ||
| const addDetectorIdMiddleware = (detectorId) => { | ||
| return async (req, res, next) => { | ||
| req.params.detectorId = detectorId; | ||
| next(); | ||
| }; | ||
| } | ||
|
|
||
| exports.addDetectorIdMiddleware = addDetectorIdMiddleware | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
Control/test/lib/middleware/mocha-addDetectorId.middleware.test.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| const assert = require('assert'); | ||
| const sinon = require('sinon'); | ||
|
|
||
| // Import the middleware | ||
| const { addDetectorIdMiddleware } = require('../../../lib/middleware/addDetectorId.middleware'); | ||
|
|
||
| describe('`addDetectorIdMiddleware` test suite', () => { | ||
| it('should add the specified detectorId to req.params and call next()', () => { | ||
| const detectorId = '1234'; | ||
| const req = { params: {} }; // Mock req object | ||
| const res = {}; // Mock res object | ||
| const next = sinon.stub(); // Mock next function | ||
|
|
||
| addDetectorIdMiddleware(detectorId)(req, res, next); | ||
|
|
||
| // Validate the detectorId is added | ||
| assert.strictEqual(req.params.detectorId, detectorId); | ||
| // Ensure next() is called | ||
| assert.ok(next.calledOnce); | ||
| }); | ||
|
|
||
| it('should overwrite existing detectorId in req.params', () => { | ||
| const detectorId = '5678'; | ||
| const req = { params: { detectorId: 'original' } }; | ||
| const res = {}; | ||
| const next = sinon.stub(); | ||
|
|
||
| addDetectorIdMiddleware(detectorId)(req, res, next); | ||
|
|
||
| // Validate the detectorId is overwritten | ||
| assert.strictEqual(req.params.detectorId, detectorId); | ||
| assert.ok(next.calledOnce); | ||
| }); | ||
|
|
||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.