Skip to content

Commit a60f790

Browse files
authored
Merge pull request #20374 from mozilla/FXA-13080
fix(emails): Update oauth_client_info service/name check
2 parents 064f0cb + 1115301 commit a60f790

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

packages/fxa-auth-server/lib/senders/oauth_client_info.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
const { Keyv } = require('keyv');
88
const client = require('../oauth/client');
9+
const { OAuthNativeServices } = require('@fxa/accounts/oauth');
10+
11+
const NATIVE_SERVICES = new Set(Object.values(OAuthNativeServices));
912

1013
module.exports = (log, config) => {
1114
const OAUTH_CLIENT_INFO_CACHE_TTL = config.oauth.clientInfoCacheTTL;
@@ -43,7 +46,7 @@ module.exports = (log, config) => {
4346
}
4447

4548
// Set the client name to 'Firefox' if the service is browser-based
46-
if (service === 'sync' || service === 'relay') {
49+
if (NATIVE_SERVICES.has(service)) {
4750
log.trace('fetch.firefoxClient');
4851
return FIREFOX_CLIENT;
4952
}

packages/fxa-auth-server/lib/senders/oauth_client_info.spec.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jest.mock('../oauth/client', () => ({
1212
case '0000000000000000':
1313
throw new Error();
1414
default:
15-
return { name: 'Firefox' };
15+
return { name: 'NotFirefox' };
1616
}
1717
},
1818
}));
@@ -60,6 +60,16 @@ describe('lib/senders/oauth_client_info:', () => {
6060
expect(res.name).toBe('Firefox');
6161
});
6262

63+
it('returns Firefox if service=smartwindow', async () => {
64+
const res = await fetch('smartwindow');
65+
expect(res.name).toBe('Firefox');
66+
});
67+
68+
it('returns Firefox if service=vpn', async () => {
69+
const res = await fetch('vpn');
70+
expect(res.name).toBe('Firefox');
71+
});
72+
6373
it('falls back to Mozilla if error', async () => {
6474
const res = await fetch('0000000000000000');
6575
expect(res.name).toBe('Mozilla');

0 commit comments

Comments
 (0)