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..390f92514a 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 @@ -54,7 +54,7 @@ describe('GET /heroes/:heroId', () => { expect(heroRes.profile).to.have.all.keys(['name']); }); - it('returns only necessary hero data given username', async () => { + it('returns only necessary hero data given username with display case', async () => { let hero = await generateUser({ contributor: {tier: 23}, }); @@ -67,4 +67,16 @@ 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 hero data given username without case sensitivity', async () => { + let hero = await generateUser({}, 'TestUpperCaseName123'); + let heroRes = await user.get(`/hall/heroes/${hero.auth.local.username.toLowerCase()}`); + + expect(heroRes).to.have.all.keys([ + '_id', 'id', 'balance', 'profile', 'purchased', + 'contributor', 'auth', 'items', + ]); + expect(heroRes.auth.local).not.to.have.keys(['salt', 'hashed_password']); + expect(heroRes.profile).to.have.all.keys(['name']); + }); }); diff --git a/test/helpers/api-integration/v3/object-generators.js b/test/helpers/api-integration/v3/object-generators.js index 4e177ace00..19486dc39a 100644 --- a/test/helpers/api-integration/v3/object-generators.js +++ b/test/helpers/api-integration/v3/object-generators.js @@ -13,8 +13,8 @@ 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); +export async function generateUser (update = {}, manualUsername = null) { + let username = manualUsername || (Date.now() + generateUUID()).substring(0, 20); let password = 'password'; let email = `${username}@example.com`; 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