Skip to content

Commit

Permalink
test: add integration tests for CollaborationAllowlistEntries and `…
Browse files Browse the repository at this point in the history
…Weblinks` (box/box-codegen#475) (#84)
  • Loading branch information
box-sdk-build authored Apr 29, 2024
1 parent a6f2230 commit e072840
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .codegen.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ "engineHash": "b3fc516", "specHash": "1698c95", "version": "0.1.0" }
{ "engineHash": "cb5120c", "specHash": "1698c95", "version": "0.1.0" }
Original file line number Diff line number Diff line change
@@ -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!))
}
}
2 changes: 1 addition & 1 deletion Tests/FileMetadata/FileMetadataManagerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion Tests/FolderMetadata/FolderMetadataManagerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)")
}

}
}
34 changes: 34 additions & 0 deletions Tests/Weblinks/WeblinksManagerTests.swift
Original file line number Diff line number Diff line change
@@ -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")
}
}
20 changes: 16 additions & 4 deletions docs/CollaborationAllowlistEntries.md
Original file line number Diff line number Diff line change
Expand Up @@ -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*
<!-- sample get_collaboration_whitelist_entries -->
```
try await client.collaborationAllowlistEntries.getCollaborationWhitelistEntries()
```

### Arguments

Expand All @@ -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*
<!-- sample post_collaboration_whitelist_entries -->
```
try await client.collaborationAllowlistEntries.createCollaborationWhitelistEntry(requestBody: CreateCollaborationWhitelistEntryRequestBody(direction: CreateCollaborationWhitelistEntryRequestBodyDirectionField.inbound, domain: domain))
```

### Arguments

Expand All @@ -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*
<!-- sample get_collaboration_whitelist_entries_id -->
```
try await client.collaborationAllowlistEntries.getCollaborationWhitelistEntryById(collaborationWhitelistEntryId: entry.id!)
```

### Arguments

Expand All @@ -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*
<!-- sample delete_collaboration_whitelist_entries_id -->
```
try await client.collaborationAllowlistEntries.deleteCollaborationWhitelistEntryById(collaborationWhitelistEntryId: entry.id!)
```

### Arguments

Expand Down
2 changes: 1 addition & 1 deletion docs/LegalHoldPolicies.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ See the endpoint docs at

<!-- sample delete_legal_hold_policies_id -->
```
try await client.legalHoldPolicies.deleteLegalHoldPolicyById(legalHoldPolicyId: legalHoldPolicy.id)
try await client.legalHoldPolicies.deleteLegalHoldPolicyById(legalHoldPolicyId: legalHoldPolicyId)
```

### Arguments
Expand Down
5 changes: 4 additions & 1 deletion docs/WebLinks.md
Original file line number Diff line number Diff line change
Expand Up @@ -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*
<!-- sample put_web_links_id -->
```
try await client.webLinks.updateWebLinkById(webLinkId: weblink.id, requestBody: UpdateWebLinkByIdRequestBody(name: updatedName, sharedLink: UpdateWebLinkByIdRequestBodySharedLinkField(access: UpdateWebLinkByIdRequestBodySharedLinkAccessField.open, password: password)))
```

### Arguments

Expand Down

0 comments on commit e072840

Please sign in to comment.