-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: remove env variable dependencies from tests (#4471)
- Loading branch information
1 parent
fc05ac1
commit a519fdd
Showing
18 changed files
with
171 additions
and
17 deletions.
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
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 |
---|---|---|
|
@@ -36,6 +36,14 @@ const mockedRecaptcha = | |
RecaptchaEnterpriseServiceClient as unknown as jest.Mock; | ||
|
||
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; | ||
|
@@ -101,7 +109,7 @@ describe('Testing auth service', () => { | |
sub: id, | ||
expiresIn: 86400000 / 24, | ||
}, | ||
process.env.APP_SECRET, | ||
'SOME-LONG-SECRET-KEY', | ||
), | ||
); | ||
}); | ||
|
@@ -133,7 +141,7 @@ describe('Testing auth service', () => { | |
sub: id, | ||
expiresIn: 86400000, | ||
}, | ||
process.env.APP_SECRET, | ||
'SOME-LONG-SECRET-KEY', | ||
), | ||
); | ||
}); | ||
|
@@ -898,8 +906,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({ | ||
|
@@ -942,7 +950,7 @@ describe('Testing auth service', () => { | |
{ | ||
id, | ||
}, | ||
process.env.APP_SECRET, | ||
'SOME-LONG-SECRET-KEY', | ||
); | ||
const response = { | ||
cookie: jest.fn(), | ||
|
@@ -1003,14 +1011,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 = { | ||
|
@@ -1044,7 +1052,7 @@ describe('Testing auth service', () => { | |
{ | ||
id, | ||
}, | ||
process.env.APP_SECRET, | ||
'SOME-LONG-SECRET-KEY', | ||
); | ||
prisma.userAccounts.findUnique = jest | ||
.fn() | ||
|
@@ -1105,7 +1113,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); | ||
}); | ||
}); | ||
|
@@ -2059,6 +2060,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({ | ||
|
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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
{ | ||
"type": "FeatureCollection", | ||
"query": ["600", "mongomery", "st", "san", "francisco", "ca", "94112"], | ||
"features": [ | ||
{ | ||
"id": "address.4226420775908864", | ||
"type": "Feature", | ||
"place_type": ["address"], | ||
"relevance": 0.797326, | ||
"properties": { | ||
"accuracy": "rooftop", | ||
"mapbox_id": "dXJuOm1ieGFkcjo3ODFjNjQxYi1mMzI2LTQxMTYtOTg3My1lOWNiNDJmNjg1ZWQ=" | ||
}, | ||
"text": "Montgomery Street", | ||
"place_name": "600 Montgomery Street, San Francisco, California 94111, United States", | ||
"center": [-122.40273, 37.79516], | ||
"geometry": { "type": "Point", "coordinates": [-122.40273, 37.79516] }, | ||
"address": "600", | ||
"context": [ | ||
{ | ||
"id": "neighborhood.214314220", | ||
"mapbox_id": "dXJuOm1ieHBsYzpETVlzN0E", | ||
"text": "Financial District" | ||
}, | ||
{ "id": "postcode.312487660", "mapbox_id": "dXJuOm1ieHBsYzpFcUF1N0E", "text": "94111" }, | ||
{ | ||
"id": "place.292358380", | ||
"wikidata": "Q62", | ||
"mapbox_id": "dXJuOm1ieHBsYzpFVzBJN0E", | ||
"text": "San Francisco" | ||
}, | ||
{ | ||
"id": "district.20547308", | ||
"wikidata": "Q62", | ||
"mapbox_id": "dXJuOm1ieHBsYzpBVG1HN0E", | ||
"text": "San Francisco County" | ||
}, | ||
{ | ||
"id": "region.419052", | ||
"short_code": "US-CA", | ||
"wikidata": "Q99", | ||
"mapbox_id": "dXJuOm1ieHBsYzpCbVRz", | ||
"text": "California" | ||
}, | ||
{ | ||
"id": "country.8940", | ||
"short_code": "us", | ||
"wikidata": "Q30", | ||
"mapbox_id": "dXJuOm1ieHBsYzpJdXc", | ||
"text": "United States" | ||
} | ||
] | ||
} | ||
], | ||
"attribution": "NOTICE: © 2023 Mapbox and its suppliers. All rights reserved. Use of this data is subject to the Mapbox Terms of Service (https://www.mapbox.com/about/maps/). This response and the information it contains may not be retained. POI(s) provided by Foursquare." | ||
} |
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,4 @@ | ||
{ | ||
"asset_id": "c225fe21edd2f291ddf93c9d57913567", | ||
"public_id": "dev/cypress-automated-image-upload-071e2ab9-5a52-4f34-85f0-e41f696f4b96" | ||
} |
Oops, something went wrong.