Skip to content
Open
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
15 changes: 11 additions & 4 deletions Nextcloud.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@
AFCE353327E4ED1900FEA6C2 /* UIToolbar+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFCE353227E4ED1900FEA6C2 /* UIToolbar+Extension.swift */; };
AFCE353527E4ED5900FEA6C2 /* DateFormatter+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFCE353427E4ED5900FEA6C2 /* DateFormatter+Extension.swift */; };
AFCE353727E4ED7B00FEA6C2 /* NCShareCells.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFCE353627E4ED7B00FEA6C2 /* NCShareCells.swift */; };
AFCE353927E5DE0500FEA6C2 /* Shareable.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFCE353827E5DE0400FEA6C2 /* Shareable.swift */; };
AFCE353927E5DE0500FEA6C2 /* NCShare+Helper.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFCE353827E5DE0400FEA6C2 /* NCShare+Helper.swift */; };
B529E40D2E8D1F8B006D9131 /* NCManageE2EE.swift in Sources */ = {isa = PBXBuildFile; fileRef = B529E40C2E8D1F8B006D9131 /* NCManageE2EE.swift */; };
D575039F27146F93008DC9DC /* String+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7A0D1342591FBC5008F8A13 /* String+Extension.swift */; };
D5B6AA7827200C7200D49C24 /* NCActivityTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5B6AA7727200C7200D49C24 /* NCActivityTableViewCell.swift */; };
F310B1EF2BA862F1001C42F5 /* NCViewerMedia+VisionKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = F310B1EE2BA862F1001C42F5 /* NCViewerMedia+VisionKit.swift */; };
F321DA8A2B71205A00DDA0E6 /* NCTrashSelectTabBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = F321DA892B71205A00DDA0E6 /* NCTrashSelectTabBar.swift */; };
Expand Down Expand Up @@ -1220,7 +1222,9 @@
AFCE353227E4ED1900FEA6C2 /* UIToolbar+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIToolbar+Extension.swift"; sourceTree = "<group>"; };
AFCE353427E4ED5900FEA6C2 /* DateFormatter+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "DateFormatter+Extension.swift"; sourceTree = "<group>"; };
AFCE353627E4ED7B00FEA6C2 /* NCShareCells.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCShareCells.swift; sourceTree = "<group>"; };
AFCE353827E5DE0400FEA6C2 /* Shareable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Shareable.swift; sourceTree = "<group>"; };
AFCE353827E5DE0400FEA6C2 /* NCShare+Helper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NCShare+Helper.swift"; sourceTree = "<group>"; };
B529E40C2E8D1F8B006D9131 /* NCManageE2EE.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCManageE2EE.swift; sourceTree = "<group>"; };
B568C2C82DA7CE560072FCB4 /* E2EETests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = E2EETests.swift; sourceTree = "<group>"; };
C0046CDA2A17B98400D87C9D /* NextcloudUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = NextcloudUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
C04E2F202A17BB4D001BAD85 /* NextcloudIntegrationTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = NextcloudIntegrationTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
D5B6AA7727200C7200D49C24 /* NCActivityTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCActivityTableViewCell.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2024,6 +2028,7 @@
isa = PBXGroup;
children = (
AA52EB452D42AC5A0089C348 /* Placeholder.swift */,
B568C2C82DA7CE560072FCB4 /* E2EETests.swift */,
);
path = NextcloudUnitTests;
sourceTree = "<group>";
Expand Down Expand Up @@ -2322,7 +2327,7 @@
AF2D7C7D2742559100ADF566 /* NCShareUserCell.swift */,
AF93471727E2361E002537EE /* NCShareHeader.xib */,
AF93471527E2361E002537EE /* NCShareHeader.swift */,
AFCE353827E5DE0400FEA6C2 /* Shareable.swift */,
AFCE353827E5DE0400FEA6C2 /* NCShare+Helper.swift */,
AA8E03D92D2ED83300E7E89C /* TransientShare.swift */,
);
path = Share;
Expand Down Expand Up @@ -2518,6 +2523,7 @@
F76882042C0DD1E7001CF441 /* Settings */ = {
isa = PBXGroup;
children = (
B529E40C2E8D1F8B006D9131 /* NCManageE2EE.swift */,
F768820B2C0DD1E7001CF441 /* Settings */,
F76882162C0DD1E7001CF441 /* AutoUpload */,
F389C9F32CEE381E00049762 /* SelectAlbum */,
Expand Down Expand Up @@ -4486,7 +4492,7 @@
F71916142E2901FB00E13E96 /* NCNetworking+Upload.swift in Sources */,
F704B5E92430C0B800632F5F /* NCCreateFormUploadConflictCell.swift in Sources */,
F72D404923D2082500A97FD0 /* NCViewerNextcloudText.swift in Sources */,
AFCE353927E5DE0500FEA6C2 /* Shareable.swift in Sources */,
AFCE353927E5DE0500FEA6C2 /* NCShare+Helper.swift in Sources */,
F77BB746289984CA0090FC19 /* UIViewController+Extension.swift in Sources */,
F700510522DF6A89003A3356 /* NCShare.swift in Sources */,
F72D1007210B6882009C96B7 /* NCPushNotificationEncryption.m in Sources */,
Expand Down Expand Up @@ -4721,6 +4727,7 @@
AF2D7C7E2742559100ADF566 /* NCShareUserCell.swift in Sources */,
AF4BF614275629E20081CEEF /* NCManageDatabase+Account.swift in Sources */,
F76340FA2EBDE9760056F538 /* NCManageDatabaseCore.swift in Sources */,
B529E40D2E8D1F8B006D9131 /* NCManageE2EE.swift in Sources */,
F3E173C02C9B1067006D177A /* AwakeMode.swift in Sources */,
F711A4DC2AF92CAE00095DD8 /* NCUtility+Date.swift in Sources */,
AF4BF61E27562B3F0081CEEF /* NCManageDatabase+Activity.swift in Sources */,
Expand Down
90 changes: 90 additions & 0 deletions Tests/NextcloudUnitTests/E2EETests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
//
// E2EETests.swift
// NextcloudTests
//
// Created by A200020526 on 26/05/23.
// Copyright © 2023 Marino Faggiana. All rights reserved.
//

@testable import Nextcloud
import XCTest
import TOPasscodeViewController

final class E2EETests: XCTestCase {

var manageE2EE: NCManageE2EE!

override func setUpWithError() throws {
// Put setup code here. This method is called before the invocation of each test method in the class.
manageE2EE = NCManageE2EE()
}

override func tearDownWithError() throws {
// Put teardown code here. This method is called after the invocation of each test method in the class.
manageE2EE = nil
}

func testExample() throws {
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct results.
// Any test you write for XCTest can be annotated as throws and async.
// Mark your test throws to produce an unexpected failure when your test encounters an uncaught error.
// Mark your test async to allow awaiting for asynchronous code to complete. Check the results with assertions afterwards.
}

func testPerformanceExample() throws {
// This is an example of a performance test case.
self.measure {
// Put the code you want to measure the time of here.
}
}

// MARK: - Initialization

func testInitialization() {
XCTAssertTrue(manageE2EE.endToEndInitialize.delegate === manageE2EE)
XCTAssertFalse(manageE2EE.isEndToEndEnabled)
XCTAssertEqual(manageE2EE.statusOfService, NSLocalizedString("_status_in_progress_", comment: ""))
}

// MARK: - Delegate

func testEndToEndInitializeSuccess() {
manageE2EE.endToEndInitializeSuccess()
XCTAssertTrue(manageE2EE.isEndToEndEnabled)
}

// MARK: - Passcode

func testRequestPasscodeType() {
// TODO: Implement this test case
}

func testCorrectPasscode_startE2E() {
manageE2EE.passcodeType = "startE2E"
manageE2EE.correctPasscode()
// TODO: Add assertions for the expected behavior after entering the correct passcode for starting E2E
}

func testCorrectPasscode_readPassphrase() {
manageE2EE.passcodeType = "readPassphrase"
// TODO: Simulate entering the correct passcode and verify the expected behavior
}

func testCorrectPasscode_removeLocallyEncryption() {
manageE2EE.passcodeType = "removeLocallyEncryption"
// TODO: Simulate entering the correct passcode and verify the expected behavior
}

func testDidPerformBiometricValidationRequest() {
let passcodeViewController = TOPasscodeViewController(passcodeType: .sixDigits, allowCancel: true)
manageE2EE.didPerformBiometricValidationRequest(in: passcodeViewController)
// TODO: Add assertions for the expected behavior after performing biometric validation
}

func testDidTapCancel() {
let passcodeViewController = TOPasscodeViewController(passcodeType: .sixDigits, allowCancel: true)
manageE2EE.didTapCancel(in: passcodeViewController)
// TODO: Add assertions for the expected behavior after tapping cancel
}
}
4 changes: 3 additions & 1 deletion iOSClient/Settings/E2EE/NCEndToEndInitialize.swift
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ class NCEndToEndInitialize: NSObject {
let privateKey = String(data: keyData, encoding: .utf8) {
NCPreferences().setEndToEndPrivateKey(account: account, privateKey: privateKey)
} else {
// // Fix here for https://jira.telekom.de/browse/NMC-5056
// let error = NKError(errorCode: NCGlobal.shared.errorInternalError, errorDescription: "Passphrase ist nicht korrekt")
let error = NKError(errorCode: NCGlobal.shared.errorInternalError, errorDescription: "Serious internal error to decrypt Private Key")
NCContentPresenter().messageNotification("E2E decrypt privateKey", error: error, delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.error, priority: .max)

Expand Down Expand Up @@ -200,7 +202,7 @@ class NCEndToEndInitialize: NSObject {
}
})

let cancel = UIAlertAction(title: "Cancel", style: .cancel)
let cancel = UIAlertAction(title: NSLocalizedString("_cancel_", comment: ""), style: .cancel)
alertController.addAction(ok)
alertController.addAction(cancel)
alertController.addTextField { textField in
Expand Down
Loading