Currently, we're using an environment variable that is an array of osu! user IDs to verify who's allowed to test. At first, it was a fairly very easy and straight forward thing to manage, but as the array grows with more testers, it's hard to keep track who's ID is who (in case they need to be removed) and adding someone means re-deploying the test build just for that.
Instead of using an environment variable, we'll store the testers in the Redis DB, not in the Postgres DB because this is only relevant in test builds and not used in prod or dev (although dev is sort of relevant so we can test this).
For each procedure:
Apply rate limit middleware.
Create a middleware that throws an error if the environment isn't dev or testing (using env.ENV) and apply it.
Anything set in Redis in these procedures must persist (can't expire).
Add tester
Using Redis, if the testers key isn't define, create it as an empty array. Append the following object:
{
osuUserId: /* From input */,
username: undefined
}
Input: osuUserId.
Conditions
The user must be an admin.
Remove tester
Remove the array element that contains the user with the inputted osu! user ID.
Input: osuUserId.
Conditions
The user must be an admin.
Misc. tasks
During the osu! OAuth callback (/api/auth/callback/osu), if the user already exists, after creating authSession object and if the environment is testing or dev: Update the array element that contains the respective osu! user ID and update it so it the username is defined. If the user doesn't exist, then do the update after authSession is created during the Discord OAuth callback (/api/auth/callback/discord). This is so we can identify who the osu! user ID belongs to.
Currently, we're using an environment variable that is an array of osu! user IDs to verify who's allowed to test. At first, it was a fairly very easy and straight forward thing to manage, but as the array grows with more testers, it's hard to keep track who's ID is who (in case they need to be removed) and adding someone means re-deploying the test build just for that.
Instead of using an environment variable, we'll store the testers in the Redis DB, not in the Postgres DB because this is only relevant in test builds and not used in prod or dev (although dev is sort of relevant so we can test this).
For each procedure:
env.ENV
) and apply it.Add tester
Using Redis, if the
testers
key isn't define, create it as an empty array. Append the following object:Input: osuUserId.
Conditions
Remove tester
Remove the array element that contains the user with the inputted osu! user ID.
Input: osuUserId.
Conditions
Misc. tasks
During the osu! OAuth callback (
/api/auth/callback/osu
), if the user already exists, after creatingauthSession
object and if the environment is testing or dev: Update the array element that contains the respective osu! user ID and update it so it the username is defined. If the user doesn't exist, then do the update afterauthSession
is created during the Discord OAuth callback (/api/auth/callback/discord
). This is so we can identify who the osu! user ID belongs to.Create interface
Tester
inlib/types.ts
: