From 9917f2d358c803665cc1bb5750f3f64a1b89577b Mon Sep 17 00:00:00 2001 From: mikiher Date: Fri, 29 Nov 2024 09:01:03 +0200 Subject: [PATCH] Change migration to v2.17.4 --- server/migrations/changelog.md | 2 +- ...4-use-subfolder-for-oidc-redirect-uris.js} | 20 ++++++------ ...-subfolder-for-oidc-redirect-uris.test.js} | 32 +++++++++---------- 3 files changed, 27 insertions(+), 27 deletions(-) rename server/migrations/{v2.17.3-use-subfolder-for-oidc-redirect-uris.js => v2.17.4-use-subfolder-for-oidc-redirect-uris.js} (82%) rename test/server/migrations/{v2.17.3-use-subfolder-for-oidc-redirect-uris.test.js => v2.17.4-use-subfolder-for-oidc-redirect-uris.test.js} (73%) diff --git a/server/migrations/changelog.md b/server/migrations/changelog.md index 8ba4fad0..67c09d53 100644 --- a/server/migrations/changelog.md +++ b/server/migrations/changelog.md @@ -8,4 +8,4 @@ Please add a record of every database migration that you create to this file. Th | v2.15.1 | v2.15.1-reindex-nocase | Fix potential db corruption issues due to bad sqlite extension introduced in v2.12.0 | | v2.15.2 | v2.15.2-index-creation | Creates author, series, and podcast episode indexes | | v2.17.0 | v2.17.0-uuid-replacement | Changes the data type of columns with UUIDv4 to UUID matching the associated model | -| v2.17.3 | v2.17.3-use-subfolder-for-oidc-redirect-uris | Save subfolder to OIDC redirect URIs to support existing installations | +| v2.17.4 | v2.17.4-use-subfolder-for-oidc-redirect-uris | Save subfolder to OIDC redirect URIs to support existing installations | diff --git a/server/migrations/v2.17.3-use-subfolder-for-oidc-redirect-uris.js b/server/migrations/v2.17.4-use-subfolder-for-oidc-redirect-uris.js similarity index 82% rename from server/migrations/v2.17.3-use-subfolder-for-oidc-redirect-uris.js rename to server/migrations/v2.17.4-use-subfolder-for-oidc-redirect-uris.js index d03783cd..03797e35 100644 --- a/server/migrations/v2.17.3-use-subfolder-for-oidc-redirect-uris.js +++ b/server/migrations/v2.17.4-use-subfolder-for-oidc-redirect-uris.js @@ -18,18 +18,18 @@ */ async function up({ context: { queryInterface, logger } }) { // Upwards migration script - logger.info('[2.17.3 migration] UPGRADE BEGIN: 2.17.3-use-subfolder-for-oidc-redirect-uris') + logger.info('[2.17.4 migration] UPGRADE BEGIN: 2.17.4-use-subfolder-for-oidc-redirect-uris') const serverSettings = await getServerSettings(queryInterface, logger) if (serverSettings.authActiveAuthMethods?.includes('openid')) { - logger.info('[2.17.3 migration] OIDC is enabled, adding authOpenIDSubfolderForRedirectURLs to server settings') + logger.info('[2.17.4 migration] OIDC is enabled, adding authOpenIDSubfolderForRedirectURLs to server settings') serverSettings.authOpenIDSubfolderForRedirectURLs = '' await updateServerSettings(queryInterface, logger, serverSettings) } else { - logger.info('[2.17.3 migration] OIDC is not enabled, no action required') + logger.info('[2.17.4 migration] OIDC is not enabled, no action required') } - logger.info('[2.17.3 migration] UPGRADE END: 2.17.3-use-subfolder-for-oidc-redirect-uris') + logger.info('[2.17.4 migration] UPGRADE END: 2.17.4-use-subfolder-for-oidc-redirect-uris') } /** @@ -40,25 +40,25 @@ async function up({ context: { queryInterface, logger } }) { */ async function down({ context: { queryInterface, logger } }) { // Downward migration script - logger.info('[2.17.3 migration] DOWNGRADE BEGIN: 2.17.3-use-subfolder-for-oidc-redirect-uris ') + logger.info('[2.17.4 migration] DOWNGRADE BEGIN: 2.17.4-use-subfolder-for-oidc-redirect-uris ') // Remove the OIDC subfolder option from the server settings const serverSettings = await getServerSettings(queryInterface, logger) if (serverSettings.authOpenIDSubfolderForRedirectURLs !== undefined) { - logger.info('[2.17.3 migration] Removing authOpenIDSubfolderForRedirectURLs from server settings') + logger.info('[2.17.4 migration] Removing authOpenIDSubfolderForRedirectURLs from server settings') delete serverSettings.authOpenIDSubfolderForRedirectURLs await updateServerSettings(queryInterface, logger, serverSettings) } else { - logger.info('[2.17.3 migration] authOpenIDSubfolderForRedirectURLs not found in server settings, no action required') + logger.info('[2.17.4 migration] authOpenIDSubfolderForRedirectURLs not found in server settings, no action required') } - logger.info('[2.17.3 migration] DOWNGRADE END: 2.17.3-use-subfolder-for-oidc-redirect-uris ') + logger.info('[2.17.4 migration] DOWNGRADE END: 2.17.4-use-subfolder-for-oidc-redirect-uris ') } async function getServerSettings(queryInterface, logger) { const result = await queryInterface.sequelize.query('SELECT value FROM settings WHERE key = "server-settings";') if (!result[0].length) { - logger.error('[2.17.3 migration] Server settings not found') + logger.error('[2.17.4 migration] Server settings not found') throw new Error('Server settings not found') } @@ -66,7 +66,7 @@ async function getServerSettings(queryInterface, logger) { try { serverSettings = JSON.parse(result[0][0].value) } catch (error) { - logger.error('[2.17.3 migration] Error parsing server settings:', error) + logger.error('[2.17.4 migration] Error parsing server settings:', error) throw error } diff --git a/test/server/migrations/v2.17.3-use-subfolder-for-oidc-redirect-uris.test.js b/test/server/migrations/v2.17.4-use-subfolder-for-oidc-redirect-uris.test.js similarity index 73% rename from test/server/migrations/v2.17.3-use-subfolder-for-oidc-redirect-uris.test.js rename to test/server/migrations/v2.17.4-use-subfolder-for-oidc-redirect-uris.test.js index 157b1ed4..1662d5f9 100644 --- a/test/server/migrations/v2.17.3-use-subfolder-for-oidc-redirect-uris.test.js +++ b/test/server/migrations/v2.17.4-use-subfolder-for-oidc-redirect-uris.test.js @@ -1,10 +1,10 @@ const { expect } = require('chai') const sinon = require('sinon') -const { up, down } = require('../../../server/migrations/v2.17.3-use-subfolder-for-oidc-redirect-uris') +const { up, down } = require('../../../server/migrations/v2.17.4-use-subfolder-for-oidc-redirect-uris') const { Sequelize } = require('sequelize') const Logger = require('../../../server/Logger') -describe('Migration v2.17.3-use-subfolder-for-oidc-redirect-uris', () => { +describe('Migration v2.17.4-use-subfolder-for-oidc-redirect-uris', () => { let queryInterface, logger, context beforeEach(() => { @@ -27,8 +27,8 @@ describe('Migration v2.17.3-use-subfolder-for-oidc-redirect-uris', () => { await up({ context }) - expect(logger.info.calledWith('[2.17.3 migration] UPGRADE BEGIN: 2.17.3-use-subfolder-for-oidc-redirect-uris')).to.be.true - expect(logger.info.calledWith('[2.17.3 migration] OIDC is enabled, adding authOpenIDSubfolderForRedirectURLs to server settings')).to.be.true + expect(logger.info.calledWith('[2.17.4 migration] UPGRADE BEGIN: 2.17.4-use-subfolder-for-oidc-redirect-uris')).to.be.true + expect(logger.info.calledWith('[2.17.4 migration] OIDC is enabled, adding authOpenIDSubfolderForRedirectURLs to server settings')).to.be.true expect(queryInterface.sequelize.query.calledTwice).to.be.true expect(queryInterface.sequelize.query.calledWith('SELECT value FROM settings WHERE key = "server-settings";')).to.be.true expect( @@ -38,7 +38,7 @@ describe('Migration v2.17.3-use-subfolder-for-oidc-redirect-uris', () => { } }) ).to.be.true - expect(logger.info.calledWith('[2.17.3 migration] UPGRADE END: 2.17.3-use-subfolder-for-oidc-redirect-uris')).to.be.true + expect(logger.info.calledWith('[2.17.4 migration] UPGRADE END: 2.17.4-use-subfolder-for-oidc-redirect-uris')).to.be.true }) it('should not add authOpenIDSubfolderForRedirectURLs if OIDC is not enabled', async () => { @@ -46,11 +46,11 @@ describe('Migration v2.17.3-use-subfolder-for-oidc-redirect-uris', () => { await up({ context }) - expect(logger.info.calledWith('[2.17.3 migration] UPGRADE BEGIN: 2.17.3-use-subfolder-for-oidc-redirect-uris')).to.be.true - expect(logger.info.calledWith('[2.17.3 migration] OIDC is not enabled, no action required')).to.be.true + expect(logger.info.calledWith('[2.17.4 migration] UPGRADE BEGIN: 2.17.4-use-subfolder-for-oidc-redirect-uris')).to.be.true + expect(logger.info.calledWith('[2.17.4 migration] OIDC is not enabled, no action required')).to.be.true expect(queryInterface.sequelize.query.calledOnce).to.be.true expect(queryInterface.sequelize.query.calledWith('SELECT value FROM settings WHERE key = "server-settings";')).to.be.true - expect(logger.info.calledWith('[2.17.3 migration] UPGRADE END: 2.17.3-use-subfolder-for-oidc-redirect-uris')).to.be.true + expect(logger.info.calledWith('[2.17.4 migration] UPGRADE END: 2.17.4-use-subfolder-for-oidc-redirect-uris')).to.be.true }) it('should throw an error if server settings cannot be parsed', async () => { @@ -61,7 +61,7 @@ describe('Migration v2.17.3-use-subfolder-for-oidc-redirect-uris', () => { } catch (error) { expect(queryInterface.sequelize.query.calledOnce).to.be.true expect(queryInterface.sequelize.query.calledWith('SELECT value FROM settings WHERE key = "server-settings";')).to.be.true - expect(logger.error.calledWith('[2.17.3 migration] Error parsing server settings:')).to.be.true + expect(logger.error.calledWith('[2.17.4 migration] Error parsing server settings:')).to.be.true expect(error).to.be.instanceOf(Error) } }) @@ -74,7 +74,7 @@ describe('Migration v2.17.3-use-subfolder-for-oidc-redirect-uris', () => { } catch (error) { expect(queryInterface.sequelize.query.calledOnce).to.be.true expect(queryInterface.sequelize.query.calledWith('SELECT value FROM settings WHERE key = "server-settings";')).to.be.true - expect(logger.error.calledWith('[2.17.3 migration] Server settings not found')).to.be.true + expect(logger.error.calledWith('[2.17.4 migration] Server settings not found')).to.be.true expect(error).to.be.instanceOf(Error) } }) @@ -87,8 +87,8 @@ describe('Migration v2.17.3-use-subfolder-for-oidc-redirect-uris', () => { await down({ context }) - expect(logger.info.calledWith('[2.17.3 migration] DOWNGRADE BEGIN: 2.17.3-use-subfolder-for-oidc-redirect-uris ')).to.be.true - expect(logger.info.calledWith('[2.17.3 migration] Removing authOpenIDSubfolderForRedirectURLs from server settings')).to.be.true + expect(logger.info.calledWith('[2.17.4 migration] DOWNGRADE BEGIN: 2.17.4-use-subfolder-for-oidc-redirect-uris ')).to.be.true + expect(logger.info.calledWith('[2.17.4 migration] Removing authOpenIDSubfolderForRedirectURLs from server settings')).to.be.true expect(queryInterface.sequelize.query.calledTwice).to.be.true expect(queryInterface.sequelize.query.calledWith('SELECT value FROM settings WHERE key = "server-settings";')).to.be.true expect( @@ -98,7 +98,7 @@ describe('Migration v2.17.3-use-subfolder-for-oidc-redirect-uris', () => { } }) ).to.be.true - expect(logger.info.calledWith('[2.17.3 migration] DOWNGRADE END: 2.17.3-use-subfolder-for-oidc-redirect-uris ')).to.be.true + expect(logger.info.calledWith('[2.17.4 migration] DOWNGRADE END: 2.17.4-use-subfolder-for-oidc-redirect-uris ')).to.be.true }) it('should not remove authOpenIDSubfolderForRedirectURLs if it does not exist', async () => { @@ -106,11 +106,11 @@ describe('Migration v2.17.3-use-subfolder-for-oidc-redirect-uris', () => { await down({ context }) - expect(logger.info.calledWith('[2.17.3 migration] DOWNGRADE BEGIN: 2.17.3-use-subfolder-for-oidc-redirect-uris ')).to.be.true - expect(logger.info.calledWith('[2.17.3 migration] authOpenIDSubfolderForRedirectURLs not found in server settings, no action required')).to.be.true + expect(logger.info.calledWith('[2.17.4 migration] DOWNGRADE BEGIN: 2.17.4-use-subfolder-for-oidc-redirect-uris ')).to.be.true + expect(logger.info.calledWith('[2.17.4 migration] authOpenIDSubfolderForRedirectURLs not found in server settings, no action required')).to.be.true expect(queryInterface.sequelize.query.calledOnce).to.be.true expect(queryInterface.sequelize.query.calledWith('SELECT value FROM settings WHERE key = "server-settings";')).to.be.true - expect(logger.info.calledWith('[2.17.3 migration] DOWNGRADE END: 2.17.3-use-subfolder-for-oidc-redirect-uris ')).to.be.true + expect(logger.info.calledWith('[2.17.4 migration] DOWNGRADE END: 2.17.4-use-subfolder-for-oidc-redirect-uris ')).to.be.true }) }) })