diff --git a/test/api/v3/integration/hall/GET-hall_heroes_heroId.test.js b/test/api/v3/integration/hall/GET-hall_heroes_heroId.test.js index b2d7bc6383..4b5bab8f0b 100644 --- a/test/api/v3/integration/hall/GET-hall_heroes_heroId.test.js +++ b/test/api/v3/integration/hall/GET-hall_heroes_heroId.test.js @@ -67,4 +67,10 @@ describe('GET /heroes/:heroId', () => { expect(heroRes.auth.local).not.to.have.keys(['salt', 'hashed_password']); expect(heroRes.profile).to.have.all.keys(['name']); }); + + it('returns correct hero using search with difference case', async () => { + await generateUser({}, { username: 'TestUpperCaseName123' }); + let heroRes = await user.get('/hall/heroes/TestuPPerCasEName123'); + expect(heroRes.auth.local.username).to.equal('TestUpperCaseName123'); + }); }); diff --git a/test/helpers/api-integration/v3/object-generators.js b/test/helpers/api-integration/v3/object-generators.js index 4e177ace00..7a0e2cbcf8 100644 --- a/test/helpers/api-integration/v3/object-generators.js +++ b/test/helpers/api-integration/v3/object-generators.js @@ -13,10 +13,16 @@ import * as Tasks from '../../../../website/server/models/task'; // parameter, such as the number of wolf eggs the user has, // , you can do so by passing in the full path as a string: // { 'items.eggs.Wolf': 10 } -export async function generateUser (update = {}) { - let username = (Date.now() + generateUUID()).substring(0, 20); - let password = 'password'; - let email = `${username}@example.com`; +// +// To manually set a username, email or password pass it in as +// an object for the second parameter. Only overrides need to be +// added. Items that don't exist will be autogenerated. +// Example: generateUser({}, { username: 'TestName' }) adds user +// with the 'TestName' username. +export async function generateUser (update = {}, overrides = {}) { + let username = overrides.username || (Date.now() + generateUUID()).substring(0, 20); + let password = overrides.password || 'password'; + let email = overrides.email || `${username}@example.com`; let user = await requester().post('/user/auth/local/register', { username, diff --git a/website/server/controllers/api-v3/hall.js b/website/server/controllers/api-v3/hall.js index d3715bfda6..2073962af0 100644 --- a/website/server/controllers/api-v3/hall.js +++ b/website/server/controllers/api-v3/hall.js @@ -175,7 +175,7 @@ api.getHero = { if (validator.isUUID(heroId)) { query = {_id: heroId}; } else { - query = {'auth.local.username': heroId}; + query = {'auth.local.lowerCaseUsername': heroId.toLowerCase()}; } const hero = await User