Skip to content

Commit

Permalink
Merge branch 'main' into docs-for-570
Browse files Browse the repository at this point in the history
  • Loading branch information
mwwoda authored Feb 26, 2024
2 parents 0ed3945 + 096a098 commit e3661f4
Show file tree
Hide file tree
Showing 14 changed files with 493 additions and 47 deletions.
39 changes: 39 additions & 0 deletions Box.V2.Test.Integration/BoxFolderManagerIntegrationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -242,5 +242,44 @@ public async Task GetFolderItemsAsync_ForFolderWithSharedLink_ShouldReturnAllFol
Assert.AreEqual(items.TotalCount, 1);
Assert.AreEqual(items.Entries[0].Id, file.Id);
}

[TestMethod]
public async Task GetFolderItemsAsync_WithOffsetPagination_ShouldReturnCorrectNumberOfFolderItems()
{
var folder = await CreateFolder();
await CreateSmallFile(folder.Id);
await CreateSmallFile(folder.Id);

var items = await UserClient.FoldersManager.GetFolderItemsAsync(folder.Id, 1, 0);

Assert.AreEqual(items.Entries.Count, 1);
Assert.AreEqual(items.TotalCount, 2);

items = await UserClient.FoldersManager.GetFolderItemsAsync(folder.Id, 1, 1);

Assert.AreEqual(items.Entries.Count, 1);

items = await UserClient.FoldersManager.GetFolderItemsAsync(folder.Id, 1, 2);
Assert.AreEqual(items.Entries.Count, 0);
}

[TestMethod]
public async Task GetFolderItemsMarkerBasedAsync_WithMarkerPagination_ShouldReturnCorrectNumberOfFolderItems()
{
var folder = await CreateFolder();
await CreateSmallFile(folder.Id);
await CreateSmallFile(folder.Id);

var items = await UserClient.FoldersManager.GetFolderItemsMarkerBasedAsync(folder.Id, 1);

Assert.AreEqual(items.Entries.Count, 1);
Assert.IsNotNull(items.NextMarker);

var nextMarker = items.NextMarker;

items = await UserClient.FoldersManager.GetFolderItemsMarkerBasedAsync(folder.Id, 1, marker: nextMarker);
Assert.AreEqual(items.Entries.Count, 1);
Assert.IsNull(items.NextMarker);
}
}
}
33 changes: 29 additions & 4 deletions Box.V2.Test.Integration/BoxSignRequestManagerIntegrationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,19 @@ public async Task CreateSignRequestAsync_ForCorrectSignRequestCreateRequest_Shou
Email = "[email protected]",
RedirectUrl = new Uri("https://www.box.com/redirect_url_signer_1"),
DeclinedRedirectUrl = new Uri("https://www.box.com/declined_redirect_url_singer_1"),
EmbedUrlExternalUserId = UserId
EmbedUrlExternalUserId = UserId,
SignerGroupId = "SignerGroup",
Password = "password",
LoginRequired = false,
},
new BoxSignRequestSignerCreate()
{
Email = "[email protected]",
RedirectUrl = new Uri("https://www.box.com/redirect_url_signer_2"),
DeclinedRedirectUrl = new Uri("https://www.box.com/declined_redirect_url_singer_2"),
SignerGroupId = "SignerGroup",
Password = "password",
LoginRequired = false,
}
},
ParentFolder = new BoxRequestEntity()
Expand All @@ -55,10 +67,23 @@ public async Task CreateSignRequestAsync_ForCorrectSignRequestCreateRequest_Shou
Assert.AreEqual(signRequestCreateRequest.DeclinedRedirectUrl.ToString(), signRequest.DeclinedRedirectUrl.ToString());
Assert.AreEqual(signRequestCreateRequest.ParentFolder.Id, signRequest.ParentFolder.Id);

// first signer is the sender with role final_copy_reader, second is the recipient with role signer
Assert.AreEqual(2, signRequest.Signers.Count);
// first signer is the sender with role final_copy_reader, second and third is the recipient with role signer
Assert.AreEqual(3, signRequest.Signers.Count);
Assert.IsNotNull(signRequest.Signers[1].IframeableEmbedUrl);

var signerGroupId = "";
foreach (var signer in signRequest.Signers)
{
if (signer.Role == BoxSignRequestSignerRole.signer)
{
if (string.IsNullOrEmpty(signerGroupId))
{
signerGroupId = signer.SignerGroupId;
}
Assert.AreEqual(signerGroupId, signer.SignerGroupId);
}
}

await UserClient.SignRequestsManager.CancelSignRequestAsync(signRequest.Id);

signRequest = await UserClient.SignRequestsManager.GetSignRequestByIdAsync(signRequest.Id);
Expand All @@ -68,7 +93,7 @@ public async Task CreateSignRequestAsync_ForCorrectSignRequestCreateRequest_Shou
[TestMethod]
public async Task GetSignRequestAsync_ForExistingSignRequest_ShouldReturnSignRequest()
{
var signRequest = await CreateSignRequest();
var signRequest = await CreateSignRequest("[email protected]", FolderId);
var fetchedSignRequest = await UserClient.SignRequestsManager.GetSignRequestByIdAsync(signRequest.Id);

Assert.AreEqual(signRequest.Id, fetchedSignRequest.Id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public async Task DeleteWebhookAsync_ForExistingWebhook_ShouldDeleteWebhookAndEx
[TestMethod]
public async Task AddWebhook_ForSignRequest_ShouldCreateSuccess()
{
var signRequest = await CreateSignRequest();
var signRequest = await CreateSignRequest("[email protected]", FolderId);
var signFileId = signRequest.SignFiles.Files[0].Id;
var webhookRequest = new BoxWebhookRequest()
{
Expand Down
4 changes: 2 additions & 2 deletions Box.V2.Test.Integration/Configuration/IntegrationTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -389,10 +389,10 @@ public static async Task Retry(Func<Task> action, int retries = 5, int sleep = 5
}
}

public static async Task<BoxSignRequest> CreateSignRequest(string signerEmail = "[email protected]")
public static async Task<BoxSignRequest> CreateSignRequest(string signerEmail = "[email protected]", string folderId = "0")
{
var file = await CreateSmallFile();
var createSignRequestCommand = new CreateSignRequestCommand(signerEmail, file.Id);
var createSignRequestCommand = new CreateSignRequestCommand(signerEmail, file.Id, folderId);
await ExecuteCommand(createSignRequestCommand);
return createSignRequestCommand.SignRequest;
}
Expand Down
3 changes: 3 additions & 0 deletions Box.V2.Test/Box.V2.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
<None Update="Fixtures\BoxFiles\UploadNewVersionUsingSession200.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Fixtures\BoxFolders\GetFolderItemsMarkerBased200.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Fixtures\BoxFolders\CreateFolderSharedLink200.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down
22 changes: 22 additions & 0 deletions Box.V2.Test/BoxFoldersManagerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1063,5 +1063,27 @@ public async Task DeleteFolderLock_ValidResponse()
//Response check
Assert.AreEqual(true, result);
}

[TestMethod]
public async Task GetFolderItemsMarkerBased_ValidResponse_ValidFolder()
{
Handler.Setup(h => h.ExecuteAsync<BoxCollectionMarkerBased<BoxItem>>(It.IsAny<IBoxRequest>()))
.Returns(() => Task.FromResult<IBoxResponse<BoxCollectionMarkerBased<BoxItem>>>(new BoxResponse<BoxCollectionMarkerBased<BoxItem>>()
{
Status = ResponseStatus.Success,
ContentString = LoadFixtureFromJson("Fixtures/BoxFolders/GetFolderItemsMarkerBased200.json")
}));

BoxCollectionMarkerBased<BoxItem> items = await _foldersManager.GetFolderItemsMarkerBasedAsync("0", 1000);

Assert.AreEqual(items.Entries.Count, 1);
Assert.AreEqual(items.Entries[0].Type, "file");
Assert.AreEqual(items.Entries[0].Id, "12345");
Assert.AreEqual(items.Entries[0].SequenceId, "3");
Assert.AreEqual(items.Entries[0].ETag, "1");
Assert.AreEqual(items.Entries[0].Name, "Contract.pdf");
Assert.AreEqual(items.NextMarker, "JV9IRGZmieiBasejOG9yDCRNgd2ymoZIbjsxbJMjIs3kioVii");
Assert.AreEqual(items.Limit, 1000);
}
}
}
35 changes: 30 additions & 5 deletions Box.V2.Test/BoxSignRequestsManagerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,12 @@ public async Task CreateSignRequest_RequiredParams_Success()
{
Email = "[email protected]",
Role = BoxSignRequestSignerRole.signer
}
},
new BoxSignRequestSignerCreate()
{
Email = "[email protected]",
Role = BoxSignRequestSignerRole.signer
},
};

var parentFolder = new BoxRequestEntity()
Expand Down Expand Up @@ -77,7 +82,7 @@ public async Task CreateSignRequest_RequiredParams_Success()
// Response check
Assert.AreEqual(1, response.SourceFiles.Count);
Assert.AreEqual("12345", response.SourceFiles[0].Id);
Assert.AreEqual(1, response.Signers.Count);
Assert.AreEqual(2, response.Signers.Count);
Assert.AreEqual("[email protected]", response.Signers[0].Email);
Assert.AreEqual("12345", response.ParentFolder.Id);
Assert.AreEqual(1, response.Signers[0].Inputs.Count);
Expand Down Expand Up @@ -113,7 +118,19 @@ public async Task CreateSignRequest_OptionalParams_Success()
Email = "[email protected]",
Role = BoxSignRequestSignerRole.signer,
RedirectUrl = new Uri("https://box.com/redirect_url_signer_1"),
DeclinedRedirectUrl = new Uri("https://box.com/declined_redirect_url_signer_1")
DeclinedRedirectUrl = new Uri("https://box.com/declined_redirect_url_signer_1"),
LoginRequired = false,
Password = "abcdefg",
SignerGroupId = "SignerGroup",
VerificationPhoneNumber = "1234567890",
}, new BoxSignRequestSignerCreate()
{
Email = "[email protected]",
Role = BoxSignRequestSignerRole.signer,
RedirectUrl = new Uri("https://box.com/redirect_url_signer_1"),
DeclinedRedirectUrl = new Uri("https://box.com/declined_redirect_url_signer_1"),
SignerGroupId = "SignerGroup",
VerificationPhoneNumber = "1234567890",
}
};

Expand Down Expand Up @@ -145,7 +162,7 @@ public async Task CreateSignRequest_OptionalParams_Success()
"text"
)
},
TemplateId = "12345"
TemplateId = "12345",
};

/*** Act ***/
Expand All @@ -160,7 +177,7 @@ public async Task CreateSignRequest_OptionalParams_Success()
// Response check
Assert.AreEqual(1, response.SourceFiles.Count);
Assert.AreEqual("12345", response.SourceFiles[0].Id);
Assert.AreEqual(1, response.Signers.Count);
Assert.AreEqual(2, response.Signers.Count);
Assert.AreEqual("[email protected]", response.Signers[0].Email);
Assert.AreEqual("https://box.com/redirect_url_signer_1", response.Signers[0].RedirectUrl.ToString());
Assert.AreEqual("https://box.com/declined_redirect_url_signer_1", response.Signers[0].DeclinedRedirectUrl.ToString());
Expand All @@ -183,6 +200,14 @@ public async Task CreateSignRequest_OptionalParams_Success()
Assert.AreEqual("https://box.com/redirect_url", response.RedirectUrl.ToString());
Assert.AreEqual("https://box.com/declined_redirect_url", response.DeclinedRedirectUrl.ToString());
Assert.AreEqual("12345", response.TemplateId);
Assert.AreEqual("cd4ff89-8fc1-42cf-8b29-1890dedd26d7", response.Signers[0].SignerGroupId);
Assert.AreEqual("1234567890", response.Signers[0].VerificationPhoneNumber);
Assert.AreEqual("cd4ff89-8fc1-42cf-8b29-1890dedd26d7", response.Signers[1].SignerGroupId);
Assert.AreEqual("1234567890", response.Signers[1].VerificationPhoneNumber);
Assert.IsFalse(response.Signers[0].LoginRequired);
Assert.AreEqual("abcdefg", response.Signers[0].Password);
Assert.IsFalse(response.Signers[1].LoginRequired);
Assert.AreEqual("abcdefg", response.Signers[1].Password);
}

[TestMethod]
Expand Down
Loading

0 comments on commit e3661f4

Please sign in to comment.