@@ -56,6 +56,7 @@ describe('checkPassword', () => {
5656 let customs , db , signinUtils ;
5757
5858 beforeEach ( ( ) => {
59+ mocks . mockOAuthClientInfo ( ) ;
5960 db = mocks . mockDB ( ) ;
6061 customs = {
6162 v2Enabled : sinon . spy ( ( ) => true ) ,
@@ -786,6 +787,7 @@ describe('sendSigninNotifications', () => {
786787 db = mocks . mockDB ( ) ;
787788 log = mocks . mockLog ( ) ;
788789 mailer = mocks . mockMailer ( ) ;
790+ mocks . mockOAuthClientInfo ( ) ;
789791 fxaMailer = mocks . mockFxaMailer ( ) ;
790792 metricsContext = mocks . mockMetricsContext ( ) ;
791793 request = mocks . mockRequest ( defaultMockRequestData ( log , metricsContext ) ) ;
@@ -1149,7 +1151,7 @@ describe('sendSigninNotifications', () => {
11491151 uaOSVersion : '11' ,
11501152 } ,
11511153 code : 'tokenVerifyCode' ,
1152- clientName : 'Firefox ' ,
1154+ clientName : 'sync ' ,
11531155 redirectTo : request . payload . redirectTo ,
11541156 service : undefined ,
11551157 resume : request . payload . resume ,
@@ -1187,7 +1189,17 @@ describe('sendSigninNotifications', () => {
11871189 } ) ;
11881190
11891191 it ( 'emits correct notifications when verificationMethod=email-2fa' , ( ) => {
1190- return sendSigninNotifications (
1192+ const oauthClientInfoMock = mocks . mockOAuthClientInfo ( {
1193+ fetch : sinon . stub ( ) . resolves ( { name : undefined } ) ,
1194+ } ) ;
1195+ // Re-initialize sendSigninNotifications to pick up the new mock
1196+ const localSendSigninNotifications = makeSigninUtils ( {
1197+ log,
1198+ db,
1199+ mailer,
1200+ config,
1201+ } ) . sendSigninNotifications ;
1202+ return localSendSigninNotifications (
11911203 request ,
11921204 accountRecord ,
11931205 sessionToken ,
@@ -1212,6 +1224,8 @@ describe('sendSigninNotifications', () => {
12121224 serviceName : undefined ,
12131225 } ) ;
12141226
1227+ assert . calledOnce ( oauthClientInfoMock . fetch ) ;
1228+
12151229 assert . calledTwice ( log . flowEvent ) ;
12161230 assert . calledWithMatch ( log . flowEvent . getCall ( 0 ) , {
12171231 event : 'account.login' ,
@@ -1271,10 +1285,12 @@ describe('sendSigninNotifications', () => {
12711285
12721286 describe ( 'email verification sending' , ( ) => {
12731287 beforeEach ( ( ) => {
1288+ mocks . mockOAuthClientInfo ( ) ;
12741289 sessionToken . tokenVerified = false ;
12751290 } ) ;
12761291
12771292 it ( 'passes service parameter correctly when request wantsKeys' , ( ) => {
1293+ mocks . mockOAuthClientInfo ( ) ;
12781294 request . query . keys = true ;
12791295 request . query . service = 'sync' ;
12801296 return sendSigninNotifications (
@@ -1290,16 +1306,26 @@ describe('sendSigninNotifications', () => {
12901306 } ) ;
12911307
12921308 it ( 'passes service parameter correctly when service is undefined' , ( ) => {
1309+ const oauthClientInfoMock = mocks . mockOAuthClientInfo ( ) ;
12931310 request . payload . service = undefined ;
1294- return sendSigninNotifications (
1311+
1312+ // Re-initialize sendSigninNotifications to pick up the new oauthClientInfoMock
1313+ const localSendSigninNotifications = makeSigninUtils ( {
1314+ log,
1315+ db,
1316+ mailer,
1317+ config,
1318+ } ) . sendSigninNotifications ;
1319+
1320+ return localSendSigninNotifications (
12951321 request ,
12961322 accountRecord ,
12971323 sessionToken ,
12981324 'email-otp'
12991325 ) . then ( ( ) => {
13001326 assert . calledOnce ( fxaMailer . sendVerifyLoginCodeEmail ) ;
1301- const callArgs = fxaMailer . sendVerifyLoginCodeEmail . getCall ( 0 ) . args [ 0 ] ;
1302- assert . equal ( callArgs . serviceName , undefined ) ;
1327+ assert . calledOnce ( oauthClientInfoMock . fetch ) ;
1328+ assert . calledWith ( oauthClientInfoMock . fetch , undefined ) ;
13031329 } ) ;
13041330 } ) ;
13051331
@@ -1369,6 +1395,9 @@ describe('sendSigninNotifications', () => {
13691395 sessionToken . tokenVerified = false ;
13701396 sessionToken . tokenVerificationId = 'tokenVerifyCode' ;
13711397 sessionToken . mustVerify = true ;
1398+ mocks . mockOAuthClientInfo ( {
1399+ fetch : sinon . stub ( ) . resolves ( { name : 'mockOauthClientName' } ) ,
1400+ } ) ;
13721401 const rpCmsConfig = {
13731402 clientId : '00f00f' ,
13741403 shared : {
@@ -1422,7 +1451,7 @@ describe('sendSigninNotifications', () => {
14221451 entrypoint : 'testo' ,
14231452 redirectTo : req . payload . redirectTo ,
14241453 resume : req . payload . resume ,
1425- serviceName : undefined ,
1454+ serviceName : 'mockOauthClientName' ,
14261455 cmsRpClientId : rpCmsConfig . clientId ,
14271456 cmsRpFromName : rpCmsConfig . shared ?. emailFromName ,
14281457 logoUrl : rpCmsConfig ?. shared ?. emailLogoUrl ,
@@ -1531,6 +1560,7 @@ describe('createKeyFetchToken', () => {
15311560 createKeyFetchToken ;
15321561
15331562 beforeEach ( ( ) => {
1563+ mocks . mockOAuthClientInfo ( ) ;
15341564 db = mocks . mockDB ( ) ;
15351565 password = {
15361566 unwrap : sinon . spy ( ( ) => Promise . resolve ( Buffer . from ( 'abcdef123456' ) ) ) ,
@@ -1602,6 +1632,7 @@ describe('getSessionVerificationStatus', () => {
16021632 let getSessionVerificationStatus ;
16031633
16041634 beforeEach ( ( ) => {
1635+ mocks . mockOAuthClientInfo ( ) ;
16051636 getSessionVerificationStatus = makeSigninUtils (
16061637 { }
16071638 ) . getSessionVerificationStatus ;
@@ -1691,6 +1722,7 @@ describe('cleanupReminders', () => {
16911722 let cleanupReminders , mockCadReminders ;
16921723
16931724 beforeEach ( ( ) => {
1725+ mocks . mockOAuthClientInfo ( ) ;
16941726 mockCadReminders = mocks . mockCadReminders ( ) ;
16951727 cleanupReminders = makeSigninUtils ( {
16961728 cadReminders : mockCadReminders ,
0 commit comments