diff --git a/.codegen.json b/.codegen.json index 7b848452..1894be0d 100644 --- a/.codegen.json +++ b/.codegen.json @@ -1 +1 @@ -{ "engineHash": "b3fc516", "specHash": "1698c95", "version": "0.1.0" } +{ "engineHash": "cb5120c", "specHash": "1698c95", "version": "0.1.0" } diff --git a/Tests/CollaborationAllowlistEntries/CollaborationAllowlistEntriesManagerTests.swift b/Tests/CollaborationAllowlistEntries/CollaborationAllowlistEntriesManagerTests.swift new file mode 100644 index 00000000..991f87e8 --- /dev/null +++ b/Tests/CollaborationAllowlistEntries/CollaborationAllowlistEntriesManagerTests.swift @@ -0,0 +1,27 @@ +import Foundation +import BoxSdkGen +import XCTest + +class CollaborationAllowlistEntriesManagerTests: XCTestCase { + var client: BoxClient! + + override func setUp() async throws { + client = CommonsManager().getDefaultClient() + } + + public func testCollaborationAllowlistEntries() async throws { + let allowlist: CollaborationAllowlistEntries = try await client.collaborationAllowlistEntries.getCollaborationWhitelistEntries() + XCTAssertTrue(allowlist.entries!.count >= 0) + let domain: String = "example.com" + let newEntry: CollaborationAllowlistEntry = try await client.collaborationAllowlistEntries.createCollaborationWhitelistEntry(requestBody: CreateCollaborationWhitelistEntryRequestBody(domain: domain, direction: CreateCollaborationWhitelistEntryRequestBodyDirectionField.inbound)) + XCTAssertTrue(Utils.Strings.toString(value: newEntry.type) == "collaboration_whitelist_entry") + XCTAssertTrue(Utils.Strings.toString(value: newEntry.direction) == "inbound") + XCTAssertTrue(newEntry.domain == domain) + let entry: CollaborationAllowlistEntry = try await client.collaborationAllowlistEntries.getCollaborationWhitelistEntryById(collaborationWhitelistEntryId: newEntry.id!) + XCTAssertTrue(entry.id == newEntry.id) + XCTAssertTrue(Utils.Strings.toString(value: entry.direction) == Utils.Strings.toString(value: newEntry.direction)) + XCTAssertTrue(entry.domain == domain) + try await client.collaborationAllowlistEntries.deleteCollaborationWhitelistEntryById(collaborationWhitelistEntryId: entry.id!) + await XCTAssertThrowsErrorAsync(try await client.collaborationAllowlistEntries.getCollaborationWhitelistEntryById(collaborationWhitelistEntryId: entry.id!)) + } +} diff --git a/Tests/FileMetadata/FileMetadataManagerTests.swift b/Tests/FileMetadata/FileMetadataManagerTests.swift index b3607b9e..0f920b38 100644 --- a/Tests/FileMetadata/FileMetadataManagerTests.swift +++ b/Tests/FileMetadata/FileMetadataManagerTests.swift @@ -20,7 +20,7 @@ class FileMetadataManagerTests: XCTestCase { let receivedMetadata: MetadataFull = try await client.fileMetadata.getFileMetadataById(fileId: file.id, scope: GetFileMetadataByIdScope.global, templateKey: "properties") XCTAssertTrue(receivedMetadata.extraData!["abc"] == "xyz") let newValue: String = "bar" - let updatedMetadata: MetadataFull = try await client.fileMetadata.updateFileMetadataById(fileId: file.id, scope: UpdateFileMetadataByIdScope.global, templateKey: "properties", requestBody: [UpdateFileMetadataByIdRequestBody(op: UpdateFileMetadataByIdRequestBodyOpField.replace, path: "/abc", value: newValue)]) + try await client.fileMetadata.updateFileMetadataById(fileId: file.id, scope: UpdateFileMetadataByIdScope.global, templateKey: "properties", requestBody: [UpdateFileMetadataByIdRequestBody(op: UpdateFileMetadataByIdRequestBodyOpField.replace, path: "/abc", value: newValue)]) let receivedUpdatedMetadata: MetadataFull = try await client.fileMetadata.getFileMetadataById(fileId: file.id, scope: GetFileMetadataByIdScope.global, templateKey: "properties") XCTAssertTrue(receivedUpdatedMetadata.extraData!["abc"] == newValue) try await client.fileMetadata.deleteFileMetadataById(fileId: file.id, scope: DeleteFileMetadataByIdScope.global, templateKey: "properties") diff --git a/Tests/FolderMetadata/FolderMetadataManagerTests.swift b/Tests/FolderMetadata/FolderMetadataManagerTests.swift index b9c591b0..38c9cd5e 100644 --- a/Tests/FolderMetadata/FolderMetadataManagerTests.swift +++ b/Tests/FolderMetadata/FolderMetadataManagerTests.swift @@ -20,7 +20,7 @@ class FolderMetadataManagerTests: XCTestCase { let receivedMetadata: MetadataFull = try await client.folderMetadata.getFolderMetadataById(folderId: folder.id, scope: GetFolderMetadataByIdScope.global, templateKey: "properties") XCTAssertTrue(receivedMetadata.extraData!["abc"] == "xyz") let newValue: String = "bar" - let updatedMetadata: MetadataFull = try await client.folderMetadata.updateFolderMetadataById(folderId: folder.id, scope: UpdateFolderMetadataByIdScope.global, templateKey: "properties", requestBody: [UpdateFolderMetadataByIdRequestBody(op: UpdateFolderMetadataByIdRequestBodyOpField.replace, path: "/abc", value: newValue)]) + try await client.folderMetadata.updateFolderMetadataById(folderId: folder.id, scope: UpdateFolderMetadataByIdScope.global, templateKey: "properties", requestBody: [UpdateFolderMetadataByIdRequestBody(op: UpdateFolderMetadataByIdRequestBodyOpField.replace, path: "/abc", value: newValue)]) let receivedUpdatedMetadata: MetadataFull = try await client.folderMetadata.getFolderMetadataById(folderId: folder.id, scope: GetFolderMetadataByIdScope.global, templateKey: "properties") XCTAssertTrue(receivedUpdatedMetadata.extraData!["abc"] == newValue) try await client.folderMetadata.deleteFolderMetadataById(folderId: folder.id, scope: DeleteFolderMetadataByIdScope.global, templateKey: "properties") diff --git a/Tests/LegalHoldPolicyAssignments/LegalHoldPolicyAssignmentsManagerTests.swift b/Tests/LegalHoldPolicyAssignments/LegalHoldPolicyAssignmentsManagerTests.swift index d7d7d5ce..2d707301 100644 --- a/Tests/LegalHoldPolicyAssignments/LegalHoldPolicyAssignmentsManagerTests.swift +++ b/Tests/LegalHoldPolicyAssignments/LegalHoldPolicyAssignmentsManagerTests.swift @@ -26,5 +26,11 @@ class LegalHoldPolicyAssignmentsManagerTests: XCTestCase { try await client.legalHoldPolicyAssignments.deleteLegalHoldPolicyAssignmentById(legalHoldPolicyAssignmentId: legalHoldPolicyAssignmentId) await XCTAssertThrowsErrorAsync(try await client.legalHoldPolicyAssignments.deleteLegalHoldPolicyAssignmentById(legalHoldPolicyAssignmentId: legalHoldPolicyAssignmentId)) try await client.files.deleteFileById(fileId: fileId) + do { + try await client.legalHoldPolicies.deleteLegalHoldPolicyById(legalHoldPolicyId: legalHoldPolicyId) + } catch { + print("\("Could not delete Legal Policy with id: ")\(legalHoldPolicyId)") + } + } } diff --git a/Tests/Weblinks/WeblinksManagerTests.swift b/Tests/Weblinks/WeblinksManagerTests.swift new file mode 100644 index 00000000..91db25d7 --- /dev/null +++ b/Tests/Weblinks/WeblinksManagerTests.swift @@ -0,0 +1,34 @@ +import Foundation +import BoxSdkGen +import XCTest + +class WeblinksManagerTests: XCTestCase { + var client: BoxClient! + + override func setUp() async throws { + client = CommonsManager().getDefaultClient() + } + + public func testCreateGetDeleteWeblink() async throws { + let url: String = "https://www.box.com" + let parent: FolderFull = try await client.folders.getFolderById(folderId: "0") + let name: String = Utils.getUUID() + let description: String = "Weblink description" + let password: String = "super-secret-password" + let weblink: WebLink = try await client.webLinks.createWebLink(requestBody: CreateWebLinkRequestBody(url: url, parent: CreateWebLinkRequestBodyParentField(id: parent.id), name: name, description: description)) + XCTAssertTrue(weblink.url == url) + XCTAssertTrue(weblink.parent!.id == parent.id) + XCTAssertTrue(weblink.name == name) + XCTAssertTrue(weblink.description == description) + let weblinkById: WebLink = try await client.webLinks.getWebLinkById(webLinkId: weblink.id) + XCTAssertTrue(weblinkById.id == weblink.id) + XCTAssertTrue(weblinkById.url == url) + let updatedName: String = Utils.getUUID() + let updatedWeblink: WebLink = try await client.webLinks.updateWebLinkById(webLinkId: weblink.id, requestBody: UpdateWebLinkByIdRequestBody(name: updatedName, sharedLink: UpdateWebLinkByIdRequestBodySharedLinkField(access: UpdateWebLinkByIdRequestBodySharedLinkAccessField.open, password: password))) + XCTAssertTrue(updatedWeblink.name == updatedName) + XCTAssertTrue(Utils.Strings.toString(value: updatedWeblink.sharedLink!.access!) == "open") + try await client.webLinks.deleteWebLinkById(webLinkId: weblink.id) + let deletedWeblink: WebLink = try await client.webLinks.getWebLinkById(webLinkId: weblink.id) + XCTAssertTrue(Utils.Strings.toString(value: deletedWeblink.itemStatus!) == "trashed") + } +} diff --git a/docs/CollaborationAllowlistEntries.md b/docs/CollaborationAllowlistEntries.md index 8e3acebb..efcd4bb0 100644 --- a/docs/CollaborationAllowlistEntries.md +++ b/docs/CollaborationAllowlistEntries.md @@ -16,7 +16,10 @@ This operation is performed by calling function `getCollaborationWhitelistEntrie See the endpoint docs at [API Reference](https://developer.box.com/reference/get-collaboration-whitelist-entries/). -*Currently we don't have an example for calling `getCollaborationWhitelistEntries` in integration tests* + +``` +try await client.collaborationAllowlistEntries.getCollaborationWhitelistEntries() +``` ### Arguments @@ -43,7 +46,10 @@ This operation is performed by calling function `createCollaborationWhitelistEnt See the endpoint docs at [API Reference](https://developer.box.com/reference/post-collaboration-whitelist-entries/). -*Currently we don't have an example for calling `createCollaborationWhitelistEntry` in integration tests* + +``` +try await client.collaborationAllowlistEntries.createCollaborationWhitelistEntry(requestBody: CreateCollaborationWhitelistEntryRequestBody(direction: CreateCollaborationWhitelistEntryRequestBodyDirectionField.inbound, domain: domain)) +``` ### Arguments @@ -70,7 +76,10 @@ This operation is performed by calling function `getCollaborationWhitelistEntryB See the endpoint docs at [API Reference](https://developer.box.com/reference/get-collaboration-whitelist-entries-id/). -*Currently we don't have an example for calling `getCollaborationWhitelistEntryById` in integration tests* + +``` +try await client.collaborationAllowlistEntries.getCollaborationWhitelistEntryById(collaborationWhitelistEntryId: entry.id!) +``` ### Arguments @@ -97,7 +106,10 @@ This operation is performed by calling function `deleteCollaborationWhitelistEnt See the endpoint docs at [API Reference](https://developer.box.com/reference/delete-collaboration-whitelist-entries-id/). -*Currently we don't have an example for calling `deleteCollaborationWhitelistEntryById` in integration tests* + +``` +try await client.collaborationAllowlistEntries.deleteCollaborationWhitelistEntryById(collaborationWhitelistEntryId: entry.id!) +``` ### Arguments diff --git a/docs/LegalHoldPolicies.md b/docs/LegalHoldPolicies.md index 3fea8384..175840e2 100644 --- a/docs/LegalHoldPolicies.md +++ b/docs/LegalHoldPolicies.md @@ -140,7 +140,7 @@ See the endpoint docs at ``` -try await client.legalHoldPolicies.deleteLegalHoldPolicyById(legalHoldPolicyId: legalHoldPolicy.id) +try await client.legalHoldPolicies.deleteLegalHoldPolicyById(legalHoldPolicyId: legalHoldPolicyId) ``` ### Arguments diff --git a/docs/WebLinks.md b/docs/WebLinks.md index 703dab14..dcffe0e8 100644 --- a/docs/WebLinks.md +++ b/docs/WebLinks.md @@ -73,7 +73,10 @@ This operation is performed by calling function `updateWebLinkById`. See the endpoint docs at [API Reference](https://developer.box.com/reference/put-web-links-id/). -*Currently we don't have an example for calling `updateWebLinkById` in integration tests* + +``` +try await client.webLinks.updateWebLinkById(webLinkId: weblink.id, requestBody: UpdateWebLinkByIdRequestBody(name: updatedName, sharedLink: UpdateWebLinkByIdRequestBodySharedLinkField(access: UpdateWebLinkByIdRequestBodySharedLinkAccessField.open, password: password))) +``` ### Arguments