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
38 changes: 37 additions & 1 deletion BoxSDK.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@
05610A9B271099A7009F92CC /* SignRequestPrefillTag.swift in Sources */ = {isa = PBXBuildFile; fileRef = 05610A9A271099A7009F92CC /* SignRequestPrefillTag.swift */; };
05610A9D27109BFB009F92CC /* SignRequestSignerInput.swift in Sources */ = {isa = PBXBuildFile; fileRef = 05610A9C27109BFB009F92CC /* SignRequestSignerInput.swift */; };
056B628B2860C16F008E9418 /* SharedLinkDataSpecs.swift in Sources */ = {isa = PBXBuildFile; fileRef = 056B628A2860C16F008E9418 /* SharedLinkDataSpecs.swift */; };
0571FC6328F7FA07004846E4 /* WebhooksModuleIntegrationSpecs.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0571FC6228F7FA07004846E4 /* WebhooksModuleIntegrationSpecs.swift */; };
0571FC6728F9491D004846E4 /* BaseIntegrationSpecs+Webhooks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0571FC6628F9491D004846E4 /* BaseIntegrationSpecs+Webhooks.swift */; };
0571FC6928F94996004846E4 /* BaseIntegrationSpecs+Users.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0571FC6828F94996004846E4 /* BaseIntegrationSpecs+Users.swift */; };
0571FC6B28F949E6004846E4 /* BaseIntegrationSpecs+WebLinks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0571FC6A28F949E6004846E4 /* BaseIntegrationSpecs+WebLinks.swift */; };
0571FC6D28F94A47004846E4 /* BaseIntegrationSpecs+RetentionPolicies.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0571FC6C28F94A47004846E4 /* BaseIntegrationSpecs+RetentionPolicies.swift */; };
0571FC6F28F94A78004846E4 /* BaseIntegrationSpecs+Files.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0571FC6E28F94A78004846E4 /* BaseIntegrationSpecs+Files.swift */; };
0571FC7128F94ABD004846E4 /* BaseIntegrationSpecs+Folders.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0571FC7028F94ABD004846E4 /* BaseIntegrationSpecs+Folders.swift */; };
0579F6F727577DAD00473A3C /* Nimble.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 05EFAB1F26F0F01100DF1830 /* Nimble.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
0579F6F827577DAD00473A3C /* Quick.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 05EFAB2026F0F01100DF1830 /* Quick.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
0579F70027577FD200473A3C /* FolderModuleIntegrationSpecs.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0579F6FF27577FD200473A3C /* FolderModuleIntegrationSpecs.swift */; };
Expand Down Expand Up @@ -674,6 +681,13 @@
056FE12726EF6F6800098F00 /* Quick.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = Quick.xcframework; path = Carthage/Build/Quick.xcframework; sourceTree = "<group>"; };
056FE12826EF6F6800098F00 /* OHHTTPStubs.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = OHHTTPStubs.xcframework; path = Carthage/Build/OHHTTPStubs.xcframework; sourceTree = "<group>"; };
056FE12926EF6F6800098F00 /* Nimble.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = Nimble.xcframework; path = Carthage/Build/Nimble.xcframework; sourceTree = "<group>"; };
0571FC6228F7FA07004846E4 /* WebhooksModuleIntegrationSpecs.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebhooksModuleIntegrationSpecs.swift; sourceTree = "<group>"; };
0571FC6628F9491D004846E4 /* BaseIntegrationSpecs+Webhooks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "BaseIntegrationSpecs+Webhooks.swift"; sourceTree = "<group>"; };
0571FC6828F94996004846E4 /* BaseIntegrationSpecs+Users.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "BaseIntegrationSpecs+Users.swift"; sourceTree = "<group>"; };
0571FC6A28F949E6004846E4 /* BaseIntegrationSpecs+WebLinks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "BaseIntegrationSpecs+WebLinks.swift"; sourceTree = "<group>"; };
0571FC6C28F94A47004846E4 /* BaseIntegrationSpecs+RetentionPolicies.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "BaseIntegrationSpecs+RetentionPolicies.swift"; sourceTree = "<group>"; };
0571FC6E28F94A78004846E4 /* BaseIntegrationSpecs+Files.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "BaseIntegrationSpecs+Files.swift"; sourceTree = "<group>"; };
0571FC7028F94ABD004846E4 /* BaseIntegrationSpecs+Folders.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "BaseIntegrationSpecs+Folders.swift"; sourceTree = "<group>"; };
0579F6FF27577FD200473A3C /* FolderModuleIntegrationSpecs.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FolderModuleIntegrationSpecs.swift; sourceTree = "<group>"; };
057C8CE3276799760092A6EC /* Date+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Date+Extensions.swift"; sourceTree = "<group>"; };
059CF240283D0666001809CA /* FolderModuleAsyncIntegrationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FolderModuleAsyncIntegrationTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1259,6 +1273,20 @@
path = Async;
sourceTree = "<group>";
};
0571FC6528F948EF004846E4 /* Base */ = {
isa = PBXGroup;
children = (
05070D2C2757DBD7000AFE20 /* BaseIntegrationSpecs.swift */,
0571FC6E28F94A78004846E4 /* BaseIntegrationSpecs+Files.swift */,
0571FC7028F94ABD004846E4 /* BaseIntegrationSpecs+Folders.swift */,
0571FC6C28F94A47004846E4 /* BaseIntegrationSpecs+RetentionPolicies.swift */,
0571FC6828F94996004846E4 /* BaseIntegrationSpecs+Users.swift */,
0571FC6628F9491D004846E4 /* BaseIntegrationSpecs+Webhooks.swift */,
0571FC6A28F949E6004846E4 /* BaseIntegrationSpecs+WebLinks.swift */,
);
path = Base;
sourceTree = "<group>";
};
05EA725C2762649B001ECFF3 /* Resources */ = {
isa = PBXGroup;
children = (
Expand All @@ -1275,13 +1303,14 @@
05EC89D527577AF900FEBAC6 /* IntegrationTests */ = {
isa = PBXGroup;
children = (
05070D2C2757DBD7000AFE20 /* BaseIntegrationSpecs.swift */,
0501990B282423970085003B /* BoxClientIntegrationSpecs.swift */,
05EA725A27621FA7001ECFF3 /* FileModuleIntegrationSpecs.swift */,
0579F6FF27577FD200473A3C /* FolderModuleIntegrationSpecs.swift */,
0BD51EDB28CF257E000DE69E /* RetentionPoliciesModuleIntegrationSpecs.swift */,
052A03F9287C1FC20063513C /* UsersModuleIntegrationSpecs.swift */,
0571FC6228F7FA07004846E4 /* WebhooksModuleIntegrationSpecs.swift */,
054D536B283CFAB800CC2CBC /* Async */,
0571FC6528F948EF004846E4 /* Base */,
053637BB276C952D00C18D26 /* Extensions */,
05EA725C2762649B001ECFF3 /* Resources */,
0547B737276C99AA002D9E7A /* Utils */,
Expand Down Expand Up @@ -2829,24 +2858,31 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
0571FC6328F7FA07004846E4 /* WebhooksModuleIntegrationSpecs.swift in Sources */,
0BD51EDC28CF257E000DE69E /* RetentionPoliciesModuleIntegrationSpecs.swift in Sources */,
0547B73E276C99AA002D9E7A /* CryptographyUtil.swift in Sources */,
053637BD276C96E400C18D26 /* IntegrationTestResources.swift in Sources */,
057C8CE4276799760092A6EC /* Date+Extensions.swift in Sources */,
05EA725B27621FA7001ECFF3 /* FileModuleIntegrationSpecs.swift in Sources */,
0571FC7128F94ABD004846E4 /* BaseIntegrationSpecs+Folders.swift in Sources */,
0571FC6728F9491D004846E4 /* BaseIntegrationSpecs+Webhooks.swift in Sources */,
05EC1082276A195100252112 /* Collaboration+Extensions.swift in Sources */,
05EC1084276A19A100252112 /* FolderItem+Extensions.swift in Sources */,
0547B73F276C99AA002D9E7A /* NameGenerator.swift in Sources */,
0547B73D276C99AA002D9E7A /* Constants.swift in Sources */,
0571FC6B28F949E6004846E4 /* BaseIntegrationSpecs+WebLinks.swift in Sources */,
0543A2392757AA2C0005CA23 /* Configuration.swift in Sources */,
0571FC6928F94996004846E4 /* BaseIntegrationSpecs+Users.swift in Sources */,
059CF241283D0666001809CA /* FolderModuleAsyncIntegrationTests.swift in Sources */,
053EE331283D1CB700B4BF5A /* BaseAsyncIntegrationTests.swift in Sources */,
0579F70027577FD200473A3C /* FolderModuleIntegrationSpecs.swift in Sources */,
052A03FA287C1FC20063513C /* UsersModuleIntegrationSpecs.swift in Sources */,
0547B743276C9A89002D9E7A /* FileUtil.swift in Sources */,
05EC1086276A1CFE00252112 /* Task+Extensions.swift in Sources */,
0571FC6F28F94A78004846E4 /* BaseIntegrationSpecs+Files.swift in Sources */,
0501990C282423970085003B /* BoxClientIntegrationSpecs.swift in Sources */,
05070D2D2757DBD7000AFE20 /* BaseIntegrationSpecs.swift in Sources */,
0571FC6D28F94A47004846E4 /* BaseIntegrationSpecs+RetentionPolicies.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
67 changes: 67 additions & 0 deletions IntegrationTests/Base/BaseIntegrationSpecs+Files.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
//
// BaseIntegrationSpecs+Files.swift
// BoxSDKIntegrationTests-iOS
//
// Created by Artur Jankowski on 14/10/2022.
// Copyright © 2022 box. All rights reserved.
//

@testable import BoxSDK
import Nimble
import Quick

extension BaseIntegrationSpecs {

func uploadFile(fileName: String, stringContent: String, toFolder folderId: String, callback: @escaping (File) -> Void) {
uploadFile(fileName: fileName, dataContent: stringContent.data(using: .utf8)!, toFolder: folderId, callback: callback)
}

func uploadFile(fileName: String, toFolder folderId: String?, callback: @escaping (File) -> Void) {
guard let folderId = folderId else {
fail("folderId should not be nil")
return
}

guard let dataContent = FileUtil.getFileContent(fileName: fileName) else {
fail("Can not get content of file \(fileName)")
return
}

uploadFile(fileName: fileName, dataContent: dataContent, toFolder: folderId, callback: callback)
}

func uploadFile(fileName: String, dataContent: Data, toFolder folderId: String, callback: @escaping (File) -> Void) {
waitUntil(timeout: .seconds(Constants.Timeout.default)) { done in
self.client.files.upload(
data: dataContent,
name: fileName,
parentId: folderId
) { result in
switch result {
case let .success(file):
callback(file)
case let .failure(error):
fail("Expected upload call to suceeded, but instead got \(error)")
}

done()
}
}
}

func deleteFile(_ file: File?) {
guard let file = file else {
return
}

waitUntil(timeout: .seconds(Constants.Timeout.default)) { done in
self.client.files.delete(fileId: file.id) { result in
if case let .failure(error) = result {
fail("Expected delete call to succeed, but instead got \(error)")
}

done()
}
}
}
}
45 changes: 45 additions & 0 deletions IntegrationTests/Base/BaseIntegrationSpecs+Folders.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//
// BaseIntegrationSpecs+Folders.swift
// BoxSDKIntegrationTests-iOS
//
// Created by Artur Jankowski on 14/10/2022.
// Copyright © 2022 box. All rights reserved.
//

@testable import BoxSDK
import Nimble
import Quick

extension BaseIntegrationSpecs {

func createFolder(name: String, parentId: String = "0", callback: @escaping (Folder) -> Void) {
waitUntil(timeout: .seconds(Constants.Timeout.default)) { done in
self.client.folders.create(name: name, parentId: parentId) { result in
switch result {
case let .success(folder):
callback(folder)
case let .failure(error):
fail("Expected create call to suceeded, but instead got \(error)")
}

done()
}
}
}

func deleteFolder(_ folder: Folder?, recursive: Bool = false) {
guard let folder = folder else {
return
}

waitUntil(timeout: .seconds(Constants.Timeout.default)) { done in
self.client.folders.delete(folderId: folder.id, recursive: recursive) { result in
if case let .failure(error) = result {
fail("Expected delete call to succeed, but instead got \(error)")
}

done()
}
}
}
}
84 changes: 84 additions & 0 deletions IntegrationTests/Base/BaseIntegrationSpecs+RetentionPolicies.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
//
// BaseIntegrationSpecs+RetentionPolicies.swift
// BoxSDKIntegrationTests-iOS
//
// Created by Artur Jankowski on 14/10/2022.
// Copyright © 2022 box. All rights reserved.
//

@testable import BoxSDK
import Nimble
import Quick

extension BaseIntegrationSpecs {

func createRetention(
name: String,
type: RetentionPolicyType = .finite,
length: Int? = 1,
dispositionAction: DispositionAction = .permanentlyDelete,
callback: @escaping (RetentionPolicy) -> Void
) {
waitUntil(timeout: .seconds(Constants.Timeout.default)) { done in
self.client.retentionPolicy.create(
name: name,
type: type,
length: length,
dispositionAction: dispositionAction
) { result in
switch result {
case let .success(retention):
callback(retention)
case let .failure(error):
fail("Expected create retention call to suceeded, but instead got \(error)")
}

done()
}
}
}

func assignRetention(
_ retention: RetentionPolicy?,
assignedContentId: String?,
assignContentType: RetentionPolicyAssignmentItemType = .folder,
callback: @escaping (RetentionPolicyAssignment) -> Void
) {
guard let retention = retention, let assignedContentId = assignedContentId else {
return
}

waitUntil(timeout: .seconds(Constants.Timeout.default)) { done in
self.client.retentionPolicy.assign(
policyId: retention.id,
assignedContentId: assignedContentId,
assignContentType: assignContentType
) { result in
switch result {
case let .success(retentionAssignment):
callback(retentionAssignment)
case let .failure(error):
fail("Expected assign retention policy call to succeed, but instead got \(error)")
}

done()
}
}
}

func retireRetention(_ retention: RetentionPolicy?) {
guard let retention = retention else {
return
}

waitUntil(timeout: .seconds(Constants.Timeout.default)) { done in
self.client.retentionPolicy.update(policyId: retention.id, status: .retired) { result in
if case let .failure(error) = result {
fail("Expected update retention call to succeed, but instead got \(error)")
}

done()
}
}
}
}
45 changes: 45 additions & 0 deletions IntegrationTests/Base/BaseIntegrationSpecs+Users.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//
// BaseIntegrationSpecs+Users.swift
// BoxSDKIntegrationTests-iOS
//
// Created by Artur Jankowski on 14/10/2022.
// Copyright © 2022 box. All rights reserved.
//

@testable import BoxSDK
import Nimble
import Quick

extension BaseIntegrationSpecs {

func createUser(name: String, callback: @escaping (User) -> Void) {
waitUntil(timeout: .seconds(Constants.Timeout.default)) { done in
self.client.users.createAppUser(name: name) { result in
switch result {
case let .success(user):
callback(user)
case let .failure(error):
fail("Expected create call to suceeded, but instead got \(error)")
}

done()
}
}
}

func deleteUser(_ user: User?) {
guard let user = user else {
return
}

waitUntil(timeout: .seconds(Constants.Timeout.large)) { done in
self.client.users.delete(userId: user.id, force: true) { result in
if case let .failure(error) = result {
fail("Expected delete call to succeed, but instead got \(error)")
}

done()
}
}
}
}
30 changes: 30 additions & 0 deletions IntegrationTests/Base/BaseIntegrationSpecs+WebLinks.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// BaseIntegrationSpecs+Weblinks.swift
// BoxSDKIntegrationTests-iOS
//
// Created by Artur Jankowski on 14/10/2022.
// Copyright © 2022 box. All rights reserved.
//

@testable import BoxSDK
import Nimble
import Quick

extension BaseIntegrationSpecs {

func deleteWebLink(_ webLink: WebLink?) {
guard let webLink = webLink else {
return
}

waitUntil(timeout: .seconds(Constants.Timeout.default)) { done in
self.client.webLinks.delete(webLinkId: webLink.id) { result in
if case let .failure(error) = result {
fail("Expected delete call to succeed, but instead got \(error)")
}

done()
}
}
}
}
Loading