Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#2396 Fix: choose correct keys for message encryption #2413

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,15 @@ final class ComposeMessageHelper {
shouldUpdateLastUsed: true
).map(\.armored).joined(separator: "\n")
let parsed = try await core.parseKeys(armoredOrBinary: armoredPubkeys.data())
// Fetch public keys which are usableForEncryption
// https://github.com/FlowCrypt/flowcrypt-ios/issues/2396
// Also fetch revoked or expired keys so that we can display correct error message
// UI Test title: sending message to user with expired/revoked public key produces modal
let keyDetails = parsed.keyDetails.filter {
$0.usableForEncryption || $0.revoked || !$0.isNotExpired
}
ioanmo226 marked this conversation as resolved.
Show resolved Hide resolved
recipientsWithKeys.append(
try RecipientWithSortedPubKeys(recipient, keyDetails: parsed.keyDetails)
try RecipientWithSortedPubKeys(recipient, keyDetails: keyDetails)
)
}
return recipientsWithKeys
Expand Down
37 changes: 36 additions & 1 deletion appium/api-mocks/mock-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ export type MockUserName =
| 'expired'
| 'revoked'
| 'sunit'
| 'ioan';
| 'ioan'
| 'signOnlyKey';

export const MockUserList: Record<MockUserName, MockUser> = {
e2e: {
Expand Down Expand Up @@ -549,6 +550,40 @@ AASLCQgHBZUKCQgLAAoJEJs5ASDX+41RueYA/ixPnWLYX6tP0oR81hOWS6dH
r9FLVFOGo9cLLDfqwMR5AP9A4dgF5OprbpTvNJDeuTwfKOWREm/HNYyiBuUb
yBWYAw==
=n23p
-----END PGP PUBLIC KEY BLOCK-----`,
},
signOnlyKey: {
email: '[email protected]',
name: 'Test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ox+Bb6DUHdPoLVhKLP1LMqw4Ce5IvcfUlJk8vHSgIK0Jse2arxvQtDsl3KoDf3Pf
WZedE2jl2zpWrfc+DGjhXdrnerfE4g5j1Za66RKOUNVr0F5TQnomAWdd6gyT7TH1
sKQKQapiLQARAQABiQFrBBgBCAAgFiEEG8Zbnfzi9LXZi2k9R1A+qJq7nx8FAmU3
3jACGwIAvwkQR1A+qJq7nx+0IAQZAQgAHRYhBHVCtr4Cby6uRGad0iLL+T9HG2pN
BQJlN94wAAoJECLL+T9HG2pNCH0EAK1k1NNRgk9swfNTs2dzEz+PSd+xcCSUmVDy
sHZB3gi0EVK5nHScCRhJb6gjsusKf+vQaMbnY1d6VKaE533t3Pn+4FIaed337qY7
z3G0E2OtD3djJupkEi1xhQSojdiVxhE4vx33/y9XooLzAnGZJ8xvuEmyNJBkw48f
nFH1hYAkY+MD/14dFwAYZKJb8YvhUaO61zWGF9RrYQmPj+KPfDSPbFyJrBUce5NB
4OYU5j/A0Z2CqFzsQusQiPU9eHyFYuMZ3wqqqj5Ctr4yuGRGk/JsXWJcXAPzcu6l
kcfPHIAvBrNPxnOUb9tXHD/YSCO9c0G4H+Eay6diHo6AbNAoEdz1/hoN
=BZfa
-----END PGP PUBLIC KEY BLOCK-----`,
},
};
52 changes: 52 additions & 0 deletions appium/tests/specs/mock/composeEmail/CheckSignOnlyKey.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { MockApi } from 'api-mocks/mock';
import { MockApiConfig } from 'api-mocks/mock-config';
import { MockUserList } from 'api-mocks/mock-data';
import {
MailFolderScreen,
MenuBarScreen,
NewMessageScreen,
SetupKeyScreen,
SplashScreen,
} from '../../../screenobjects/all-screens';

describe('COMPOSE EMAIL: ', () => {
it('check encrypting message for user which contains sign only key', async () => {
const mockApi = new MockApi();

const recipient = MockUserList.signOnlyKey;
const subject = 'sign only key subject';
const message = 'sign only key message';

mockApi.fesConfig = MockApiConfig.defaultEnterpriseFesConfiguration;
mockApi.ekmConfig = MockApiConfig.defaultEnterpriseEkmConfiguration;
mockApi.addGoogleAccount('[email protected]');
mockApi.attesterConfig = {
servedPubkeys: {
[MockUserList.signOnlyKey.email]: MockUserList.signOnlyKey.pub!,
ioanmo226 marked this conversation as resolved.
Show resolved Hide resolved
},
};

await mockApi.withMockedApis(async () => {
await SplashScreen.mockLogin();
await SetupKeyScreen.setPassPhrase();
await MailFolderScreen.checkInboxScreen();
await MailFolderScreen.clickCreateEmail();

// Compose draft
await NewMessageScreen.composeEmail(recipient.email, subject, message);
await NewMessageScreen.clickBackButton();

// Go to draft folder
await MenuBarScreen.clickMenuBtn();
await MenuBarScreen.clickDraftsButton();

// Open draft and see if draft is saved correctly
await MailFolderScreen.clickOnEmailBySubject(subject);
await NewMessageScreen.checkFilledComposeEmailInfo({
recipients: [recipient.name],
subject: subject,
message: message,
});
});
});
});
Loading