chore: codereview comments

Signed-off-by: benjdlambert <ben@blam.sh>
This commit is contained in:
benjdlambert
2025-11-18 11:12:37 +01:00
parent a9315d0f77
commit eb279cbe7b
2 changed files with 27 additions and 1 deletions
@@ -21,7 +21,7 @@
*/
exports.up = async function up(knex) {
await knex.schema.alterTable('oauth_authorization_sessions', table => {
table.text('state').nullable().alter();
table.text('state', 'longtext').nullable().alter();
});
};
@@ -324,9 +324,35 @@ describe('migrations', () => {
})
.into('oidc_clients');
// Insert a session with state before migration
const existingState = 'existing-short-state';
await knex
.insert({
id: 'test-existing-session',
client_id: 'test-client-id',
redirect_uri: 'https://example.com/callback',
state: existingState,
response_type: 'code',
status: 'pending',
expires_at: new Date(Date.now() + 3600000),
})
.into('oauth_authorization_sessions');
// Apply the migration that changes state to TEXT
await migrateUpOnce(knex);
// Verify existing state persists after migration
await expect(
knex('oauth_authorization_sessions')
.where('id', 'test-existing-session')
.first(),
).resolves.toEqual(
expect.objectContaining({
id: 'test-existing-session',
state: existingState,
}),
);
// Test inserting a state parameter longer than 255 characters
// This is based on the real-world example from the issue
const longState = 'a'.repeat(280);