-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: correctly pass null when rolling out user from the enterprise (#792
) Co-authored-by: Jonathan Black <[email protected]>
- Loading branch information
Showing
3 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -206,6 +206,39 @@ public async Task UpdateUser_ValidResponse_ValidUser() | |
Assert.AreEqual("[email protected]", user.NotificationEmail.Email); | ||
} | ||
|
||
[TestMethod] | ||
[TestCategory("CI-UNIT-TEST")] | ||
public async Task RolloutUserFromEnterprise_ValidResponse_ValidUser() | ||
{ | ||
/*** Arrange ***/ | ||
var responseString = "{\"type\":\"user\",\"id\":\"181216415\",\"name\":\"sean\",\"login\":\"[email protected]\",\"created_at\":\"2012-05-03T21:39:11-07:00\",\"modified_at\":\"2012-12-06T18:17:16-08:00\",\"role\":\"admin\",\"language\":\"en\",\"space_amount\":5368709120,\"space_used\":1237179286,\"max_upload_size\":2147483648,\"tracking_codes\":[],\"can_see_managed_users\":true,\"is_sync_enabled\":true,\"status\":\"active\",\"job_title\":\"\",\"phone\":\"6509241374\",\"address\":\"\",\"avatar_url\":\"https://www.box.com/api/avatar/large/181216415\",\"is_exempt_from_device_limits\":false,\"is_exempt_from_login_verification\":false, \"notification_email\": { \"email\": \"[email protected]\", \"is_confirmed\": true}}"; | ||
IBoxRequest boxRequest = null; | ||
Handler.Setup(h => h.ExecuteAsync<BoxUser>(It.IsAny<IBoxRequest>())) | ||
.Returns(Task.FromResult<IBoxResponse<BoxUser>>(new BoxResponse<BoxUser>() | ||
{ | ||
Status = ResponseStatus.Success, | ||
ContentString = responseString | ||
})) | ||
.Callback<IBoxRequest>(r => boxRequest = r); | ||
|
||
/*** Act ***/ | ||
var userRequest = new BoxUserRollOutRequest() | ||
{ | ||
Id = "181216415", | ||
}; | ||
BoxUser user = await _usersManager.UpdateUserInformationAsync(userRequest); | ||
|
||
/*** Assert ***/ | ||
|
||
// Request check | ||
Assert.IsNotNull(boxRequest); | ||
Assert.AreEqual(RequestMethod.Put, boxRequest.Method); | ||
Assert.AreEqual(UserUri + "181216415", boxRequest.AbsoluteUri.AbsoluteUri); | ||
BoxUserRequest payload = JsonConvert.DeserializeObject<BoxUserRequest>(boxRequest.Payload); | ||
Assert.AreEqual(userRequest.Id, payload.Id); | ||
Assert.AreEqual(boxRequest.Payload, "{\"enterprise\":null,\"id\":\"181216415\"}"); | ||
} | ||
|
||
[TestMethod] | ||
[TestCategory("CI-UNIT-TEST")] | ||
public async Task InviteUser_ValidResponse_ValidUser() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using Newtonsoft.Json; | ||
|
||
namespace Box.V2.Models | ||
{ | ||
/// <summary> | ||
/// A request class for rolling users out of the enterprise. | ||
/// </summary> | ||
public class BoxUserRollOutRequest : BoxUserRequest | ||
{ | ||
/// <summary> | ||
/// Setting this to null will roll the user out of the enterprise and make them a free user | ||
/// </summary> | ||
[JsonProperty(PropertyName = "enterprise", NullValueHandling = NullValueHandling.Include)] | ||
public new string Enterprise { get; set; } | ||
|
||
} | ||
} |