Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions application/backend/prisma/seed/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { SurveyStep } from '../../../common/types/survey'
import { createDefaultAnswers, recalculateAnswers } from '../../src/utils/answers'
import prisma from '../../src/PrismaClient'

const seedUserPassword = 'SDoZBbfxWJFX$4u6aZPd'

const main = async () => {
await prisma.organisation.upsert({
where: { name: 'OrgName' },
Expand Down Expand Up @@ -53,7 +55,7 @@ const main = async () => {
firstName: 'Michael',
lastName: 'Wilson',
role: 'Participant',
password: hashPassword('SomePassword123'),
password: hashPassword(seedUserPassword),
profiles: {
create: [
{
Expand Down Expand Up @@ -104,7 +106,7 @@ const main = async () => {
firstName: 'Sally',
lastName: 'Wilson',
role: 'Participant',
password: hashPassword('SomePassword123'),
password: hashPassword(seedUserPassword),
profiles: {
create: [
{
Expand Down Expand Up @@ -198,7 +200,7 @@ const main = async () => {
middleName: 'Mary',
lastName: 'Johnson',
role: 'Participant',
password: hashPassword('SomePassword123'),
password: hashPassword(seedUserPassword),
organisations: {},
profiles: {
create: [
Expand Down Expand Up @@ -284,7 +286,7 @@ const main = async () => {
middleName: 'James',
lastName: 'Doe',
role: 'OrganisationAdmin',
password: hashPassword('SomePassword123'),
password: hashPassword(seedUserPassword),
},
})

Expand All @@ -296,7 +298,7 @@ const main = async () => {
firstName: 'Jane',
lastName: 'Smith',
role: 'StudyAdmin',
password: hashPassword('SomePassword123'),
password: hashPassword(seedUserPassword),
adminOfStudies: { connect: [{ id: defaultStudy.id }, { id: shortStudy.id }] },
},
})
Expand All @@ -309,7 +311,7 @@ const main = async () => {
firstName: 'Bob',
lastName: 'Brown',
role: 'OrganisationAdmin',
password: hashPassword('SomePassword123'),
password: hashPassword(seedUserPassword),
},
})

Expand All @@ -321,7 +323,7 @@ const main = async () => {
firstName: 'Emily',
lastName: 'Davis',
role: 'StudyAdmin',
password: hashPassword('SomePassword123'),
password: hashPassword(seedUserPassword),
adminOfStudies: { connect: { id: shortStudy.id } },
},
})
Expand Down
19 changes: 9 additions & 10 deletions application/backend/src/controllers/AuditLogsController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { resetDB, seedAuditLogs } from 'common/testing/TestHelpers'
import { defaultAuditLogsPageSize } from 'common/src/config'
import { generateToken } from '../authentication'
import type { GetAuditLogsResponse } from 'common/types/api/audit-logs'
import { ORG_ADMIN_ID, PARTICIPANT_UNANSWERED_ID, STUDY_ADMIN_ID } from 'common/testing/seed'
import { TestUsers, TestStudies } from 'common/testing/constants'
import { UpdateStudyRequest } from 'common/types/api/studies'
import type { OTPLoginRequest, RegisterRequest } from 'common/types/api/auth'
const api = new Api()
Expand All @@ -17,10 +17,13 @@ describe('AuditLogsController', () => {
let orgAdminToken: string
let studyAdminToken: string

const studyName: string = TestStudies.TEST_STUDY.name
const testStudyId: number = TestStudies.TEST_STUDY.id

beforeAll(async () => {
participantToken = await generateToken({ userId: PARTICIPANT_UNANSWERED_ID })
orgAdminToken = await generateToken({ userId: ORG_ADMIN_ID })
studyAdminToken = await generateToken({ userId: STUDY_ADMIN_ID })
participantToken = await generateToken({ userId: TestUsers.PARTICIPANT_UNANSWERED.id })
orgAdminToken = await generateToken({ userId: TestUsers.ORG_ADMIN.id })
studyAdminToken = await generateToken({ userId: TestUsers.STUDY_ADMIN.id })

api.run()
})
Expand Down Expand Up @@ -212,8 +215,6 @@ describe('AuditLogsController', () => {
describe('Sensitive information', () => {
it('should not show sensitive token information in payloads', async () => {
// Update a redcapToken
const studyName: string = 'Test Study'
const testStudyId: number = 1
// Check test study exists
const existingStudy = await prisma.study.findFirst({
where: { name: studyName },
Expand Down Expand Up @@ -241,8 +242,6 @@ describe('AuditLogsController', () => {

it('should obscure sensitive token information in payloads', async () => {
// Update a redcapToken
const studyName: string = 'Test Study'
const testStudyId: number = 1
// Check test study exists
const existingStudy = await prisma.study.findFirst({
where: { name: studyName },
Expand Down Expand Up @@ -274,7 +273,7 @@ describe('AuditLogsController', () => {
email: 'johndoe@example.com',
firstName: 'John',
lastName: 'Doe',
password: 'Password1',
password: 'Loginforbogusperson1',
role: Role.Participant,
}

Expand Down Expand Up @@ -304,7 +303,7 @@ describe('AuditLogsController', () => {
code: '1223',
expiresAt: new Date(new Date().getTime() + 1000 * 60),
id: 'abc123',
userId: PARTICIPANT_UNANSWERED_ID,
userId: TestUsers.PARTICIPANT_UNANSWERED.id,
},
})
const loginRequest: OTPLoginRequest = {
Expand Down
Loading
Loading