Skip to content

Commit

Permalink
do not freeze authApi for testing only
Browse files Browse the repository at this point in the history
  • Loading branch information
siosonel committed Jan 14, 2025
1 parent 17c5259 commit 1682df4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion server/src/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ async function maySetAuthRoutes(app, basepath = '', _serverconfig = null) {
authApi.userCanAccess = () => true
authApi.getRequiredCredForDsEmbedder = () => undefined
authApi.getPayloadFromHeaderAuth = () => ({})
Object.freeze(authApi)
// custom auth for testing
if (serverconfig.debugmode && !app.doNotFreezeAuth) Object.freeze(authApi)
return
}
try {
Expand Down Expand Up @@ -642,6 +643,9 @@ async function maySetAuthRoutes(app, basepath = '', _serverconfig = null) {
}
return { errors }
}

// custom auth for testing
if (serverconfig.debugmode && !app.doNotFreezeAuth) Object.freeze(authApi)
}

function getSessionId(req, cred) {
Expand Down
1 change: 1 addition & 0 deletions server/src/test/auth.unit.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const secrets = {
function appInit() {
// mock the express router api
const app = {
doNotFreezeAuthApi: true,
routes: {},
middlewares: {},
setRoute(method, route, handler) {
Expand Down

0 comments on commit 1682df4

Please sign in to comment.