Skip to content

Commit 939897a

Browse files
committed
Add tests
1 parent bbcdccb commit 939897a

3 files changed

Lines changed: 24 additions & 21 deletions

File tree

packages/fxa-auth-server/lib/routes/passwordless.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import * as validators from './validators';
2727
import { FxaMailer } from '../senders/fxa-mailer';
2828
import { formatUserAgentInfo } from 'fxa-shared/lib/user-agent';
2929
import { formatGeoData } from 'fxa-shared/lib/geo-data';
30+
import type { DB } from '../db';
3031

3132
/**
3233
* Redis adapter for OTP storage
@@ -60,7 +61,7 @@ class PasswordlessHandler {
6061

6162
constructor(
6263
private log: AuthLogger,
63-
private db: any,
64+
private db: DB,
6465
private config: ConfigType,
6566
private customs: any,
6667
private glean: ReturnType<typeof gleanMetrics>,

packages/fxa-auth-server/lib/senders/fxa-mailer.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -209,11 +209,6 @@ export class FxaMailer extends FxaEmailRenderer {
209209
const links = {
210210
privacyUrl: this.linkBuilder.buildPrivacyLink(template, metricsEnabled),
211211
supportUrl: this.linkBuilder.buildSupportLink(template, metricsEnabled),
212-
passwordChangeLink: this.linkBuilder.buildPasswordChangeLink(
213-
template,
214-
metricsEnabled,
215-
{ email: opts.to }
216-
),
217212
};
218213
const headers = this.buildHeaders(
219214
{ template, version },
@@ -242,11 +237,6 @@ export class FxaMailer extends FxaEmailRenderer {
242237
const links = {
243238
privacyUrl: this.linkBuilder.buildPrivacyLink(template, metricsEnabled),
244239
supportUrl: this.linkBuilder.buildSupportLink(template, metricsEnabled),
245-
passwordChangeLink: this.linkBuilder.buildPasswordChangeLink(
246-
template,
247-
metricsEnabled,
248-
{ email: opts.to }
249-
),
250240
};
251241
const headers = this.buildHeaders(
252242
{ template, version },

packages/fxa-auth-server/test/local/routes/account.js

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1903,7 +1903,7 @@ describe('/account/status', () => {
19031903
});
19041904

19051905
it('returns passwordlessSupported true for non-existing account when globally enabled', async () => {
1906-
const { route, mockRequest, mockDB } = setup({
1906+
const { route, mockRequest } = setup({
19071907
extraConfig: {
19081908
passwordlessOtp: {
19091909
enabled: true,
@@ -1921,7 +1921,7 @@ describe('/account/status', () => {
19211921
});
19221922

19231923
it('returns passwordlessSupported true for non-existing account with forced email regex', async () => {
1924-
const { route, mockRequest, mockDB } = setup({
1924+
const { route, mockRequest } = setup({
19251925
extraConfig: {
19261926
passwordlessOtp: {
19271927
enabled: false,
@@ -1940,7 +1940,7 @@ describe('/account/status', () => {
19401940
});
19411941

19421942
it('returns passwordlessSupported false for non-existing account when not enabled and email does not match forced regex', async () => {
1943-
const { route, mockRequest, mockDB } = setup({
1943+
const { route, mockRequest } = setup({
19441944
extraConfig: {
19451945
passwordlessOtp: {
19461946
enabled: false,
@@ -1959,7 +1959,7 @@ describe('/account/status', () => {
19591959
});
19601960

19611961
it('does not return passwordlessSupported when thirdPartyAuthStatus is not requested', async () => {
1962-
const { route, mockRequest, mockDB } = setup({
1962+
const { route, mockRequest } = setup({
19631963
dbOptions: { exists: false },
19641964
});
19651965
mockRequest.payload.thirdPartyAuthStatus = false;
@@ -5027,7 +5027,9 @@ describe('/account', () => {
50275027
mockPlaySubscriptions.getSubscriptions,
50285028
uid
50295029
);
5030-
assert.deepEqual(result.subscriptions, [mockFormattedPlayStoreSubscription]);
5030+
assert.deepEqual(result.subscriptions, [
5031+
mockFormattedPlayStoreSubscription,
5032+
]);
50315033
}
50325034
);
50335035
});
@@ -5169,7 +5171,9 @@ describe('/account', () => {
51695171
mockAppStoreSubscriptions.getSubscriptions,
51705172
uid
51715173
);
5172-
assert.deepEqual(result.subscriptions, [mockFormattedAppStoreSubscription]);
5174+
assert.deepEqual(result.subscriptions, [
5175+
mockFormattedAppStoreSubscription,
5176+
]);
51735177
}
51745178
);
51755179
});
@@ -5248,15 +5252,23 @@ describe('/account', () => {
52485252
it('should return account metadata and 2FA status', () => {
52495253
return runTest(buildRoute(), request, (result) => {
52505254
assert.ok(Object.prototype.hasOwnProperty.call(result, 'createdAt'));
5251-
assert.ok(Object.prototype.hasOwnProperty.call(result, 'passwordCreatedAt'));
5255+
assert.ok(
5256+
Object.prototype.hasOwnProperty.call(result, 'passwordCreatedAt')
5257+
);
52525258
assert.ok(Object.prototype.hasOwnProperty.call(result, 'hasPassword'));
52535259
assert.ok(Object.prototype.hasOwnProperty.call(result, 'emails'));
52545260
assert.ok(Object.prototype.hasOwnProperty.call(result, 'totp'));
52555261
assert.ok(Object.prototype.hasOwnProperty.call(result, 'backupCodes'));
52565262
assert.ok(Object.prototype.hasOwnProperty.call(result, 'recoveryKey'));
5257-
assert.ok(Object.prototype.hasOwnProperty.call(result, 'recoveryPhone'));
5258-
assert.ok(Object.prototype.hasOwnProperty.call(result, 'securityEvents'));
5259-
assert.ok(Object.prototype.hasOwnProperty.call(result, 'linkedAccounts'));
5263+
assert.ok(
5264+
Object.prototype.hasOwnProperty.call(result, 'recoveryPhone')
5265+
);
5266+
assert.ok(
5267+
Object.prototype.hasOwnProperty.call(result, 'securityEvents')
5268+
);
5269+
assert.ok(
5270+
Object.prototype.hasOwnProperty.call(result, 'linkedAccounts')
5271+
);
52605272
assert.isArray(result.emails);
52615273
assert.isArray(result.securityEvents);
52625274
assert.isArray(result.linkedAccounts);

0 commit comments

Comments
 (0)