-
Notifications
You must be signed in to change notification settings - Fork 859
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
392 changed files
with
5,748 additions
and
4,682 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
github "https://github.com/marinofaggiana/KTVHTTPCache" "2.0.2" | ||
github "https://github.com/marinofaggiana/KTVHTTPCache" "2.0.5" | ||
github "https://github.com/marinofaggiana/TOPasscodeViewController" "master" | ||
github "krzyzanowskim/OpenSSL" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
github "krzyzanowskim/OpenSSL" "1.1.1300" | ||
github "marinofaggiana/KTVHTTPCache" "2.0.2" | ||
github "marinofaggiana/KTVHTTPCache" "2.0.5" | ||
github "marinofaggiana/TOPasscodeViewController" "a1b9d1058b2648e636525fc368e220a0cfddb42a" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
Nextcloud.xcodeproj/xcshareddata/xcschemes/File Provider Extension.xcscheme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
// | ||
// SharePermissionTest.swift | ||
// Nextcloud | ||
// | ||
// Created by Henrik Storch on 29.03.22. | ||
// Copyright © 2021 Henrik Storch. All rights reserved. | ||
// | ||
// Author Henrik Storch <henrik.storch@nextcloud.com> | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
// | ||
|
||
@testable import Nextcloud | ||
import XCTest | ||
import NCCommunication | ||
|
||
class SharePermissionTest: XCTestCase { | ||
override func setUp() { | ||
let json = | ||
""" | ||
{"ocs":{"data":{"capabilities":{"files_sharing":{"default_permissions":31}}}}} | ||
""".data(using: .utf8)! | ||
NCManageDatabase.shared.addCapabilitiesJSon(json, account: "") | ||
} | ||
|
||
func testShareCellPermissionCell() throws { | ||
let share = NCTableShareOptions(sharee: NCCommunicationSharee(), metadata: tableMetadata(), password: nil) | ||
let shareConfig = NCShareConfig(parentMetadata: tableMetadata(), share: share) | ||
|
||
for row in 0..<shareConfig.permissions.count { | ||
guard let cell = shareConfig.config(for: IndexPath(row: row, section: 0)) as? NCToggleCellConfig else { | ||
XCTFail("Invalid share permission cell") | ||
continue | ||
} | ||
XCTAssertFalse(cell.isOn(for: share)) | ||
} | ||
|
||
let meta = tableMetadata() | ||
meta.sharePermissionsCollaborationServices = 31 | ||
let fullShare = NCTableShareOptions(sharee: NCCommunicationSharee(), metadata: meta, password: nil) | ||
let shareFullConfig = NCShareConfig(parentMetadata: meta, share: fullShare) | ||
|
||
for row in 0..<shareFullConfig.permissions.count { | ||
guard let cell = shareConfig.config(for: IndexPath(row: row, section: 0)) as? NCToggleCellConfig else { | ||
XCTFail("Invalid share permission cell") | ||
continue | ||
} | ||
XCTAssertTrue(cell.isOn(for: fullShare)) | ||
} | ||
} | ||
|
||
func testSharePermission() throws { | ||
XCTAssertTrue(NCLinkPermission.allowEdit.hasResharePermission(for: 15)) | ||
XCTAssertTrue(NCLinkPermission.allowEdit.hasResharePermission(for: 11)) | ||
XCTAssertTrue(NCLinkPermission.allowEdit.hasResharePermission(for: 7)) | ||
XCTAssertFalse(NCLinkPermission.allowEdit.hasResharePermission(for: 13)) | ||
XCTAssertFalse(NCLinkPermission.allowEdit.hasResharePermission(for: 1)) | ||
|
||
XCTAssertTrue(NCLinkPermission.viewOnly.hasResharePermission(for: 25)) | ||
XCTAssertTrue(NCLinkPermission.viewOnly.hasResharePermission(for: 17)) | ||
XCTAssertFalse(NCLinkPermission.viewOnly.hasResharePermission(for: 12)) | ||
XCTAssertFalse(NCLinkPermission.viewOnly.hasResharePermission(for: 2)) | ||
|
||
XCTAssertTrue(NCLinkPermission.fileDrop.hasResharePermission(for: 4)) | ||
XCTAssertFalse(NCLinkPermission.fileDrop.hasResharePermission(for: 27)) | ||
|
||
XCTAssertTrue(NCUserPermission.create.hasResharePermission(for: 4)) | ||
XCTAssertFalse(NCUserPermission.create.hasResharePermission(for: 27)) | ||
|
||
XCTAssertTrue(NCUserPermission.edit.hasResharePermission(for: 2)) | ||
XCTAssertFalse(NCUserPermission.edit.hasResharePermission(for: 29)) | ||
|
||
XCTAssertTrue(NCUserPermission.reshare.hasResharePermission(for: 16)) | ||
XCTAssertFalse(NCUserPermission.reshare.hasResharePermission(for: 15)) | ||
} | ||
|
||
func testFileShare() throws { | ||
let meta = tableMetadata() | ||
meta.directory = false | ||
let share = NCTableShareOptions.shareLink(metadata: meta, password: nil) | ||
let fileConfig = NCShareConfig(parentMetadata: meta, share: share) | ||
XCTAssertEqual(fileConfig.advanced, NCShareDetails.forLink) | ||
XCTAssertEqual(fileConfig.permissions as? [NCLinkPermission], NCLinkPermission.forFile) | ||
|
||
meta.directory = true | ||
let folderConfig = NCShareConfig(parentMetadata: meta, share: share) | ||
XCTAssertEqual(folderConfig.advanced, NCShareDetails.forLink) | ||
XCTAssertEqual(folderConfig.permissions as? [NCLinkPermission], NCLinkPermission.forDirectory) | ||
} | ||
|
||
func testUserShare() throws { | ||
let meta = tableMetadata() | ||
meta.directory = false | ||
let sharee = NCCommunicationSharee() | ||
let share = NCTableShareOptions(sharee: sharee, metadata: meta, password: nil) | ||
let fileConfig = NCShareConfig(parentMetadata: meta, share: share) | ||
XCTAssertEqual(fileConfig.advanced, NCShareDetails.forUser) | ||
XCTAssertEqual(fileConfig.permissions as? [NCUserPermission], NCUserPermission.forFile) | ||
|
||
meta.directory = true | ||
let folderConfig = NCShareConfig(parentMetadata: meta, share: share) | ||
XCTAssertEqual(folderConfig.advanced, NCShareDetails.forUser) | ||
XCTAssertEqual(folderConfig.permissions as? [NCUserPermission], NCUserPermission.forDirectory) | ||
} | ||
|
||
func testResharePermission() throws { | ||
let meta = tableMetadata() | ||
let permissionReadShare = NCGlobal.shared.permissionShareShare + NCGlobal.shared.permissionReadShare | ||
meta.sharePermissionsCollaborationServices = permissionReadShare | ||
meta.directory = false | ||
let share = NCTableShareOptions.shareLink(metadata: meta, password: nil) | ||
let fileConfig = NCShareConfig(parentMetadata: meta, share: share) | ||
XCTAssertEqual(fileConfig.resharePermission, meta.sharePermissionsCollaborationServices) | ||
XCTAssertEqual(fileConfig.advanced, NCShareDetails.forLink) | ||
XCTAssertEqual(fileConfig.permissions as? [NCLinkPermission], NCLinkPermission.forFile) | ||
|
||
meta.directory = true | ||
let sharee = NCCommunicationSharee() | ||
let folderShare = NCTableShareOptions(sharee: sharee, metadata: meta, password: nil) | ||
let folderConfig = NCShareConfig(parentMetadata: meta, share: folderShare) | ||
XCTAssertEqual(folderConfig.resharePermission, meta.sharePermissionsCollaborationServices) | ||
XCTAssertEqual(folderConfig.advanced, NCShareDetails.forUser) | ||
XCTAssertEqual(folderConfig.permissions as? [NCUserPermission], NCUserPermission.forDirectory) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// | ||
// UserAgentTests.swift | ||
// Nextcloud | ||
// | ||
// Created by Henrik Storch on 03.05.22. | ||
// Copyright © 2022 Henrik Storch. All rights reserved. | ||
// | ||
// Author Henrik Storch <henrik.storch@nextcloud.com> | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
// | ||
|
||
@testable import Nextcloud | ||
import XCTest | ||
|
||
class UserAgentTests: XCTestCase { | ||
// https://github.com/nextcloud/server/blob/fc826e98115b510313ddacbf6fef4ce8d041e373/lib/public/IRequest.php#L83 | ||
let ncServerUARegex = "^Mozilla\\/5\\.0 \\(iOS\\) (ownCloud|Nextcloud)\\-iOS.*$" | ||
|
||
// https://github.com/ProseMirror/prosemirror-view/blob/427d278aaaacde422ed1f2b8c84bb53337162775/src/browser.js#L18-L22 | ||
let proseMirrorWebKitUARegex = "\\bAppleWebKit\\/(\\d+)" | ||
let proseMirroriOSUARegex = "Mobile\\/\\w+" | ||
|
||
func testDefaultUserAgent() throws { | ||
let userAgent: String = CCUtility.getUserAgent() | ||
let match = try matches(for: ncServerUARegex, in: userAgent).first | ||
XCTAssertNotNil(match) | ||
} | ||
|
||
func testTextUserAgent() throws { | ||
let userAgent: String = NCUtility.shared.getCustomUserAgentNCText() | ||
let match = try matches(for: ncServerUARegex, in: userAgent).first | ||
XCTAssertNotNil(match) | ||
|
||
let iOSMatch = try matches(for: proseMirroriOSUARegex, in: userAgent).first | ||
XCTAssertNotNil(iOSMatch) | ||
|
||
// https://github.com/ProseMirror/prosemirror-view/blob/8f246f320801f8e3cac92c97f71ac91e3e327f2f/src/input.js#L521-L522 | ||
let webKitMatch = try matches(for: proseMirrorWebKitUARegex, in: userAgent).first | ||
XCTAssertNotNil(webKitMatch) | ||
XCTAssertEqual(webKitMatch!.numberOfRanges, 2) | ||
let versionRange = webKitMatch!.range(at: 1) | ||
let versionString = userAgent[Range(versionRange, in: userAgent)!] | ||
let webkitVersion = Int(versionString) ?? 0 | ||
XCTAssertGreaterThanOrEqual(webkitVersion, 604) | ||
} | ||
|
||
func matches(for regex: String, in text: String) throws -> [NSTextCheckingResult] { | ||
let range = NSRange(location: 0, length: text.utf16.count) | ||
let regex = try NSRegularExpression(pattern: regex) | ||
return regex.matches(in: text, range: range) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.