forked from bloom-housing/bloom
-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: remove env variable dependencies from tests (bloom-housing#4471) #817
Open
ludtkemorgan
wants to merge
3
commits into
main
Choose a base branch
from
4427/release
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
api/prisma/migrations/20241118165143_add_bengali_and_arabic/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
-- AlterEnum | ||
-- This migration adds more than one value to an enum. | ||
-- With PostgreSQL versions 11 and earlier, this is not possible | ||
-- in a single migration. This can be worked around by creating | ||
-- multiple migrations, each migration adding only one value to | ||
-- the enum. | ||
ALTER TYPE "languages_enum" | ||
ADD | ||
VALUE 'bn'; | ||
|
||
ALTER TYPE "languages_enum" | ||
ADD | ||
VALUE 'ar'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -975,6 +975,8 @@ enum LanguagesEnum { | |
vi | ||
zh | ||
tl | ||
bn | ||
ar | ||
|
||
@@map("languages_enum") | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,14 @@ import { PermissionService } from '../../../src/services/permission.service'; | |
import { Jurisdiction } from '../../../src/dtos/jurisdictions/jurisdiction.dto'; | ||
|
||
describe('Testing auth service', () => { | ||
process.env.APP_SECRET = 'SOME-LONG-SECRET-KEY'; | ||
process.env.EMAIL_API_KEY = 'SG.SOME-LONG-SECRET-KEY'; | ||
process.env.TWILIO_ACCOUNT_SID = 'AC'; | ||
process.env.TWILIO_AUTH_TOKEN = '842'; | ||
process.env.MFA_CODE_LENGTH = '5'; | ||
process.env.MFA_CODE_VALID = '60000'; | ||
process.env.TWILIO_PHONE_NUMBER = '5555555555'; | ||
process.env.GOOGLE_API_KEY = 'GOOGLE_API_KEY'; | ||
let authService: AuthService; | ||
let smsService: SmsService; | ||
let prisma: PrismaService; | ||
|
@@ -96,7 +104,7 @@ describe('Testing auth service', () => { | |
sub: id, | ||
expiresIn: 86400000 / 24, | ||
}, | ||
process.env.APP_SECRET, | ||
'SOME-LONG-SECRET-KEY', | ||
), | ||
); | ||
}); | ||
|
@@ -128,7 +136,7 @@ describe('Testing auth service', () => { | |
sub: id, | ||
expiresIn: 86400000, | ||
}, | ||
process.env.APP_SECRET, | ||
'SOME-LONG-SECRET-KEY', | ||
), | ||
); | ||
}); | ||
|
@@ -655,8 +663,8 @@ describe('Testing auth service', () => { | |
}); | ||
expect(sendMfaCodeMock).not.toHaveBeenCalled(); | ||
expect(smsService.client.messages.create).toHaveBeenCalledWith({ | ||
body: expect.anything(), | ||
from: expect.anything(), | ||
body: 'Your Partners Portal account access token: 00000', | ||
from: '5555555555', | ||
to: '520-781-8711', | ||
}); | ||
expect(res).toEqual({ | ||
|
@@ -727,7 +735,7 @@ describe('Testing auth service', () => { | |
{ | ||
id, | ||
}, | ||
process.env.APP_SECRET, | ||
'SOME-LONG-SECRET-KEY', | ||
); | ||
const response = { | ||
cookie: jest.fn(), | ||
|
@@ -788,14 +796,14 @@ describe('Testing auth service', () => { | |
{ | ||
id, | ||
}, | ||
process.env.APP_SECRET, | ||
'SOME-LONG-SECRET-KEY', | ||
); | ||
const secondId = randomUUID(); | ||
const secondToken = sign( | ||
{ | ||
id: secondId, | ||
}, | ||
process.env.APP_SECRET, | ||
'SOME-LONG-SECRET-KEY', | ||
); | ||
|
||
const response = { | ||
|
@@ -829,7 +837,7 @@ describe('Testing auth service', () => { | |
{ | ||
id, | ||
}, | ||
process.env.APP_SECRET, | ||
'SOME-LONG-SECRET-KEY', | ||
); | ||
prisma.userAccounts.findUnique = jest | ||
.fn() | ||
|
@@ -890,7 +898,7 @@ describe('Testing auth service', () => { | |
id, | ||
email: '[email protected]', | ||
}, | ||
process.env.APP_SECRET, | ||
'SOME-LONG-SECRET-KEY', | ||
); | ||
prisma.userAccounts.findUnique = jest | ||
.fn() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -304,10 +304,11 @@ describe('Testing user service', () => { | |
|
||
describe('createConfirmationToken', () => { | ||
it('should encode a confirmation token correctly', () => { | ||
process.env.APP_SECRET = 'SOME-LONG-SECRET-KEY'; | ||
const id = randomUUID(); | ||
const res = service.createConfirmationToken(id, '[email protected]'); | ||
expect(res).not.toBeNull(); | ||
const decoded = verify(res, process.env.APP_SECRET) as IdDTO; | ||
const decoded = verify(res, 'SOME-LONG-SECRET-KEY') as IdDTO; | ||
expect(decoded.id).toEqual(id); | ||
}); | ||
}); | ||
|
@@ -2107,6 +2108,8 @@ describe('Testing user service', () => { | |
}); | ||
|
||
it('should successfully request single use code when previous code is still valid', async () => { | ||
process.env.MFA_CODE_LENGTH = '5'; | ||
process.env.MFA_CODE_VALID = '60000'; | ||
const id = randomUUID(); | ||
emailService.sendSingleUseCode = jest.fn(); | ||
prisma.userAccounts.findFirst = jest.fn().mockResolvedValue({ | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ludtkemorgan Is this a private var?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a sample token stolen from the commented link. The API needs a valid looking token (starting with pk. and probably a few other things) but it's not actually a valid token that would work if you tried to use it