This commit is contained in:
@@ -87,7 +87,7 @@ namespace raven_integration
|
||||
ApiResponse DELETETestResponse = await Util.DeleteAsync("User/" + d2Id.ToString(), await Util.GetTokenAsync("manager", "l3tm3in"));
|
||||
Util.ValidateHTTPStatusCode(DELETETestResponse, 204);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Test not found
|
||||
@@ -178,6 +178,52 @@ namespace raven_integration
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public async void DisallowedPatchAttemptsShouldFail()
|
||||
{
|
||||
//CREATE
|
||||
dynamic D = new JObject();
|
||||
D.name = Util.Uniquify("DisallowedPatchAttemptsShouldFail");
|
||||
D.ownerId = 1L;
|
||||
D.active = true;
|
||||
D.login = Util.Uniquify("LOGIN");
|
||||
D.password = Util.Uniquify("PASSWORD");
|
||||
D.roles = 0;//norole
|
||||
D.localeId = 1;//random locale
|
||||
D.userType = 3;//non scheduleable
|
||||
|
||||
ApiResponse R = await Util.PostAsync("User", await Util.GetTokenAsync("manager", "l3tm3in"), D.ToString());
|
||||
Util.ValidateDataReturnResponseOk(R);
|
||||
long w2Id = R.ObjectResponse["result"]["id"].Value<long>();
|
||||
uint OriginalConcurrencyToken = R.ObjectResponse["result"]["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 on OwnerId
|
||||
patchJson = "[{\"value\": \"0\",\"path\": \"/ownerid\",\"op\": \"replace\"}]";
|
||||
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>
|
||||
///
|
||||
/// </summary>
|
||||
@@ -210,7 +256,7 @@ namespace raven_integration
|
||||
//PUT
|
||||
var NewPassword = "NEW_PASSWORD";
|
||||
D.password = NewPassword;
|
||||
D.concurrencyToken=OriginalConcurrencyToken;
|
||||
D.concurrencyToken = OriginalConcurrencyToken;
|
||||
R = await Util.PutAsync("User/" + UserId.ToString(), await Util.GetTokenAsync("manager", "l3tm3in"), D.ToString());
|
||||
Util.ValidateDataReturnResponseOk(R);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user