Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 4 additions & 1 deletion FlowCrypt/Controllers/Search/SearchViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ final class SearchViewController: TableNodeViewController {
extension SearchViewController {
private func setupUI() {
view.backgroundColor = .backgroundColor
view.accessibilityIdentifier = "searchViewController"

title = "search_title".localized

node.delegate = self
node.dataSource = self
}
Expand All @@ -91,7 +94,7 @@ extension SearchViewController {
$0.hidesNavigationBarDuringPresentation = false
$0.searchBar.tintColor = .white
$0.searchBar.setImage(#imageLiteral(resourceName: "search_icn").tinted(.white), for: .search, state: .normal)
$0.searchBar.setImage(#imageLiteral(resourceName: "cancel.png").tinted(.white), for: .clear, state: .normal)
$0.searchBar.setImage(#imageLiteral(resourceName: "cancel").tinted(.white), for: .clear, state: .normal)
$0.searchBar.delegate = self
$0.searchBar.searchTextField.textColor = .white
}
Expand Down
15 changes: 5 additions & 10 deletions FlowCrypt/Controllers/Threads/ThreadDetailsDecorator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ private func makeEncryptionBadge(_ input: ThreadDetailsViewController.Input) ->
return BadgeNode.Input(
icon: icon,
text: NSAttributedString.text(from: text, style: .regular(12), color: .white),
color: color
color: color,
textAccessibilityIdentifier: "encryptionBadge"
)
}

Expand All @@ -103,16 +104,10 @@ private func makeSignatureBadge(_ input: ThreadDetailsViewController.Input) -> B
return nil
}

let text: String
if input.processedMessage?.messageType == .encrypted {
text = signature.message
} else {
text = "message_not_signed".localized
}

return BadgeNode.Input(
icon: signature.icon,
text: NSAttributedString.text(from: text, style: .regular(12), color: .white),
color: signature.color
text: NSAttributedString.text(from: signature.message, style: .regular(12), color: .white),
color: signature.color,
textAccessibilityIdentifier: "signatureBadge"
)
}
6 changes: 5 additions & 1 deletion FlowCryptUI/Nodes/BadgeNode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@ public final class BadgeNode: ASDisplayNode {
public let icon: String?
public let text: NSAttributedString?
public let color: UIColor?
public let textAccessibilityIdentifier: String

public init(icon: String?,
text: NSAttributedString?,
color: UIColor?) {
color: UIColor?,
textAccessibilityIdentifier: String) {
self.icon = icon
self.text = text
self.color = color
self.textAccessibilityIdentifier = textAccessibilityIdentifier
}
}

Expand All @@ -43,6 +46,7 @@ public final class BadgeNode: ASDisplayNode {
automaticallyManagesSubnodes = true

textNode.attributedText = input.text
textNode.accessibilityIdentifier = input.textAccessibilityIdentifier
backgroundColor = input.color
cornerRadius = 4
}
Expand Down
4 changes: 3 additions & 1 deletion appium/tests/screenobjects/all-screens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import ContactPublicKeyScreen from './contact-public-key.screen';
import PublicKeyScreen from './public-key.screen';
import AttachmentScreen from './attachment.screen';
import MailFolderScreen from './mail-folder.screen'
import SearchScreen from './search.screen'

export {
SplashScreen,
Expand All @@ -23,5 +24,6 @@ export {
PublicKeyScreen,
ContactScreen,
ContactPublicKeyScreen,
MailFolderScreen
MailFolderScreen,
SearchScreen
};
26 changes: 23 additions & 3 deletions appium/tests/screenobjects/email.screen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ const SELECTORS = {
FORWARD_BUTTON: '~Forward',
DELETE_BUTTON: '~Delete',
CONFIRM_DELETING: '~OK',
SENDER_EMAIL: '~senderEmail'
SENDER_EMAIL: '~senderEmail',
ENCRYPTION_BADGE: '~encryptionBadge',
SIGNATURE_BADGE: '~signatureBadge'
};


Expand Down Expand Up @@ -63,7 +65,15 @@ class EmailScreen extends BaseScreen {
}

get senderEmail() {
return $(SELECTORS.SENDER_EMAIL);
return $(SELECTORS.SENDER_EMAIL);
}

get encryptionBadge() {
return $(SELECTORS.ENCRYPTION_BADGE);
}

get signatureBadge() {
return $(SELECTORS.SIGNATURE_BADGE);
}

checkEmailAddress = async (email: string) => {
Expand Down Expand Up @@ -136,7 +146,17 @@ class EmailScreen extends BaseScreen {
}

confirmDelete = async () => {
await ElementHelper.waitAndClick(await this.confirmDeletingButton)
await ElementHelper.waitAndClick(await this.confirmDeletingButton);
}

checkEncryptionBadge = async (value: string) => {
await (await this.encryptionBadge).waitForDisplayed();
await expect(await this.encryptionBadge).toHaveText(value);
}

checkSignatureBadge = async (value: string) => {
await (await this.signatureBadge).waitForDisplayed();
await expect(await this.signatureBadge).toHaveText(value);
}
}

Expand Down
36 changes: 36 additions & 0 deletions appium/tests/screenobjects/search.screen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import BaseScreen from './base.screen';
import ElementHelper from "../helpers/ElementHelper";

const SELECTORS = {
BACK_BUTTON: '~arrow left c',
SCREEN: '~searchViewController',
SEARCH_FIELD: '~searchAllEmailField'
};

class SearchScreen extends BaseScreen {
constructor() {
super(SELECTORS.SCREEN);
}

get backButton() {
return $(SELECTORS.BACK_BUTTON)
}

get searchField() {
return $(SELECTORS.SEARCH_FIELD);
}

clickBackButton = async () => {
await browser.pause(2000);
await ElementHelper.waitAndClick(await this.backButton);
}

searchAndClickEmailBySubject = async (subject: string) => {
await (await this.searchField).setValue(`subject: '${subject}'`);

const selector = `~${subject}`;
await ElementHelper.waitAndClick(await $(selector), 500);
}
}

export default new SearchScreen();
75 changes: 75 additions & 0 deletions appium/tests/specs/inbox/CheckAllEmailSignatureCases.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import {
SplashScreen,
SetupKeyScreen,
MailFolderScreen,
EmailScreen,
SearchScreen
} from '../../screenobjects/all-screens';

describe('INBOX: ', () => {

it('user is able to view correct signature badge for all cases', async () => {

await SplashScreen.login();
await SetupKeyScreen.setPassPhrase();
await MailFolderScreen.checkInboxScreen();

// signed+encrypted message
await MailFolderScreen.clickSearchButton();

await SearchScreen.searchAndClickEmailBySubject('Signed and encrypted message');

await EmailScreen.checkEncryptionBadge('encrypted');
await EmailScreen.checkSignatureBadge('signed');
await EmailScreen.clickBackButton();

await SearchScreen.clickBackButton();

// singed only message
await MailFolderScreen.clickSearchButton();
await SearchScreen.searchAndClickEmailBySubject('Signed only message');

await EmailScreen.checkEncryptionBadge('not encrypted');
await EmailScreen.checkSignatureBadge('signed');
await EmailScreen.clickBackButton();

await SearchScreen.clickBackButton();

// signed only message with detached signature
await MailFolderScreen.clickSearchButton();
await SearchScreen.searchAndClickEmailBySubject('Signed only message with detached signature');

await EmailScreen.checkEncryptionBadge('not encrypted');
await EmailScreen.checkSignatureBadge('signed');
await EmailScreen.clickBackButton();

await SearchScreen.clickBackButton();

// plain message
await MailFolderScreen.clickSearchButton();
await SearchScreen.searchAndClickEmailBySubject('Test 1');

await EmailScreen.checkEncryptionBadge('not encrypted');
await EmailScreen.checkSignatureBadge('not signed');
await EmailScreen.clickBackButton();

await SearchScreen.clickBackButton();

// signed only message where the pubkey is not available
await MailFolderScreen.clickSearchButton();
await SearchScreen.searchAndClickEmailBySubject('Signed only message where the pubkey is not available');

await EmailScreen.checkEncryptionBadge('decrypt error');
await EmailScreen.clickBackButton();
Comment on lines +58 to +63
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is not right - signed only message that is missing pubkey should have encryption badge of not encrypted and a signature badge that says it cannot be verified due to missing pubkey.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe email was crafter with error. Let's create separate issue


await SearchScreen.clickBackButton();

// signed only message that was tempered during transit
await MailFolderScreen.clickSearchButton();
await SearchScreen.searchAndClickEmailBySubject('Signed only message that was tempered during transit');

await EmailScreen.checkEncryptionBadge('not encrypted');
await EmailScreen.checkSignatureBadge('bad signature');
await EmailScreen.clickBackButton();
});
});