diff options
| author | Bug Magnet <marco.nikic@mullvad.net> | 2024-04-30 11:20:32 +0200 |
|---|---|---|
| committer | Bug Magnet <marco.nikic@mullvad.net> | 2024-04-30 11:20:32 +0200 |
| commit | 31bcf205c645885bf9959665b57f902b54e205ad (patch) | |
| tree | 5bfb055eeaed309adb108b6e2d7b132fb10cdd05 | |
| parent | d9e8e577961ad6b790809383b610d1d7c8157d59 (diff) | |
| parent | 6c748d5dd7d2b12ad8d9c14f5d473a1c57044281 (diff) | |
| download | mullvadvpn-31bcf205c645885bf9959665b57f902b54e205ad.tar.xz mullvadvpn-31bcf205c645885bf9959665b57f902b54e205ad.zip | |
Merge branch 'make-custom-list-names-be-case-sensitive-ios-655'
4 files changed, 17 insertions, 15 deletions
diff --git a/ios/MullvadSettings/CustomListRepository.swift b/ios/MullvadSettings/CustomListRepository.swift index c6709782e2..9688618ac8 100644 --- a/ios/MullvadSettings/CustomListRepository.swift +++ b/ios/MullvadSettings/CustomListRepository.swift @@ -39,7 +39,7 @@ public struct CustomListRepository: CustomListRepositoryProtocol { public func save(list: CustomList) throws { var lists = fetchAll() - if let listWithSameName = lists.first(where: { $0.name.caseInsensitiveCompare(list.name) == .orderedSame }), + if let listWithSameName = lists.first(where: { $0.name.compare(list.name) == .orderedSame }), listWithSameName.id != list.id { throw CustomRelayListError.duplicateName } else if let index = lists.firstIndex(where: { $0.id == list.id }) { diff --git a/ios/MullvadVPN/View controllers/SelectLocation/CustomListLocationNodeBuilder.swift b/ios/MullvadVPN/View controllers/SelectLocation/CustomListLocationNodeBuilder.swift index e92a8bda8d..3f2e22a96f 100644 --- a/ios/MullvadVPN/View controllers/SelectLocation/CustomListLocationNodeBuilder.swift +++ b/ios/MullvadVPN/View controllers/SelectLocation/CustomListLocationNodeBuilder.swift @@ -17,7 +17,7 @@ struct CustomListLocationNodeBuilder { var customListLocationNode: CustomListLocationNode { let listNode = CustomListLocationNode( name: customList.name, - code: customList.name.lowercased(), + code: customList.name, locations: customList.locations, isActive: !customList.locations.isEmpty, customList: customList diff --git a/ios/MullvadVPNTests/MullvadVPN/View controllers/SelectLocation/CustomListRepositoryTests.swift b/ios/MullvadVPNTests/MullvadVPN/View controllers/SelectLocation/CustomListRepositoryTests.swift index bb54ec2a6e..5e08158ebb 100644 --- a/ios/MullvadVPNTests/MullvadVPN/View controllers/SelectLocation/CustomListRepositoryTests.swift +++ b/ios/MullvadVPNTests/MullvadVPN/View controllers/SelectLocation/CustomListRepositoryTests.swift @@ -30,11 +30,13 @@ class CustomListRepositoryTests: XCTestCase { func testFailedAddingDuplicateCustomList() throws { let item1 = CustomList(name: "Netflix", locations: []) - let item2 = CustomList(name: "Netflix", locations: []) + let item2 = CustomList(name: "netflix", locations: []) + let item3 = CustomList(name: "Netflix", locations: []) try XCTAssertNoThrow(repository.save(list: item1)) + try XCTAssertNoThrow(repository.save(list: item2)) - XCTAssertThrowsError(try repository.save(list: item2)) { error in + XCTAssertThrowsError(try repository.save(list: item3)) { error in XCTAssertEqual(error as? CustomRelayListError, CustomRelayListError.duplicateName) } } diff --git a/ios/MullvadVPNTests/MullvadVPN/View controllers/SelectLocation/CustomListsDataSourceTests.swift b/ios/MullvadVPNTests/MullvadVPN/View controllers/SelectLocation/CustomListsDataSourceTests.swift index a14e2296f8..33a97fffcd 100644 --- a/ios/MullvadVPNTests/MullvadVPN/View controllers/SelectLocation/CustomListsDataSourceTests.swift +++ b/ios/MullvadVPNTests/MullvadVPN/View controllers/SelectLocation/CustomListsDataSourceTests.swift @@ -23,20 +23,20 @@ class CustomListsDataSourceTests: XCTestCase { let nodes = dataSource.nodes let netflixNode = try XCTUnwrap(nodes.first(where: { $0.name == "Netflix" })) - XCTAssertNotNil(netflixNode.descendantNodeFor(codes: ["netflix", "es1-wireguard"])) - XCTAssertNotNil(netflixNode.descendantNodeFor(codes: ["netflix", "se"])) - XCTAssertNotNil(netflixNode.descendantNodeFor(codes: ["netflix", "us", "dal"])) + XCTAssertNotNil(netflixNode.descendantNodeFor(codes: ["Netflix", "es1-wireguard"])) + XCTAssertNotNil(netflixNode.descendantNodeFor(codes: ["Netflix", "se"])) + XCTAssertNotNil(netflixNode.descendantNodeFor(codes: ["Netflix", "us", "dal"])) let youtubeNode = try XCTUnwrap(nodes.first(where: { $0.name == "Youtube" })) - XCTAssertNotNil(youtubeNode.descendantNodeFor(codes: ["youtube", "se2-wireguard"])) - XCTAssertNotNil(youtubeNode.descendantNodeFor(codes: ["youtube", "us", "dal"])) + XCTAssertNotNil(youtubeNode.descendantNodeFor(codes: ["Youtube", "se2-wireguard"])) + XCTAssertNotNil(youtubeNode.descendantNodeFor(codes: ["Youtube", "us", "dal"])) } func testParents() throws { let listNode = try XCTUnwrap(dataSource.nodes.first(where: { $0.name == "Netflix" })) - let countryNode = try XCTUnwrap(listNode.descendantNodeFor(codes: ["netflix-se"])) - let cityNode = try XCTUnwrap(listNode.descendantNodeFor(codes: ["netflix-se-got"])) - let hostNode = try XCTUnwrap(listNode.descendantNodeFor(codes: ["netflix-se10-wireguard"])) + let countryNode = try XCTUnwrap(listNode.descendantNodeFor(codes: ["Netflix", "se"])) + let cityNode = try XCTUnwrap(listNode.descendantNodeFor(codes: ["Netflix", "se", "got"])) + let hostNode = try XCTUnwrap(listNode.descendantNodeFor(codes: ["Netflix-se10-wireguard"])) XCTAssertNil(listNode.parent) XCTAssertEqual(countryNode.parent, listNode) @@ -48,8 +48,8 @@ class CustomListsDataSourceTests: XCTestCase { let nodes = dataSource.search(by: "got") let rootNode = RootLocationNode(children: nodes) - XCTAssertTrue(rootNode.descendantNodeFor(codes: ["netflix", "se", "got"])?.isHiddenFromSearch == false) - XCTAssertTrue(rootNode.descendantNodeFor(codes: ["netflix", "se", "sto"])?.isHiddenFromSearch == true) + XCTAssertTrue(rootNode.descendantNodeFor(codes: ["Netflix", "se", "got"])?.isHiddenFromSearch == false) + XCTAssertTrue(rootNode.descendantNodeFor(codes: ["Netflix", "se", "sto"])?.isHiddenFromSearch == true) } func testSearchWithEmptyText() throws { @@ -66,7 +66,7 @@ class CustomListsDataSourceTests: XCTestCase { let relays = UserSelectedRelays(locations: [.hostname("es", "mad", "es1-wireguard")], customListSelection: nil) let nodeByLocations = dataSource.node(by: relays, for: customLists.first!) - let nodeByCode = dataSource.nodes.first?.descendantNodeFor(codes: ["netflix", "es1-wireguard"]) + let nodeByCode = dataSource.nodes.first?.descendantNodeFor(codes: ["Netflix", "es1-wireguard"]) XCTAssertEqual(nodeByLocations, nodeByCode) } |
