Skip to content

Commit

Permalink
fix: update password requirements (#4107)
Browse files Browse the repository at this point in the history
  • Loading branch information
emilyjablonski authored May 23, 2024
1 parent 4e6e1db commit 1f96fbb
Show file tree
Hide file tree
Showing 47 changed files with 226 additions and 163 deletions.
1 change: 1 addition & 0 deletions api/prisma/seed-dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export const devSeeding = async (
confirmedAt: new Date(),
jurisdictionIds: [jurisdiction.id],
acceptedTerms: true,
password: 'abcdef',
}),
});
await prismaClient.userAccounts.create({
Expand Down
5 changes: 4 additions & 1 deletion api/prisma/seed-helpers/user-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@ export const userFactory = async (optionalParams?: {
jurisdictionIds?: string[];
listings?: string[];
acceptedTerms?: boolean;
password?: string;
}): Promise<Prisma.UserAccountsCreateInput> => ({
email:
optionalParams?.email?.toLocaleLowerCase() ||
`${randomNoun().toLowerCase()}${randomNoun().toLowerCase()}@${randomAdjective().toLowerCase()}.com`,
firstName: optionalParams?.firstName || 'First',
lastName: optionalParams?.lastName || 'Last',
passwordHash: await passwordToHash('abcdef'),
passwordHash: optionalParams?.password
? await passwordToHash(optionalParams?.password)
: await passwordToHash('Abcdef12345!'),
userRoles: {
create: {
isAdmin: optionalParams?.roles?.isAdmin || false,
Expand Down
1 change: 1 addition & 0 deletions api/prisma/seed-staging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export const stagingSeed = async (
confirmedAt: new Date(),
jurisdictionIds: [jurisdiction.id, additionalJurisdiction.id],
acceptedTerms: true,
password: 'abcdef',
}),
});
// create a jurisdictional admin
Expand Down
3 changes: 2 additions & 1 deletion api/src/utilities/password-regex.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export const passwordRegex = /^(?=.*[0-9])(?=.*[a-zA-Z])([a-zA-Z0-9]+).{7,}$/;
export const passwordRegex =
/^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$%^&*-]).{12,}$/;
2 changes: 1 addition & 1 deletion api/test/integration/ami-chart.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe('AmiChart Controller Tests', () => {
.set({ passkey: process.env.API_PASS_KEY || '' })
.send({
email: storedUser.email,
password: 'abcdef',
password: 'Abcdef12345!',
} as Login)
.expect(201);

Expand Down
2 changes: 1 addition & 1 deletion api/test/integration/api-key-guard.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('API Key Guard Tests', () => {
.set({ passkey: process.env.API_PASS_KEY || '' })
.send({
email: storedUser.email,
password: 'abcdef',
password: 'Abcdef12345!',
} as Login)
.expect(201);

Expand Down
2 changes: 1 addition & 1 deletion api/test/integration/application-flagged-set.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ describe('Application flagged set Controller Tests', () => {
const res = await request(app.getHttpServer())
.post('/auth/login')
.set({ passkey: process.env.API_PASS_KEY || '' })
.send({ email: adminUser.email, password: 'abcdef' })
.send({ email: adminUser.email, password: 'Abcdef12345!' })
.expect(201);
adminAccessToken = res.header?.['set-cookie'].find((cookie) =>
cookie.startsWith('access-token='),
Expand Down
2 changes: 1 addition & 1 deletion api/test/integration/application.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ describe('Application Controller Tests', () => {
.set({ passkey: process.env.API_PASS_KEY || '' })
.send({
email: storedUser.email,
password: 'abcdef',
password: 'Abcdef12345!',
} as Login)
.expect(201);

Expand Down
2 changes: 1 addition & 1 deletion api/test/integration/asset.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe('Asset Controller Tests', () => {
.set({ passkey: process.env.API_PASS_KEY || '' })
.send({
email: storedUser.email,
password: 'abcdef',
password: 'Abcdef12345!',
} as Login)
.expect(201);

Expand Down
14 changes: 7 additions & 7 deletions api/test/integration/auth.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe('Auth Controller Tests', () => {
.set({ passkey: process.env.API_PASS_KEY || '' })
.send({
email: storedUser.email,
password: 'abcdef',
password: 'Abcdef12345!',
mfaCode: storedUser.singleUseCode,
mfaType: MfaType.email,
} as Login)
Expand Down Expand Up @@ -98,7 +98,7 @@ describe('Auth Controller Tests', () => {
.set({ passkey: process.env.API_PASS_KEY || '' })
.send({
email: storedUser.email,
password: 'abcdef',
password: 'Abcdef12345!',
} as Login)
.expect(201);

Expand Down Expand Up @@ -139,7 +139,7 @@ describe('Auth Controller Tests', () => {
.set({ passkey: process.env.API_PASS_KEY || '' })
.send({
email: storedUser.email,
password: 'abcdef',
password: 'Abcdef12345!',
} as Login)
.expect(201);

Expand Down Expand Up @@ -192,7 +192,7 @@ describe('Auth Controller Tests', () => {
.set({ passkey: process.env.API_PASS_KEY || '' })
.send({
email: storedUser.email,
password: 'abcdef',
password: 'Abcdef12345!',
mfaType: MfaType.sms,
} as RequestMfaCode)
.expect(201);
Expand Down Expand Up @@ -249,8 +249,8 @@ describe('Auth Controller Tests', () => {
.set({ passkey: process.env.API_PASS_KEY || '' })
.send({
email: storedUser.email,
password: 'abcdef123',
passwordConfirmation: 'abcdef123',
password: 'Abcdef12345!',
passwordConfirmation: 'Abcdef12345!',
token,
} as UpdatePassword)
.expect(200);
Expand Down Expand Up @@ -346,7 +346,7 @@ describe('Auth Controller Tests', () => {
.set({ passkey: process.env.API_PASS_KEY || '' })
.send({
email: storedUser.email,
password: 'abcdef',
password: 'Abcdef12345!',
} as Login)
.expect(201);
await request(app.getHttpServer())
Expand Down
2 changes: 1 addition & 1 deletion api/test/integration/jurisdiction.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('Jurisdiction Controller Tests', () => {
.set({ passkey: process.env.API_PASS_KEY || '' })
.send({
email: storedUser.email,
password: 'abcdef',
password: 'Abcdef12345!',
} as Login)
.expect(201);

Expand Down
6 changes: 3 additions & 3 deletions api/test/integration/listing.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ describe('Listing Controller Tests', () => {
const res = await request(app.getHttpServer())
.post('/auth/login')
.set({ passkey: process.env.API_PASS_KEY || '' })
.send({ email: adminUser.email, password: 'abcdef' })
.send({ email: adminUser.email, password: 'Abcdef12345!' })
.expect(201);
adminAccessToken = res.header?.['set-cookie'].find((cookie) =>
cookie.startsWith('access-token='),
Expand Down Expand Up @@ -811,7 +811,7 @@ describe('Listing Controller Tests', () => {
const res = await request(app.getHttpServer())
.post('/auth/login')
.set({ passkey: process.env.API_PASS_KEY || '' })
.send({ email: adminUser.email, password: 'abcdef' })
.send({ email: adminUser.email, password: 'Abcdef12345!' })
.expect(201);

adminAccessToken = res.header?.['set-cookie'].find((cookie) =>
Expand All @@ -823,7 +823,7 @@ describe('Listing Controller Tests', () => {
const res = await request(app.getHttpServer())
.post('/auth/login')
.set({ passkey: process.env.API_PASS_KEY || '' })
.send({ email: partnerUser.email, password: 'abcdef' })
.send({ email: partnerUser.email, password: 'Abcdef12345!' })
.expect(201);

const partnerAccessToken = res.header?.['set-cookie'].find((cookie) =>
Expand Down
2 changes: 1 addition & 1 deletion api/test/integration/multiselect-question.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe('MultiselectQuestion Controller Tests', () => {
.set({ passkey: process.env.API_PASS_KEY || '' })
.send({
email: storedUser.email,
password: 'abcdef',
password: 'Abcdef12345!',
} as Login)
.expect(201);

Expand Down
4 changes: 2 additions & 2 deletions api/test/integration/permission-tests/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ export const buildUserCreateMock = (
return {
firstName: 'Public User firstName',
lastName: 'Public User lastName',
password: 'example password 1',
password: 'Abcdef12345!',
email,
jurisdictions: [{ id: jurisId }],
} as unknown as UserCreate;
Expand All @@ -281,7 +281,7 @@ export const buildUserInviteMock = (
return {
firstName: 'Partner User firstName',
lastName: 'Partner User lastName',
password: 'example password 1',
password: 'Abcdef12345!',
email,
jurisdictions: [{ id: jurisId }],
agreedToTermsOfService: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ describe('Testing Permissioning of endpoints as Admin User', () => {
.set({ passkey: process.env.API_PASS_KEY || '' })
.send({
email: storedUser.email,
password: 'abcdef',
password: 'Abcdef12345!',
} as Login)
.expect(201);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ describe('Testing Permissioning of endpoints as Jurisdictional Admin in the corr
.set({ passkey: process.env.API_PASS_KEY || '' })
.send({
email: storedUser.email,
password: 'abcdef',
password: 'Abcdef12345!',
} as Login)
.expect(201);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ describe('Testing Permissioning of endpoints as Jurisdictional Admin in the wron
.set({ passkey: process.env.API_PASS_KEY || '' })
.send({
email: storedUser.email,
password: 'abcdef',
password: 'Abcdef12345!',
} as Login)
.expect(201);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ describe('Testing Permissioning of endpoints as partner with correct listing', (
.set({ passkey: process.env.API_PASS_KEY || '' })
.send({
email: storedUser.email,
password: 'abcdef',
password: 'Abcdef12345!',
} as Login)
.expect(201);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ describe('Testing Permissioning of endpoints as partner with wrong listing', ()
.set({ passkey: process.env.API_PASS_KEY || '' })
.send({
email: storedUser.email,
password: 'abcdef',
password: 'Abcdef12345!',
} as Login)
.expect(201);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ describe('Testing Permissioning of endpoints as public user', () => {
.set({ passkey: process.env.API_PASS_KEY || '' })
.send({
email: storedUser.email,
password: 'abcdef',
password: 'Abcdef12345!',
} as Login)
.expect(201);
storedUserId = storedUser.id;
Expand Down
2 changes: 1 addition & 1 deletion api/test/integration/reserved-community-type.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe('ReservedCommunityType Controller Tests', () => {
.set({ passkey: process.env.API_PASS_KEY || '' })
.send({
email: storedUser.email,
password: 'abcdef',
password: 'Abcdef12345!',
} as Login)
.expect(201);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('UnitAccessibilityPriorityType Controller Tests', () => {
.set({ passkey: process.env.API_PASS_KEY || '' })
.send({
email: storedUser.email,
password: 'abcdef',
password: 'Abcdef12345!',
} as Login)
.expect(201);

Expand Down
2 changes: 1 addition & 1 deletion api/test/integration/unit-rent-type.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe('UnitRentType Controller Tests', () => {
.set({ passkey: process.env.API_PASS_KEY || '' })
.send({
email: storedUser.email,
password: 'abcdef',
password: 'Abcdef12345!',
} as Login)
.expect(201);

Expand Down
2 changes: 1 addition & 1 deletion api/test/integration/unit-type.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('UnitType Controller Tests', () => {
.set({ passkey: process.env.API_PASS_KEY || '' })
.send({
email: storedUser.email,
password: 'abcdef',
password: 'Abcdef12345!',
} as Login)
.expect(201);

Expand Down
8 changes: 4 additions & 4 deletions api/test/integration/user.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ describe('User Controller Tests', () => {
.set({ passkey: process.env.API_PASS_KEY || '' })
.send({
email: storedUser.email,
password: 'abcdef',
password: 'Abcdef12345!',
} as Login)
.expect(201);

Expand Down Expand Up @@ -576,7 +576,7 @@ describe('User Controller Tests', () => {
.send({
firstName: 'Public User firstName',
lastName: 'Public User lastName',
password: 'example password 1',
password: 'Abcdef12345!',
email: '[email protected]',
jurisdictions: [{ id: juris.id }],
} as UserCreate)
Expand All @@ -602,7 +602,7 @@ describe('User Controller Tests', () => {
);
});

it('should create parter user', async () => {
it('should create partner user', async () => {
const juris = await prisma.jurisdictions.create({
data: jurisdictionFactory(),
});
Expand All @@ -613,7 +613,7 @@ describe('User Controller Tests', () => {
.send({
firstName: 'Partner User firstName',
lastName: 'Partner User lastName',
password: 'example password 1',
password: 'Abcdef12345!',
email: '[email protected]',
jurisdictions: [{ id: juris.id }],
agreedToTermsOfService: true,
Expand Down
Loading

0 comments on commit 1f96fbb

Please sign in to comment.