Skip to content

Commit 55bc24a

Browse files
committed
feat: Add support for sign webhook triggers
1 parent c5f146c commit 55bc24a

14 files changed

+683
-289
lines changed

BoxSDK.xcodeproj/project.pbxproj

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@
5858
05610A9B271099A7009F92CC /* SignRequestPrefillTag.swift in Sources */ = {isa = PBXBuildFile; fileRef = 05610A9A271099A7009F92CC /* SignRequestPrefillTag.swift */; };
5959
05610A9D27109BFB009F92CC /* SignRequestSignerInput.swift in Sources */ = {isa = PBXBuildFile; fileRef = 05610A9C27109BFB009F92CC /* SignRequestSignerInput.swift */; };
6060
056B628B2860C16F008E9418 /* SharedLinkDataSpecs.swift in Sources */ = {isa = PBXBuildFile; fileRef = 056B628A2860C16F008E9418 /* SharedLinkDataSpecs.swift */; };
61+
0571FC6328F7FA07004846E4 /* WebhooksModuleIntegrationSpecs.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0571FC6228F7FA07004846E4 /* WebhooksModuleIntegrationSpecs.swift */; };
62+
0571FC6728F9491D004846E4 /* BaseIntegrationSpecs+Webhooks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0571FC6628F9491D004846E4 /* BaseIntegrationSpecs+Webhooks.swift */; };
63+
0571FC6928F94996004846E4 /* BaseIntegrationSpecs+Users.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0571FC6828F94996004846E4 /* BaseIntegrationSpecs+Users.swift */; };
64+
0571FC6B28F949E6004846E4 /* BaseIntegrationSpecs+WebLinks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0571FC6A28F949E6004846E4 /* BaseIntegrationSpecs+WebLinks.swift */; };
65+
0571FC6D28F94A47004846E4 /* BaseIntegrationSpecs+RetentionPolicies.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0571FC6C28F94A47004846E4 /* BaseIntegrationSpecs+RetentionPolicies.swift */; };
66+
0571FC6F28F94A78004846E4 /* BaseIntegrationSpecs+Files.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0571FC6E28F94A78004846E4 /* BaseIntegrationSpecs+Files.swift */; };
67+
0571FC7128F94ABD004846E4 /* BaseIntegrationSpecs+Folders.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0571FC7028F94ABD004846E4 /* BaseIntegrationSpecs+Folders.swift */; };
6168
0579F6F727577DAD00473A3C /* Nimble.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 05EFAB1F26F0F01100DF1830 /* Nimble.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
6269
0579F6F827577DAD00473A3C /* Quick.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 05EFAB2026F0F01100DF1830 /* Quick.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
6370
0579F70027577FD200473A3C /* FolderModuleIntegrationSpecs.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0579F6FF27577FD200473A3C /* FolderModuleIntegrationSpecs.swift */; };
@@ -674,6 +681,13 @@
674681
056FE12726EF6F6800098F00 /* Quick.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = Quick.xcframework; path = Carthage/Build/Quick.xcframework; sourceTree = "<group>"; };
675682
056FE12826EF6F6800098F00 /* OHHTTPStubs.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = OHHTTPStubs.xcframework; path = Carthage/Build/OHHTTPStubs.xcframework; sourceTree = "<group>"; };
676683
056FE12926EF6F6800098F00 /* Nimble.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = Nimble.xcframework; path = Carthage/Build/Nimble.xcframework; sourceTree = "<group>"; };
684+
0571FC6228F7FA07004846E4 /* WebhooksModuleIntegrationSpecs.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebhooksModuleIntegrationSpecs.swift; sourceTree = "<group>"; };
685+
0571FC6628F9491D004846E4 /* BaseIntegrationSpecs+Webhooks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "BaseIntegrationSpecs+Webhooks.swift"; sourceTree = "<group>"; };
686+
0571FC6828F94996004846E4 /* BaseIntegrationSpecs+Users.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "BaseIntegrationSpecs+Users.swift"; sourceTree = "<group>"; };
687+
0571FC6A28F949E6004846E4 /* BaseIntegrationSpecs+WebLinks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "BaseIntegrationSpecs+WebLinks.swift"; sourceTree = "<group>"; };
688+
0571FC6C28F94A47004846E4 /* BaseIntegrationSpecs+RetentionPolicies.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "BaseIntegrationSpecs+RetentionPolicies.swift"; sourceTree = "<group>"; };
689+
0571FC6E28F94A78004846E4 /* BaseIntegrationSpecs+Files.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "BaseIntegrationSpecs+Files.swift"; sourceTree = "<group>"; };
690+
0571FC7028F94ABD004846E4 /* BaseIntegrationSpecs+Folders.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "BaseIntegrationSpecs+Folders.swift"; sourceTree = "<group>"; };
677691
0579F6FF27577FD200473A3C /* FolderModuleIntegrationSpecs.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FolderModuleIntegrationSpecs.swift; sourceTree = "<group>"; };
678692
057C8CE3276799760092A6EC /* Date+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Date+Extensions.swift"; sourceTree = "<group>"; };
679693
059CF240283D0666001809CA /* FolderModuleAsyncIntegrationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FolderModuleAsyncIntegrationTests.swift; sourceTree = "<group>"; };
@@ -1259,6 +1273,20 @@
12591273
path = Async;
12601274
sourceTree = "<group>";
12611275
};
1276+
0571FC6528F948EF004846E4 /* Base */ = {
1277+
isa = PBXGroup;
1278+
children = (
1279+
05070D2C2757DBD7000AFE20 /* BaseIntegrationSpecs.swift */,
1280+
0571FC6E28F94A78004846E4 /* BaseIntegrationSpecs+Files.swift */,
1281+
0571FC7028F94ABD004846E4 /* BaseIntegrationSpecs+Folders.swift */,
1282+
0571FC6C28F94A47004846E4 /* BaseIntegrationSpecs+RetentionPolicies.swift */,
1283+
0571FC6828F94996004846E4 /* BaseIntegrationSpecs+Users.swift */,
1284+
0571FC6628F9491D004846E4 /* BaseIntegrationSpecs+Webhooks.swift */,
1285+
0571FC6A28F949E6004846E4 /* BaseIntegrationSpecs+WebLinks.swift */,
1286+
);
1287+
path = Base;
1288+
sourceTree = "<group>";
1289+
};
12621290
05EA725C2762649B001ECFF3 /* Resources */ = {
12631291
isa = PBXGroup;
12641292
children = (
@@ -1275,13 +1303,14 @@
12751303
05EC89D527577AF900FEBAC6 /* IntegrationTests */ = {
12761304
isa = PBXGroup;
12771305
children = (
1278-
05070D2C2757DBD7000AFE20 /* BaseIntegrationSpecs.swift */,
12791306
0501990B282423970085003B /* BoxClientIntegrationSpecs.swift */,
12801307
05EA725A27621FA7001ECFF3 /* FileModuleIntegrationSpecs.swift */,
12811308
0579F6FF27577FD200473A3C /* FolderModuleIntegrationSpecs.swift */,
12821309
0BD51EDB28CF257E000DE69E /* RetentionPoliciesModuleIntegrationSpecs.swift */,
12831310
052A03F9287C1FC20063513C /* UsersModuleIntegrationSpecs.swift */,
1311+
0571FC6228F7FA07004846E4 /* WebhooksModuleIntegrationSpecs.swift */,
12841312
054D536B283CFAB800CC2CBC /* Async */,
1313+
0571FC6528F948EF004846E4 /* Base */,
12851314
053637BB276C952D00C18D26 /* Extensions */,
12861315
05EA725C2762649B001ECFF3 /* Resources */,
12871316
0547B737276C99AA002D9E7A /* Utils */,
@@ -2829,24 +2858,31 @@
28292858
isa = PBXSourcesBuildPhase;
28302859
buildActionMask = 2147483647;
28312860
files = (
2861+
0571FC6328F7FA07004846E4 /* WebhooksModuleIntegrationSpecs.swift in Sources */,
28322862
0BD51EDC28CF257E000DE69E /* RetentionPoliciesModuleIntegrationSpecs.swift in Sources */,
28332863
0547B73E276C99AA002D9E7A /* CryptographyUtil.swift in Sources */,
28342864
053637BD276C96E400C18D26 /* IntegrationTestResources.swift in Sources */,
28352865
057C8CE4276799760092A6EC /* Date+Extensions.swift in Sources */,
28362866
05EA725B27621FA7001ECFF3 /* FileModuleIntegrationSpecs.swift in Sources */,
2867+
0571FC7128F94ABD004846E4 /* BaseIntegrationSpecs+Folders.swift in Sources */,
2868+
0571FC6728F9491D004846E4 /* BaseIntegrationSpecs+Webhooks.swift in Sources */,
28372869
05EC1082276A195100252112 /* Collaboration+Extensions.swift in Sources */,
28382870
05EC1084276A19A100252112 /* FolderItem+Extensions.swift in Sources */,
28392871
0547B73F276C99AA002D9E7A /* NameGenerator.swift in Sources */,
28402872
0547B73D276C99AA002D9E7A /* Constants.swift in Sources */,
2873+
0571FC6B28F949E6004846E4 /* BaseIntegrationSpecs+WebLinks.swift in Sources */,
28412874
0543A2392757AA2C0005CA23 /* Configuration.swift in Sources */,
2875+
0571FC6928F94996004846E4 /* BaseIntegrationSpecs+Users.swift in Sources */,
28422876
059CF241283D0666001809CA /* FolderModuleAsyncIntegrationTests.swift in Sources */,
28432877
053EE331283D1CB700B4BF5A /* BaseAsyncIntegrationTests.swift in Sources */,
28442878
0579F70027577FD200473A3C /* FolderModuleIntegrationSpecs.swift in Sources */,
28452879
052A03FA287C1FC20063513C /* UsersModuleIntegrationSpecs.swift in Sources */,
28462880
0547B743276C9A89002D9E7A /* FileUtil.swift in Sources */,
28472881
05EC1086276A1CFE00252112 /* Task+Extensions.swift in Sources */,
2882+
0571FC6F28F94A78004846E4 /* BaseIntegrationSpecs+Files.swift in Sources */,
28482883
0501990C282423970085003B /* BoxClientIntegrationSpecs.swift in Sources */,
28492884
05070D2D2757DBD7000AFE20 /* BaseIntegrationSpecs.swift in Sources */,
2885+
0571FC6D28F94A47004846E4 /* BaseIntegrationSpecs+RetentionPolicies.swift in Sources */,
28502886
);
28512887
runOnlyForDeploymentPostprocessing = 0;
28522888
};
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
//
2+
// BaseIntegrationSpecs+Files.swift
3+
// BoxSDKIntegrationTests-iOS
4+
//
5+
// Created by Artur Jankowski on 14/10/2022.
6+
// Copyright © 2022 box. All rights reserved.
7+
//
8+
9+
@testable import BoxSDK
10+
import Nimble
11+
import Quick
12+
13+
extension BaseIntegrationSpecs {
14+
15+
func uploadFile(fileName: String, stringContent: String, toFolder folderId: String, callback: @escaping (File) -> Void) {
16+
uploadFile(fileName: fileName, dataContent: stringContent.data(using: .utf8)!, toFolder: folderId, callback: callback)
17+
}
18+
19+
func uploadFile(fileName: String, toFolder folderId: String?, callback: @escaping (File) -> Void) {
20+
guard let folderId = folderId else {
21+
fail("folderId should not be nil")
22+
return
23+
}
24+
25+
guard let dataContent = FileUtil.getFileContent(fileName: fileName) else {
26+
fail("Can not get content of file \(fileName)")
27+
return
28+
}
29+
30+
uploadFile(fileName: fileName, dataContent: dataContent, toFolder: folderId, callback: callback)
31+
}
32+
33+
func uploadFile(fileName: String, dataContent: Data, toFolder folderId: String, callback: @escaping (File) -> Void) {
34+
waitUntil(timeout: .seconds(Constants.Timeout.default)) { done in
35+
self.client.files.upload(
36+
data: dataContent,
37+
name: fileName,
38+
parentId: folderId
39+
) { result in
40+
switch result {
41+
case let .success(file):
42+
callback(file)
43+
case let .failure(error):
44+
fail("Expected upload call to suceeded, but instead got \(error)")
45+
}
46+
47+
done()
48+
}
49+
}
50+
}
51+
52+
func deleteFile(_ file: File?) {
53+
guard let file = file else {
54+
return
55+
}
56+
57+
waitUntil(timeout: .seconds(Constants.Timeout.default)) { done in
58+
self.client.files.delete(fileId: file.id) { result in
59+
if case let .failure(error) = result {
60+
fail("Expected delete call to succeed, but instead got \(error)")
61+
}
62+
63+
done()
64+
}
65+
}
66+
}
67+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
//
2+
// BaseIntegrationSpecs+Folders.swift
3+
// BoxSDKIntegrationTests-iOS
4+
//
5+
// Created by Artur Jankowski on 14/10/2022.
6+
// Copyright © 2022 box. All rights reserved.
7+
//
8+
9+
@testable import BoxSDK
10+
import Nimble
11+
import Quick
12+
13+
extension BaseIntegrationSpecs {
14+
15+
func createFolder(name: String, parentId: String = "0", callback: @escaping (Folder) -> Void) {
16+
waitUntil(timeout: .seconds(Constants.Timeout.default)) { done in
17+
self.client.folders.create(name: name, parentId: parentId) { result in
18+
switch result {
19+
case let .success(folder):
20+
callback(folder)
21+
case let .failure(error):
22+
fail("Expected create call to suceeded, but instead got \(error)")
23+
}
24+
25+
done()
26+
}
27+
}
28+
}
29+
30+
func deleteFolder(_ folder: Folder?, recursive: Bool = false) {
31+
guard let folder = folder else {
32+
return
33+
}
34+
35+
waitUntil(timeout: .seconds(Constants.Timeout.default)) { done in
36+
self.client.folders.delete(folderId: folder.id, recursive: recursive) { result in
37+
if case let .failure(error) = result {
38+
fail("Expected delete call to succeed, but instead got \(error)")
39+
}
40+
41+
done()
42+
}
43+
}
44+
}
45+
}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
//
2+
// BaseIntegrationSpecs+RetentionPolicies.swift
3+
// BoxSDKIntegrationTests-iOS
4+
//
5+
// Created by Artur Jankowski on 14/10/2022.
6+
// Copyright © 2022 box. All rights reserved.
7+
//
8+
9+
@testable import BoxSDK
10+
import Nimble
11+
import Quick
12+
13+
extension BaseIntegrationSpecs {
14+
15+
func createRetention(
16+
name: String,
17+
type: RetentionPolicyType = .finite,
18+
length: Int? = 1,
19+
dispositionAction: DispositionAction = .permanentlyDelete,
20+
callback: @escaping (RetentionPolicy) -> Void
21+
) {
22+
waitUntil(timeout: .seconds(Constants.Timeout.default)) { done in
23+
self.client.retentionPolicy.create(
24+
name: name,
25+
type: type,
26+
length: length,
27+
dispositionAction: dispositionAction
28+
) { result in
29+
switch result {
30+
case let .success(retention):
31+
callback(retention)
32+
case let .failure(error):
33+
fail("Expected create retention call to suceeded, but instead got \(error)")
34+
}
35+
36+
done()
37+
}
38+
}
39+
}
40+
41+
func assignRetention(
42+
_ retention: RetentionPolicy?,
43+
assignedContentId: String?,
44+
assignContentType: RetentionPolicyAssignmentItemType = .folder,
45+
callback: @escaping (RetentionPolicyAssignment) -> Void
46+
) {
47+
guard let retention = retention, let assignedContentId = assignedContentId else {
48+
return
49+
}
50+
51+
waitUntil(timeout: .seconds(Constants.Timeout.default)) { done in
52+
self.client.retentionPolicy.assign(
53+
policyId: retention.id,
54+
assignedContentId: assignedContentId,
55+
assignContentType: assignContentType
56+
) { result in
57+
switch result {
58+
case let .success(retentionAssignment):
59+
callback(retentionAssignment)
60+
case let .failure(error):
61+
fail("Expected assign retention policy call to succeed, but instead got \(error)")
62+
}
63+
64+
done()
65+
}
66+
}
67+
}
68+
69+
func retireRetention(_ retention: RetentionPolicy?) {
70+
guard let retention = retention else {
71+
return
72+
}
73+
74+
waitUntil(timeout: .seconds(Constants.Timeout.default)) { done in
75+
self.client.retentionPolicy.update(policyId: retention.id, status: .retired) { result in
76+
if case let .failure(error) = result {
77+
fail("Expected update retention call to succeed, but instead got \(error)")
78+
}
79+
80+
done()
81+
}
82+
}
83+
}
84+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
//
2+
// BaseIntegrationSpecs+Users.swift
3+
// BoxSDKIntegrationTests-iOS
4+
//
5+
// Created by Artur Jankowski on 14/10/2022.
6+
// Copyright © 2022 box. All rights reserved.
7+
//
8+
9+
@testable import BoxSDK
10+
import Nimble
11+
import Quick
12+
13+
extension BaseIntegrationSpecs {
14+
15+
func createUser(name: String, callback: @escaping (User) -> Void) {
16+
waitUntil(timeout: .seconds(Constants.Timeout.default)) { done in
17+
self.client.users.createAppUser(name: name) { result in
18+
switch result {
19+
case let .success(user):
20+
callback(user)
21+
case let .failure(error):
22+
fail("Expected create call to suceeded, but instead got \(error)")
23+
}
24+
25+
done()
26+
}
27+
}
28+
}
29+
30+
func deleteUser(_ user: User?) {
31+
guard let user = user else {
32+
return
33+
}
34+
35+
waitUntil(timeout: .seconds(Constants.Timeout.large)) { done in
36+
self.client.users.delete(userId: user.id, force: true) { result in
37+
if case let .failure(error) = result {
38+
fail("Expected delete call to succeed, but instead got \(error)")
39+
}
40+
41+
done()
42+
}
43+
}
44+
}
45+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//
2+
// BaseIntegrationSpecs+Weblinks.swift
3+
// BoxSDKIntegrationTests-iOS
4+
//
5+
// Created by Artur Jankowski on 14/10/2022.
6+
// Copyright © 2022 box. All rights reserved.
7+
//
8+
9+
@testable import BoxSDK
10+
import Nimble
11+
import Quick
12+
13+
extension BaseIntegrationSpecs {
14+
15+
func deleteWebLink(_ webLink: WebLink?) {
16+
guard let webLink = webLink else {
17+
return
18+
}
19+
20+
waitUntil(timeout: .seconds(Constants.Timeout.default)) { done in
21+
self.client.webLinks.delete(webLinkId: webLink.id) { result in
22+
if case let .failure(error) = result {
23+
fail("Expected delete call to succeed, but instead got \(error)")
24+
}
25+
26+
done()
27+
}
28+
}
29+
}
30+
}

0 commit comments

Comments
 (0)