Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
35a110b
add checkbox per email for attester key submission
martgil Aug 13, 2021
9fa4608
fixes tslint error
martgil Aug 13, 2021
80c1028
fixes tslint error
martgil Aug 13, 2021
5a48a5d
add xss-escaped comment to pass pattern checks
martgil Aug 13, 2021
90d8e21
Merge branch 'master' into issue-3885-smart-alias-submission
martgil Aug 16, 2021
6abd22c
Added test for issue-3885 selectable email aliases to submit on attester
martgil Aug 26, 2021
7c41884
Merge branch 'master' into issue-3885-smart-alias-submission
martgil Aug 26, 2021
eca1d7f
Added a private key with two UIDs
rrrooommmaaa Aug 27, 2021
67854b6
Merge to master
Aug 30, 2021
5bbad80
refactor data-test naming and add multi email alias account to google…
Aug 31, 2021
181055f
fix tslint error
Aug 31, 2021
7afacfb
fix failing test on setup-page-recipe
Aug 31, 2021
be4fcb7
Added test for importing key with multiple email alias (incomplete)
Aug 31, 2021
605668e
fixes tslint formatting error
Aug 31, 2021
9e551b4
complete test for importing key with multiple email alias
Sep 1, 2021
bf0cc03
rename data-test and class container
Sep 1, 2021
2c28c55
rename data-test and class container
Sep 1, 2021
fa8343f
Merge remote-tracking branch 'origin/master' into issue-3885-smart-al…
Sep 2, 2021
03dcc3a
Merge remote-tracking branch 'origin/master' into issue-3885-smart-al…
Sep 6, 2021
c40bcb4
separate the test to CONSUMER-MOCK test variant
Sep 6, 2021
8e8df3d
move the render display function to key-import-ui.ts
Sep 6, 2021
bf95386
Merge remote-tracking branch 'origin/master' into issue-3885-smart-al…
Sep 13, 2021
c00812e
emails for checkboxes are default to 'unchecked' state
Sep 13, 2021
c9cb7ae
remove accidental console.log
Sep 13, 2021
d7ce232
Merge remote-tracking branch 'origin/master' into issue-3885-smart-al…
martgil Sep 15, 2021
4658710
Added automatic check/uncheck when an email is present.
martgil Sep 15, 2021
22e1325
fixes tslint by adding interface property
martgil Sep 15, 2021
3d7d10d
add event of keyup paste and change to manipulate checkboxes
martgil Sep 15, 2021
eac35bd
change button color from gray to green when valid private key
martgil Sep 16, 2021
3706337
remove checkEmailAliasIfPresent and uses fillOnly
martgil Sep 16, 2021
f4cb2e4
use fillOnly completely
martgil Sep 16, 2021
69b545f
bring back checkEmailAliasIfPresent and wrap it in fillOnly
martgil Sep 16, 2021
7cbecc7
rename css class name to avoid interfering with any className based c…
martgil Sep 16, 2021
8700b2b
Merge remote-tracking branch 'origin/master' into issue-3885-smart-al…
martgil Sep 17, 2021
f43870f
added key with multiple aliases
martgil Sep 17, 2021
b89a365
simplified code and move data-test to label input
martgil Sep 17, 2021
2348d82
corrected any type to string
martgil Sep 17, 2021
2bb59cc
Merge remote-tracking branch 'origin/master' into issue-3885-smart-al…
martgil Sep 17, 2021
7f8ffac
Merge remote-tracking branch 'origin/master' into issue-3885-smart-al…
martgil Sep 20, 2021
6f34d6b
remove spagetti code and better checking for submitkeyforaddrs
martgil Sep 20, 2021
06dd307
Merge remote-tracking branch 'origin/master' into issue-3885-smart-al…
martgil Sep 21, 2021
4303cdb
exclude email (uncheck checkbox) before submitting
martgil Sep 21, 2021
062ac92
attester pubkey for multi alias user (failing)
martgil Sep 21, 2021
7c176eb
added test "setup - imported key from a file with multiple alias"
martgil Sep 21, 2021
dd46996
added test if excluded email was submitted from the attester
martgil Sep 22, 2021
95f66b3
Merge remote-tracking branch 'origin/master' into issue-3885-smart-al…
martgil Sep 22, 2021
23f25b7
collect submitted keys from attester
rrrooommmaaa Sep 22, 2021
bc3f66e
patch data-test (selector) trasnformer to match/replace any provided …
martgil Sep 23, 2021
d31c794
move data-test directly to the input
martgil Sep 23, 2021
bc8fcf0
fix inconsistency in checking detected email alias
martgil Sep 23, 2021
2a4ca6a
manipulate test key and added 1 UID
martgil Sep 23, 2021
1e24b66
complete neccessary tests by checking default detected key states
martgil Sep 23, 2021
c422ae2
refactor email alias process [floating-promise-error] in constructor …
martgil Sep 24, 2021
8d1678f
remove comment
martgil Sep 24, 2021
ea82852
parse aliases via already rendered input checkbox
martgil Sep 27, 2021
ed8a17a
Merge remote-tracking branch 'origin/master' into issue-3885-smart-al…
martgil Sep 27, 2021
ed450b1
Merge remote-tracking branch 'origin/master' into issue-3885-smart-al…
martgil Sep 28, 2021
19a46f8
Merge remote-tracking branch 'origin/master' into issue-3885-smart-al…
martgil Sep 29, 2021
99a96ac
patched 'saveKeysAndPassPhrase' on setup.ts
martgil Sep 29, 2021
bd6a3e5
Merge branch 'master' into issue-3885-smart-alias-submission
martgil Oct 6, 2021
9221b84
fix conflict
martgil Oct 6, 2021
9d55fc7
fix conflict
martgil Oct 6, 2021
85c1b6d
Merge branch 'issue-3885-smart-alias-submission' of https://github.co…
martgil Oct 20, 2021
d5328df
fixes eslint
martgil Oct 20, 2021
686b97c
Merge branch 'master' into issue-3885-smart-alias-submission
tomholub Oct 26, 2021
e210e26
Merge remote-tracking branch 'origin/master' into issue-3886-smart-al…
martgil Oct 27, 2021
cbf2e7f
added callback when performing tests
martgil Oct 27, 2021
c578031
remove unnecessary undefined initialization
martgil Oct 27, 2021
ed62c7d
fix pubkey definition
flowcrypt-machine-user Oct 27, 2021
65b1de7
uncheck the checkbox when submit pubkey was set to false
martgil Oct 28, 2021
e8907c0
better flow for pubkey submission
martgil Oct 28, 2021
413ab9b
check for checkbox state in the first run
martgil Oct 28, 2021
2cd8efd
fix test title typo
martgil Oct 28, 2021
51c2aad
reverted back changes [proposed solution]
martgil Oct 29, 2021
227301e
clean up setup procedure
Nov 12, 2021
89c72d5
Merge branch 'master' into issue-3885-smart-alias-submission
tomholub Nov 12, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion extension/chrome/settings/setup.htm
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ <h1>Set Up FlowCrypt</h1>
Submit corresponding pubkey to FlowCrypt Attester
</label>
</div>
<div class="line left remove_if_pubkey_submitting_not_user_configurable" style="visibility: hidden;">
<div class="line left remove_if_pubkey_submitting_not_user_configurable container_for_import_key_email_alias" data-test="container-for-import-key-email-alias" style="visibility: hidden;">
<label>
<input type="checkbox" class="input_submit_all" disabled="disabled" />
<span>
Expand Down
31 changes: 19 additions & 12 deletions extension/chrome/settings/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ export class SetupView extends View {
} else {
window.location.href = 'index.htm';
}
this.submitKeyForAddrs = [this.acctEmail];
this.keyImportUi.initPrvImportSrcForm(this.acctEmail, this.parentTabId); // for step_2b_manual_enter, if user chooses so
this.submitKeyForAddrs = [];
this.keyImportUi.initPrvImportSrcForm(this.acctEmail, this.parentTabId, this.submitKeyForAddrs); // for step_2b_manual_enter, if user chooses so
this.keyImportUi.onBadPassphrase = () => $('#step_2b_manual_enter .input_passphrase').val('').focus();
this.keyImportUi.renderPassPhraseStrengthValidationInput($('#step_2a_manual_create .input_password'), $('#step_2a_manual_create .action_proceed_private'));
this.keyImportUi.renderPassPhraseStrengthValidationInput($('#step_2_ekm_choose_pass_phrase .input_password'), $('#step_2_ekm_choose_pass_phrase .action_proceed_private'));
Expand Down Expand Up @@ -201,10 +201,11 @@ export class SetupView extends View {
const inputSubmitAll = $(target).closest('.manual').find('.input_submit_all').first();
if ($(target).prop('checked')) {
if (inputSubmitAll.closest('div.line').css('visibility') === 'visible') {
inputSubmitAll.prop({ checked: true, disabled: false });
$('.input_email_alias').prop({ disabled: false });
}
} else {
inputSubmitAll.prop({ checked: false, disabled: true });
$('.input_email_alias').prop({ checked: false });
$('.input_email_alias').prop({ disabled: true });
}
}

Expand All @@ -216,19 +217,23 @@ export class SetupView extends View {
}
}

public preFinalizeSetup = async (options: SetupOptions): Promise<void> => {
await AcctStore.set(this.acctEmail, { tmp_submit_main: options.submit_main, tmp_submit_all: options.submit_all });
}

public submitPublicKeysAndFinalizeSetup = async ({ submit_main, submit_all }: { submit_main: boolean, submit_all: boolean }): Promise<void> => {
public submitPublicKeys = async (
{ submit_main, submit_all }: { submit_main: boolean, submit_all: boolean }
): Promise<void> => {
const primaryKi = await KeyStore.getFirstRequired(this.acctEmail);
try {
await this.submitPublicKeyIfNeeded(primaryKi.public, { submit_main, submit_all });
} catch (e) {
return await Settings.promptToRetry(e, Lang.setup.failedToSubmitToAttester, () => this.submitPublicKeysAndFinalizeSetup({ submit_main, submit_all }));
return await Settings.promptToRetry(
e,
Lang.setup.failedToSubmitToAttester,
() => this.submitPublicKeys({ submit_main, submit_all })
);
}
}

public finalizeSetup = async (): Promise<void> => {
await AcctStore.set(this.acctEmail, { setup_date: Date.now(), setup_done: true, cryptup_enabled: true });
await AcctStore.remove(this.acctEmail, ['tmp_submit_main', 'tmp_submit_all']);
}

public saveKeysAndPassPhrase = async (prvs: Key[], options: SetupOptions) => {
Expand All @@ -237,9 +242,11 @@ export class SetupView extends View {
await PassphraseStore.set((options.passphrase_save && !this.orgRules.forbidStoringPassPhrase()) ? 'local' : 'session',
this.acctEmail, { longid: KeyUtil.getPrimaryLongid(prv) }, options.passphrase);
}
const { sendAs } = await AcctStore.get(this.acctEmail, ['sendAs']);
const myOwnEmailsAddrs: string[] = [this.acctEmail].concat(Object.keys(sendAs!));
const myOwnEmailAddrsAsContacts: Contact[] = [];
const { full_name: name } = await AcctStore.get(this.acctEmail, ['full_name']);
for (const email of this.submitKeyForAddrs) {
for (const email of myOwnEmailsAddrs) {
myOwnEmailAddrsAsContacts.push(await ContactStore.obj({ email, name, pubkey: KeyUtil.armor(await KeyUtil.asPublicKey(prvs[0])) }));
}
await ContactStore.save(undefined, myOwnEmailAddrsAsContacts);
Expand Down
5 changes: 3 additions & 2 deletions extension/chrome/settings/setup/setup-create-key.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,13 @@ export class SetupCreateKeyModule {
const keyIdentity = await this.createSaveKeyPair(opts, keyAlgo);
if (keyIdentity) {
if (this.view.orgRules.canBackupKeys()) {
await this.view.preFinalizeSetup(opts);
await this.view.submitPublicKeys(opts);
const action = $('#step_2a_manual_create .input_backup_inbox').prop('checked') ? 'setup_automatic' : 'setup_manual';
// only finalize after backup is done. backup.htm will redirect back to this page with ?action=finalize
window.location.href = Url.create('modules/backup.htm', { action, acctEmail: this.view.acctEmail, idToken: this.view.idToken, id: keyIdentity.id, type: keyIdentity.type });
} else {
await this.view.submitPublicKeysAndFinalizeSetup(opts);
await this.view.submitPublicKeys(opts);
await this.view.finalizeSetup();
await this.view.setupRender.renderSetupDone();
}
}
Expand Down
8 changes: 4 additions & 4 deletions extension/chrome/settings/setup/setup-import-key.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ export class SetupImportKeyModule {
}
Xss.sanitizeRender('#step_2b_manual_enter .action_add_private_key', Ui.spinner('white'));
await this.view.saveKeysAndPassPhrase([checked.encrypted], options);
await this.view.preFinalizeSetup(options);
await this.view.submitPublicKeysAndFinalizeSetup(options);
await this.view.submitPublicKeys(options);
await this.view.finalizeSetup();
await this.view.setupRender.renderSetupDone();
} catch (e) {
if (e instanceof UserAlert) {
Expand Down Expand Up @@ -69,8 +69,8 @@ export class SetupImportKeyModule {
return;
}
await this.view.saveKeysAndPassPhrase([fixedPrv], options);
await this.view.preFinalizeSetup(options);
await this.view.submitPublicKeysAndFinalizeSetup(options);
await this.view.submitPublicKeys(options);
await this.view.finalizeSetup();
await this.view.setupRender.renderSetupDone();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ export class SetupWithEmailKeyManagerModule {
window.location.href = Url.create('index.htm', { acctEmail: this.view.acctEmail });
return;
}
await this.view.submitPublicKeysAndFinalizeSetup(setupOptions);
await this.view.submitPublicKeys(setupOptions);
await this.view.finalizeSetup();
await this.view.setupRender.renderSetupDone();
} catch (e) {
if (ApiErr.isNetErr(e) && await Api.isInternetAccessible()) { // frendly message when key manager is down, helpful during initial infrastructure setup
Expand Down
4 changes: 2 additions & 2 deletions extension/chrome/settings/setup/setup-recover-key.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ export class SetupRecoverKeyModule {
await this.view.saveKeysAndPassPhrase(newlyMatchingKeys, options);
const { setup_done } = await AcctStore.get(this.view.acctEmail, ['setup_done']);
if (!setup_done) { // normal situation - fresh setup
await this.view.preFinalizeSetup(options);
await this.view.submitPublicKeysAndFinalizeSetup(options);
await this.view.submitPublicKeys(options);
await this.view.finalizeSetup();
await this.view.setupRender.renderSetupDone();
} else { // setup was finished before, just added more keys now
await this.view.setupRender.renderSetupDone();
Expand Down
36 changes: 26 additions & 10 deletions extension/chrome/settings/setup/setup-render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import { AcctStore } from '../../../js/common/platform/store/acct-store.js';
import { KeyStore } from '../../../js/common/platform/store/key-store.js';
import { Ui } from '../../../js/common/browser/ui.js';
import { PgpPwd } from '../../../js/common/core/crypto/pgp/pgp-password.js';
import { Xss } from '../../../js/common/platform/xss.js';
import { KeyImportUi } from '../../../js/common/ui/key-import-ui.js';

export class SetupRenderModule {

Expand Down Expand Up @@ -39,12 +41,7 @@ export class SetupRenderModule {
await this.view.setupRecoverKey.renderAddKeyFromBackup();
}
} else if (this.view.action === 'finalize') {
const { tmp_submit_all, tmp_submit_main } = await AcctStore.get(this.view.acctEmail, ['tmp_submit_all', 'tmp_submit_main']);
if (typeof tmp_submit_all === 'undefined' || typeof tmp_submit_main === 'undefined') {
$('#content').text(`Setup session expired. To set up FlowCrypt, please click the FlowCrypt icon on top right.`);
return;
}
await this.view.submitPublicKeysAndFinalizeSetup({ submit_all: tmp_submit_all, submit_main: tmp_submit_main });
await this.view.finalizeSetup();
await this.renderSetupDone();
} else if (this.view.orgRules.mustAutoImportOrAutogenPrvWithKeyManager()) {
if (this.view.orgRules.mustAutogenPassPhraseQuietly() && this.view.orgRules.forbidStoringPassPhrase()) {
Expand Down Expand Up @@ -137,11 +134,30 @@ export class SetupRenderModule {
}

private saveAndFillSubmitPubkeysOption = (addresses: string[]) => {
this.view.submitKeyForAddrs = this.filterAddressesForSubmittingKeys(addresses);
if (this.view.submitKeyForAddrs.length > 1) {
$('.addresses').text(Value.arr.withoutVal(this.view.submitKeyForAddrs, this.view.acctEmail).join(', '));
$('.manual .input_submit_all').prop({ checked: true, disabled: false }).closest('div.line').css('display', 'block');
this.renderEmailAddresses(this.filterAddressesForSubmittingKeys(addresses));
}

private renderEmailAddresses = (addresses: string[]) => {
$('.input_submit_all').hide();
const emailAliases = Value.arr.withoutVal(addresses, this.view.acctEmail);
for (const e of emailAliases) {
// eslint-disable-next-line max-len
$('.addresses').append(`<label><input type="checkbox" class="input_email_alias" data-email="${Xss.escape(e)}" data-test="input-email-alias-${e.replace(/[^a-z0-9]+/g, '')}" />${Xss.escape(e)}</label><br/>`); // xss-escaped
}
$('.input_email_alias').click((event) => {
const email = String($(event.target).data('email'));
if ($(event.target).prop('checked')) {
if (!this.view.submitKeyForAddrs.includes(email)) {
KeyImportUi.addAliasForSubmission(email, this.view.submitKeyForAddrs);
}
} else {
KeyImportUi.removeAliasFromSubmission(email, this.view.submitKeyForAddrs);
}
});
if (emailAliases.length > 0) {
$('.container_for_import_key_email_alias').css('visibility', 'visible');
}
$('.manual .input_submit_all').prop({ checked: true, disabled: false }).closest('div.line').css('display', 'block');
}

private filterAddressesForSubmittingKeys = (addresses: string[]): string[] => {
Expand Down
2 changes: 2 additions & 0 deletions extension/css/cryptup.css
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ td.green,
b.green,
span.green { color: #31a217; }

button,
.line.gray,
td.gray,
b.gray,
Expand Down Expand Up @@ -131,6 +132,7 @@ span.gray { color: #b7b7b7; }
color: white;
}

button.btn_disabled,
.swal2-popup .swal2-styled.swal2-confirm.ui-modal-warning-confirm,
.swal2-popup .swal2-styled.swal2-cancel.ui-modal-confirm-cancel,
.swal2-popup .swal2-styled.swal2-cancel.ui-modal-confirm-checkbox-cancel,
Expand Down
1 change: 1 addition & 0 deletions extension/js/common/core/types/openpgp.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ declare namespace OpenPGP {
export class Userid extends BasePacket {
public tag: enums.packet.userid;
public userid: string;
public email: string;
}

export class SecretSubkey extends BaseKeyPacket {
Expand Down
5 changes: 1 addition & 4 deletions extension/js/common/platform/store/acct-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export type AccountIndex = 'keys' | 'notification_setup_needed_dismissed' | 'ema
'google_token_refresh' | 'hide_message_password' | 'sendAs' |
'pubkey_sent_to' | 'full_name' | 'cryptup_enabled' | 'setup_done' |
'successfully_received_at_leat_one_message' | 'notification_setup_done_seen' | 'picture' |
'outgoing_language' | 'setup_date' | 'openid' | 'tmp_submit_main' | 'tmp_submit_all' | 'uuid' | 'use_rich_text' | 'rules' |
'outgoing_language' | 'setup_date' | 'openid' | 'uuid' | 'use_rich_text' | 'rules' |
'fesUrl' | 'fesAccessToken';

export type SendAsAlias = {
Expand Down Expand Up @@ -67,9 +67,6 @@ export type AcctStoreDict = {
rules?: DomainRulesJson;
fesUrl?: string; // url where FlowCrypt Enterprise Server is deployed
fesAccessToken?: string;
// temporary
tmp_submit_main?: boolean;
tmp_submit_all?: boolean;
};

/**
Expand Down
31 changes: 29 additions & 2 deletions extension/js/common/ui/key-import-ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,22 @@ export class KeyImportUi {
return;
}

public static addAliasForSubmission = (email: string, submitKeyForAddrs: string[]) => {
submitKeyForAddrs.push(email);
}

public static removeAliasFromSubmission = (email: string, submitKeyForAddrs: string[]) => {
submitKeyForAddrs.splice(submitKeyForAddrs.indexOf(email), 1);
}

constructor(o: { rejectKnown?: boolean, checkEncryption?: boolean, checkSigning?: boolean }) {
this.rejectKnown = o.rejectKnown === true;
this.checkEncryption = o.checkEncryption === true;
this.checkSigning = o.checkSigning === true;
}
public onBadPassphrase: VoidCallback = () => undefined;

public initPrvImportSrcForm = (acctEmail: string, parentTabId: string | undefined) => {
public initPrvImportSrcForm = (acctEmail: string, parentTabId: string | undefined, submitKeyForAddrs?: string[] | undefined) => {
$('input[type=radio][name=source]').off().change(function () {
if ((this as HTMLInputElement).value === 'file') {
$('.input_private_key').val('').change().prop('disabled', true);
Expand All @@ -79,9 +87,28 @@ export class KeyImportUi {
$('.input_passphrase').attr('type', 'text');
$('#e_rememberPassphrase').prop('checked', true);
}));
$('.input_private_key').on('keyup paste change', Ui.event.handle(async target => {
$('.action_add_private_key').addClass('btn_disabled').attr('disabled');
$('.input_email_alias').prop('checked', false);
const { keys: [prv] } = await opgp.key.readArmored(String($(target).val()));
if (prv !== undefined) {
$('.action_add_private_key').removeClass('btn_disabled').removeAttr('disabled');
if (submitKeyForAddrs !== undefined) {
const users = prv.users;
for (const user of users) {
const userId = user.userId;
for (const inputCheckboxesWithEmail of $('.input_email_alias')) {
if (String($(inputCheckboxesWithEmail).data('email')) === userId!.email) {
KeyImportUi.addAliasForSubmission(userId!.email, submitKeyForAddrs!);
$(inputCheckboxesWithEmail).prop('checked', true);
}
}
}
}
}
}));
$('.input_private_key').change(Ui.event.handle(async target => {
const { keys: [prv] } = await opgp.key.readArmored(String($(target).val()));
$('.input_passphrase').val('');
if (!prv || !prv.isPrivate()) {
$('.line.unprotected_key_create_pass_phrase').hide();
return;
Expand Down
Binary file not shown.
4 changes: 2 additions & 2 deletions test/source/browser/controllable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -475,8 +475,8 @@ abstract class ControllableBase {
} else if (m = customSelLanguageQuery.match(/@(ui-modal-[a-z\-]+)/)) { // tslint:disable-line:no-conditional-assignment
return `.${m[1]}`; // represented as a class
// eslint-disable-next-line no-cond-assign
} else if (m = customSelLanguageQuery.match(/^@([a-z0-9\-_]+)$/i)) { // tslint:disable-line:no-conditional-assignment
return `[data-test="${m[1]}"]`;
} else if (m = customSelLanguageQuery.match(/@([a-z0-9\-_]+)$/i)) { // tslint:disable-line:no-conditional-assignment
return customSelLanguageQuery.replace(/@([a-z0-9\-_]+)$/i, `[data-test="${m[1]}"]`);
// eslint-disable-next-line no-cond-assign
} else if (m = customSelLanguageQuery.match(/^@([a-z0-9\-_]+)\(([^()]*)\)$/i)) { // tslint:disable-line:no-conditional-assignment
return `//*[@data-test='${m[1]}' and contains(text(),'${m[2]}')]`;
Expand Down
3 changes: 3 additions & 0 deletions test/source/mock/attester/attester-endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const knownMockEmails = [
];

let data: GoogleData;
export const MOCK_ATTESTER_LAST_INSERTED_PUB: { [email: string]: string } = {};

const getDC26454AFB71D18EABBAD73D1C7E6D3C5563A941 = async () => {
if (!data) {
Expand Down Expand Up @@ -80,6 +81,7 @@ export const mockAttesterEndpoints: HandlersDefinition = {
} else if (isPost(req)) {
oauth.checkAuthorizationHeaderWithIdToken(req.headers.authorization);
expect(body).to.contain('-----BEGIN PGP PUBLIC KEY BLOCK-----');
MOCK_ATTESTER_LAST_INSERTED_PUB[emailOrLongid] = body as string;
return 'Saved'; // 200 OK
} else {
throw new HttpClientErr(`Not implemented: ${req.method}`);
Expand All @@ -95,6 +97,7 @@ export const mockAttesterEndpoints: HandlersDefinition = {
if (email === 'no.pub@org-rules-test.flowcrypt.test') {
throw new HttpClientErr(`Could not find LDAP pubkey on a LDAP-only domain for email ${email} on server keys.flowcrypt.test`);
}
MOCK_ATTESTER_LAST_INSERTED_PUB[email] = pubkey;
return { saved: true };
},
'/attester/test/welcome': async ({ body }, req) => {
Expand Down
22 changes: 22 additions & 0 deletions test/source/mock/google/google-endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,28 @@ export const mockGoogleEndpoints: HandlersDefinition = {
treatAsAlias: false,
verificationStatus: 'accepted'
});
} else if (acct === 'multi.aliased.user@example.com') {
const alias1 = 'alias1@example.com';
const alias2 = 'alias2@example.com';
sendAs.push({
sendAsEmail: alias1,
displayName: 'An Alias1',
replyToAddress: alias1,
signature: '',
isDefault: false,
isPrimary: false,
treatAsAlias: false,
verificationStatus: 'accepted'
}, {
sendAsEmail: alias2,
displayName: 'An Alias1',
replyToAddress: alias2,
signature: '',
isDefault: false,
isPrimary: false,
treatAsAlias: false,
verificationStatus: 'accepted'
});
}
return { sendAs };
}
Expand Down
Loading