This commit is contained in:
2020-05-13 19:44:34 +00:00
parent 58ddcb1d11
commit 38d5bf6ecb

View File

@@ -77,17 +77,6 @@ namespace raven_integration
checkPUTWorked.ObjectResponse["data"]["name"].Value<string>().Should().Be(D2.name.ToString());
uint concurrencyToken = PUTTestResponse.ObjectResponse["data"]["concurrencyToken"].Value<uint>();
//PATCH
var newName = Util.Uniquify("UPDATED VIA PATCH SECOND TEST User");
string patchJson = "[{\"value\": \"" + newName + "\",\"path\": \"/name\",\"op\": \"replace\"}]";
ApiResponse PATCHTestResponse = await Util.PatchAsync("User/" + d2Id.ToString() + "/" + concurrencyToken.ToString(), await Util.GetTokenAsync("manager", "l3tm3in"), patchJson);
Util.ValidateHTTPStatusCode(PATCHTestResponse, 200);
//check PATCH worked
ApiResponse checkPATCHWorked = await Util.GetAsync("User/" + d2Id.ToString(), await Util.GetTokenAsync("manager", "l3tm3in"));
Util.ValidateNoErrorInResponse(checkPATCHWorked);
checkPATCHWorked.ObjectResponse["data"]["name"].Value<string>().Should().Be(newName);
//DELETE
ApiResponse DELETETestResponse = await Util.DeleteAsync("User/" + d2Id.ToString(), await Util.GetTokenAsync("manager", "l3tm3in"));
Util.ValidateHTTPStatusCode(DELETETestResponse, 204);
@@ -165,86 +154,6 @@ namespace raven_integration
}
/// <summary>
///
/// </summary>
[Fact]
public async void PatchConcurrencyViolationShouldFail()
{
//CREATE
dynamic D = new JObject();
D.name = Util.Uniquify("PatchConcurrencyViolationShouldFail");
D.active = true;
D.login = Util.Uniquify("LOGIN");
D.password = Util.Uniquify("PASSWORD");
D.roles = 0;//norole
D.userType = 3;//non scheduleable
//Required by form custom rules
D.notes = "notes";
D.customFields = Util.UserRequiredCustomFieldsJsonString();
ApiResponse R = await Util.PostAsync("User", await Util.GetTokenAsync("manager", "l3tm3in"), D.ToString());
Util.ValidateDataReturnResponseOk(R);
long w2Id = R.ObjectResponse["data"]["id"].Value<long>();
uint OriginalConcurrencyToken = R.ObjectResponse["data"]["concurrencyToken"].Value<uint>();
//PATCH
var newName = Util.Uniquify("PutConcurrencyViolationShouldFail UPDATED VIA PATCH");
string patchJson = "[{\"value\": \"" + newName + "\",\"path\": \"/name\",\"op\": \"replace\"}]";
ApiResponse PATCHTestResponse = await Util.PatchAsync("User/" + w2Id.ToString() + "/" + (OriginalConcurrencyToken - 1).ToString(), await Util.GetTokenAsync("manager", "l3tm3in"), patchJson);
Util.ValidateConcurrencyError(PATCHTestResponse);
}
/// <summary>
///
/// </summary>
[Fact]
public async void DisallowedPatchAttemptsShouldFail()
{
//CREATE
dynamic D = new JObject();
D.name = Util.Uniquify("DisallowedPatchAttemptsShouldFail");
D.active = true;
D.login = Util.Uniquify("LOGIN");
D.password = Util.Uniquify("PASSWORD");
D.roles = 0;//norole
D.userType = 3;//non scheduleable
//Required by form custom rules
D.notes = "notes";
D.customFields = Util.UserRequiredCustomFieldsJsonString();
ApiResponse R = await Util.PostAsync("User", await Util.GetTokenAsync("manager", "l3tm3in"), D.ToString());
Util.ValidateDataReturnResponseOk(R);
long w2Id = R.ObjectResponse["data"]["id"].Value<long>();
uint OriginalConcurrencyToken = R.ObjectResponse["data"]["concurrencyToken"].Value<uint>();
//PATCH attempt on Id
string patchJson = "[{\"value\": \"0\",\"path\": \"/id\",\"op\": \"replace\"}]";
ApiResponse PATCHTestResponse = await Util.PatchAsync("User/" + w2Id.ToString() + "/" + (OriginalConcurrencyToken - 1).ToString(), await Util.GetTokenAsync("manager", "l3tm3in"), patchJson);
Util.ValidateErrorCodeResponse(PATCHTestResponse, 2200, 400);
//PATCH attempt add field
patchJson = "[{\"value\": \"0\",\"path\": \"/bogus\",\"op\": \"add\"}]";
PATCHTestResponse = await Util.PatchAsync("User/" + w2Id.ToString() + "/" + (OriginalConcurrencyToken - 1).ToString(), await Util.GetTokenAsync("manager", "l3tm3in"), patchJson);
Util.ValidateErrorCodeResponse(PATCHTestResponse, 2200, 400);
//PATCH attempt remove name field
patchJson = "[{\"path\": \"/name\",\"op\": \"remove\"}]";
PATCHTestResponse = await Util.PatchAsync("User/" + w2Id.ToString() + "/" + (OriginalConcurrencyToken - 1).ToString(), await Util.GetTokenAsync("manager", "l3tm3in"), patchJson);
Util.ValidateErrorCodeResponse(PATCHTestResponse, 2200, 400);
}
/// <summary>
///