This commit is contained in:
@@ -33,6 +33,7 @@ namespace raven_integration
|
|||||||
w.active = true;
|
w.active = true;
|
||||||
w.usertype = 1;
|
w.usertype = 1;
|
||||||
|
|
||||||
|
//*** CREATED
|
||||||
ApiResponse r2 = await Util.PostAsync("Widget", await Util.GetTokenAsync("InventoryFull"), w.ToString());
|
ApiResponse r2 = await Util.PostAsync("Widget", await Util.GetTokenAsync("InventoryFull"), w.ToString());
|
||||||
Util.ValidateDataReturnResponseOk(r2);
|
Util.ValidateDataReturnResponseOk(r2);
|
||||||
long w2Id = r2.ObjectResponse["data"]["id"].Value<long>();
|
long w2Id = r2.ObjectResponse["data"]["id"].Value<long>();
|
||||||
@@ -40,21 +41,16 @@ namespace raven_integration
|
|||||||
ApiResponse EventLogResponse = await Util.GetAsync($"EventLog/ObjectLog?AyType=2&AyId={w2Id}", await Util.GetTokenAsync("BizAdminFull"));
|
ApiResponse EventLogResponse = await Util.GetAsync($"EventLog/ObjectLog?AyType=2&AyId={w2Id}", await Util.GetTokenAsync("BizAdminFull"));
|
||||||
Util.ValidateHTTPStatusCode(EventLogResponse, 200);
|
Util.ValidateHTTPStatusCode(EventLogResponse, 200);
|
||||||
|
|
||||||
//NOTE:was failing here, for no reason that makes any sense it thinks there are two created events by two users for the same widget.
|
((JArray)EventLogResponse.ObjectResponse["data"]["events"]).Count.Should().Be(1);//only one event so far
|
||||||
//might have been some temporary bad code in the seeder at one point when I was experimenting with async stuff
|
EventLogResponse.ObjectResponse["data"]["events"][0]["date"].Value<DateTime>().Should().BeLessThan(new TimeSpan(1, 0, 0)).Before(DateTime.UtcNow);//should be less than one hour before now
|
||||||
|
EventLogResponse.ObjectResponse["data"]["events"][0]["userId"].Should().NotBeNull();
|
||||||
|
EventLogResponse.ObjectResponse["data"]["events"][0]["event"].Value<int>().Should().Be(1);//AyEvent 1 = created
|
||||||
((JArray)EventLogResponse.ObjectResponse["data"]).Count.Should().Be(1);//only one event so far
|
EventLogResponse.ObjectResponse["data"]["events"][0]["textra"].Should().BeNullOrEmpty();
|
||||||
EventLogResponse.ObjectResponse["data"][0]["date"].Value<DateTime>().Should().BeLessThan(new TimeSpan(1, 0, 0)).Before(DateTime.UtcNow);//should be less than one hour before now
|
|
||||||
EventLogResponse.ObjectResponse["data"][0]["userId"].Should().NotBeNull();
|
|
||||||
EventLogResponse.ObjectResponse["data"][0]["event"].Value<int>().Should().Be(1);//AyEvent 1 = created
|
|
||||||
EventLogResponse.ObjectResponse["data"][0]["textra"].Should().BeNullOrEmpty();
|
|
||||||
|
|
||||||
//Get current user doing modifications ID
|
//Get current user doing modifications ID
|
||||||
long CurrentUserId = EventLogResponse.ObjectResponse["data"][0]["userId"].Value<long>();
|
long CurrentUserId = EventLogResponse.ObjectResponse["data"]["events"][0]["userId"].Value<long>();
|
||||||
|
|
||||||
//RETRIEVE
|
|
||||||
|
|
||||||
|
//*** RETRIEVED
|
||||||
//Get one
|
//Get one
|
||||||
ApiResponse r3 = await Util.GetAsync("Widget/" + w2Id.ToString(), await Util.GetTokenAsync("InventoryFull"));
|
ApiResponse r3 = await Util.GetAsync("Widget/" + w2Id.ToString(), await Util.GetTokenAsync("InventoryFull"));
|
||||||
Util.ValidateDataReturnResponseOk(r3);
|
Util.ValidateDataReturnResponseOk(r3);
|
||||||
@@ -62,17 +58,16 @@ namespace raven_integration
|
|||||||
|
|
||||||
EventLogResponse = await Util.GetAsync($"EventLog/ObjectLog?AyType=2&AyId={w2Id}", await Util.GetTokenAsync("BizAdminFull"));
|
EventLogResponse = await Util.GetAsync($"EventLog/ObjectLog?AyType=2&AyId={w2Id}", await Util.GetTokenAsync("BizAdminFull"));
|
||||||
Util.ValidateHTTPStatusCode(EventLogResponse, 200);
|
Util.ValidateHTTPStatusCode(EventLogResponse, 200);
|
||||||
((JArray)EventLogResponse.ObjectResponse["data"]).Count.Should().Be(2);
|
//confirm event count, type and sort order (descending by date most recent first)
|
||||||
EventLogResponse.ObjectResponse["data"][1]["date"].Value<DateTime>().Should().BeLessThan(new TimeSpan(1, 0, 0)).Before(DateTime.UtcNow);//should be less than one hour before now
|
((JArray)EventLogResponse.ObjectResponse["data"]["events"]).Count.Should().Be(2);
|
||||||
EventLogResponse.ObjectResponse["data"][1]["userId"].Should().NotBeNull();
|
EventLogResponse.ObjectResponse["data"]["events"][0]["date"].Value<DateTime>().Should().BeLessThan(new TimeSpan(1, 0, 0)).Before(DateTime.UtcNow);//should be less than one hour before now
|
||||||
EventLogResponse.ObjectResponse["data"][1]["event"].Value<int>().Should().Be(2);//AyEvent 2 = retrieved
|
EventLogResponse.ObjectResponse["data"]["events"][0]["userId"].Should().NotBeNull();
|
||||||
EventLogResponse.ObjectResponse["data"][1]["textra"].Should().BeNullOrEmpty();
|
EventLogResponse.ObjectResponse["data"]["events"][0]["event"].Value<int>().Should().Be(2);//AyEvent 2 = retrieved
|
||||||
|
EventLogResponse.ObjectResponse["data"]["events"][0]["textra"].Should().BeNullOrEmpty();
|
||||||
|
|
||||||
|
|
||||||
|
//*** MODIFIED
|
||||||
//UPDATE
|
|
||||||
//PUT
|
//PUT
|
||||||
|
|
||||||
//update w2id
|
//update w2id
|
||||||
w.name = Util.Uniquify("UPDATED VIA PUT EVENTLOG TEST WIDGET");
|
w.name = Util.Uniquify("UPDATED VIA PUT EVENTLOG TEST WIDGET");
|
||||||
w.UserId = 1;
|
w.UserId = 1;
|
||||||
@@ -80,6 +75,7 @@ namespace raven_integration
|
|||||||
ApiResponse PUTTestResponse = await Util.PutAsync("Widget/" + w2Id.ToString(), await Util.GetTokenAsync("InventoryFull"), w.ToString());
|
ApiResponse PUTTestResponse = await Util.PutAsync("Widget/" + w2Id.ToString(), await Util.GetTokenAsync("InventoryFull"), w.ToString());
|
||||||
Util.ValidateHTTPStatusCode(PUTTestResponse, 200);
|
Util.ValidateHTTPStatusCode(PUTTestResponse, 200);
|
||||||
|
|
||||||
|
//*** RETRIEVED
|
||||||
//check PUT worked
|
//check PUT worked
|
||||||
ApiResponse checkPUTWorked = await Util.GetAsync("Widget/" + w2Id.ToString(), await Util.GetTokenAsync("InventoryFull"));
|
ApiResponse checkPUTWorked = await Util.GetAsync("Widget/" + w2Id.ToString(), await Util.GetTokenAsync("InventoryFull"));
|
||||||
Util.ValidateNoErrorInResponse(checkPUTWorked);
|
Util.ValidateNoErrorInResponse(checkPUTWorked);
|
||||||
@@ -88,17 +84,18 @@ namespace raven_integration
|
|||||||
|
|
||||||
EventLogResponse = await Util.GetAsync($"EventLog/ObjectLog?AyType=2&AyId={w2Id}", await Util.GetTokenAsync("BizAdminFull"));
|
EventLogResponse = await Util.GetAsync($"EventLog/ObjectLog?AyType=2&AyId={w2Id}", await Util.GetTokenAsync("BizAdminFull"));
|
||||||
Util.ValidateHTTPStatusCode(EventLogResponse, 200);
|
Util.ValidateHTTPStatusCode(EventLogResponse, 200);
|
||||||
((JArray)EventLogResponse.ObjectResponse["data"]).Count.Should().Be(4);
|
((JArray)EventLogResponse.ObjectResponse["data"]["events"]).Count.Should().Be(4);
|
||||||
EventLogResponse.ObjectResponse["data"][2]["date"].Value<DateTime>().Should().BeLessThan(new TimeSpan(1, 0, 0)).Before(DateTime.UtcNow);//should be less than one hour before now
|
//put op is the second item in the list, top item is the recent fetch
|
||||||
EventLogResponse.ObjectResponse["data"][2]["userId"].Should().NotBeNull();
|
EventLogResponse.ObjectResponse["data"]["events"][1]["date"].Value<DateTime>().Should().BeLessThan(new TimeSpan(1, 0, 0)).Before(DateTime.UtcNow);//should be less than one hour before now
|
||||||
EventLogResponse.ObjectResponse["data"][2]["event"].Value<int>().Should().Be(3);//AyEvent 3 = Modified
|
EventLogResponse.ObjectResponse["data"]["events"][1]["userId"].Should().NotBeNull();
|
||||||
EventLogResponse.ObjectResponse["data"][2]["textra"].Should().BeNullOrEmpty();
|
EventLogResponse.ObjectResponse["data"]["events"][1]["event"].Value<int>().Should().Be(3);//AyEvent 3 = Modified
|
||||||
|
EventLogResponse.ObjectResponse["data"]["events"][1]["textra"].Should().BeNullOrEmpty();
|
||||||
|
|
||||||
|
|
||||||
//Check user log for basic accessibility
|
//Check user log for basic accessibility UserLog?UserId=7
|
||||||
EventLogResponse = await Util.GetAsync($"EventLog/UserLog?AyType=3&AyId={CurrentUserId}", await Util.GetTokenAsync("BizAdminFull"));
|
EventLogResponse = await Util.GetAsync($"EventLog/UserLog?UserId={CurrentUserId}", await Util.GetTokenAsync("BizAdminFull"));
|
||||||
Util.ValidateHTTPStatusCode(EventLogResponse, 200);
|
Util.ValidateHTTPStatusCode(EventLogResponse, 200);
|
||||||
((JArray)EventLogResponse.ObjectResponse["data"]).Count.Should().BeGreaterOrEqualTo(4);//just one run of the above will be 4 events plus any others from other tests
|
((JArray)EventLogResponse.ObjectResponse["data"]["events"]).Count.Should().BeGreaterOrEqualTo(4);//just one run of the above will be 4 events plus any others from other tests
|
||||||
//Not sure of any easy way to assert the User log is correct other than the count as other tests running concurrently could easily skew this
|
//Not sure of any easy way to assert the User log is correct other than the count as other tests running concurrently could easily skew this
|
||||||
|
|
||||||
|
|
||||||
@@ -109,11 +106,102 @@ namespace raven_integration
|
|||||||
//All events should be cleared up on deletion with the sole exception of the deleted event
|
//All events should be cleared up on deletion with the sole exception of the deleted event
|
||||||
EventLogResponse = await Util.GetAsync($"EventLog/ObjectLog?AyType=2&AyId={w2Id}", await Util.GetTokenAsync("BizAdminFull"));
|
EventLogResponse = await Util.GetAsync($"EventLog/ObjectLog?AyType=2&AyId={w2Id}", await Util.GetTokenAsync("BizAdminFull"));
|
||||||
Util.ValidateHTTPStatusCode(EventLogResponse, 200);
|
Util.ValidateHTTPStatusCode(EventLogResponse, 200);
|
||||||
((JArray)EventLogResponse.ObjectResponse["data"]).Count.Should().Be(1);
|
((JArray)EventLogResponse.ObjectResponse["data"]["events"]).Count.Should().Be(1);
|
||||||
EventLogResponse.ObjectResponse["data"][0]["date"].Value<DateTime>().Should().BeLessThan(new TimeSpan(1, 0, 0)).Before(DateTime.UtcNow);//should be less than one hour before now
|
EventLogResponse.ObjectResponse["data"]["events"][0]["date"].Value<DateTime>().Should().BeLessThan(new TimeSpan(1, 0, 0)).Before(DateTime.UtcNow);//should be less than one hour before now
|
||||||
EventLogResponse.ObjectResponse["data"][0]["userId"].Should().NotBeNull();
|
EventLogResponse.ObjectResponse["data"]["events"][0]["userId"].Should().NotBeNull();
|
||||||
EventLogResponse.ObjectResponse["data"][0]["event"].Value<int>().Should().Be(0);//AyEvent 0 = deleted
|
EventLogResponse.ObjectResponse["data"]["events"][0]["event"].Value<int>().Should().Be(0);//AyEvent 0 = deleted
|
||||||
EventLogResponse.ObjectResponse["data"][0]["textra"].Value<string>().Should().Be(w.name.ToString());
|
EventLogResponse.ObjectResponse["data"]["events"][0]["textra"].Value<string>().Should().Be(w.name.ToString());
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
[Fact]
|
||||||
|
public async void EventLogLimitOffSetWorks()
|
||||||
|
{
|
||||||
|
|
||||||
|
//CREATE
|
||||||
|
dynamic d = new JObject();
|
||||||
|
d.name = Util.Uniquify("EventLogLimitOffSetWorks");
|
||||||
|
|
||||||
|
d.active = true;
|
||||||
|
d.login = "EventLogLimitOffSetWorks";
|
||||||
|
d.password = "EventLogLimitOffSetWorks";
|
||||||
|
d.roles = 2;//bizadminfull needs widget rights
|
||||||
|
d.userType = 3;//non scheduleable
|
||||||
|
|
||||||
|
//Required by form custom rules
|
||||||
|
d.notes = "notes";
|
||||||
|
d.customFields = Util.UserRequiredCustomFieldsJsonString();
|
||||||
|
|
||||||
|
ApiResponse a = await Util.PostAsync("User", await Util.GetTokenAsync("manager", "l3tm3in"), d.ToString());
|
||||||
|
Util.ValidateDataReturnResponseOk(a);
|
||||||
|
long UserId = a.ObjectResponse["data"]["id"].Value<long>();
|
||||||
|
|
||||||
|
|
||||||
|
//Loop and make 10 widgets
|
||||||
|
for (int i = 0; i < 10; i++)
|
||||||
|
{
|
||||||
|
d = new JObject();
|
||||||
|
d.name = Util.Uniquify("EventLogLimitOffSetWorks");
|
||||||
|
d.customFields = Util.WidgetRequiredCustomFieldsJsonString();
|
||||||
|
d.dollarAmount = 1.11m;
|
||||||
|
d.active = true;
|
||||||
|
d.usertype = 1;
|
||||||
|
d.notes = "note here";
|
||||||
|
a = await Util.PostAsync("Widget", await Util.GetTokenAsync("EventLogLimitOffSetWorks", "EventLogLimitOffSetWorks"), d.ToString());
|
||||||
|
Util.ValidateDataReturnResponseOk(a);
|
||||||
|
}
|
||||||
|
|
||||||
|
a = await Util.GetAsync($"EventLog/UserLog?UserId={UserId}&Offset=0&Limit=9", await Util.GetTokenAsync("BizAdminFull"));
|
||||||
|
((JArray)a.ObjectResponse["data"]["events"]).Count.Should().Be(9);
|
||||||
|
//capture events, then compare to paged ones
|
||||||
|
var eventList = ((JArray)a.ObjectResponse["data"]["events"]);
|
||||||
|
List<string> allEvents = new List<string>(9);
|
||||||
|
foreach (JObject o in eventList)
|
||||||
|
{
|
||||||
|
allEvents.Add(o["date"].Value<string>() + o["objectType"].Value<string>()
|
||||||
|
+ o["objectId"].Value<string>() + o["name"].Value<string>() + o["event"].Value<string>()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
a = await Util.GetAsync($"EventLog/UserLog?UserId={UserId}&Offset=0&Limit=3", await Util.GetTokenAsync("BizAdminFull"));
|
||||||
|
((JArray)a.ObjectResponse["data"]["events"]).Count.Should().Be(3);
|
||||||
|
var pageEventList = ((JArray)a.ObjectResponse["data"]["events"]);
|
||||||
|
foreach (JObject o in pageEventList)
|
||||||
|
{
|
||||||
|
allEvents.Should().Contain(o["date"].Value<string>() + o["objectType"].Value<string>()
|
||||||
|
+ o["objectId"].Value<string>() + o["name"].Value<string>() + o["event"].Value<string>()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
a = await Util.GetAsync($"EventLog/UserLog?UserId={UserId}&Offset=1&Limit=3", await Util.GetTokenAsync("BizAdminFull"));
|
||||||
|
((JArray)a.ObjectResponse["data"]["events"]).Count.Should().Be(3);
|
||||||
|
pageEventList = ((JArray)a.ObjectResponse["data"]["events"]);
|
||||||
|
foreach (JObject o in pageEventList)
|
||||||
|
{
|
||||||
|
allEvents.Should().Contain(o["date"].Value<string>() + o["objectType"].Value<string>()
|
||||||
|
+ o["objectId"].Value<string>() + o["name"].Value<string>() + o["event"].Value<string>()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
a = await Util.GetAsync($"EventLog/UserLog?UserId={UserId}&Offset=2&Limit=3", await Util.GetTokenAsync("BizAdminFull"));
|
||||||
|
((JArray)a.ObjectResponse["data"]["events"]).Count.Should().Be(3);
|
||||||
|
pageEventList = ((JArray)a.ObjectResponse["data"]["events"]);
|
||||||
|
foreach (JObject o in pageEventList)
|
||||||
|
{
|
||||||
|
allEvents.Should().Contain(o["date"].Value<string>() + o["objectType"].Value<string>()
|
||||||
|
+ o["objectId"].Value<string>() + o["name"].Value<string>() + o["event"].Value<string>()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user