This commit is contained in:
@@ -19,22 +19,23 @@ namespace raven_integration
|
||||
{
|
||||
//CREATE
|
||||
dynamic d = new JObject();
|
||||
d.name = Util.Uniquify("Test DataListFilter");
|
||||
d.name = Util.Uniquify("Test DataListView");
|
||||
|
||||
d["public"] = true;
|
||||
d.listKey="TestWidgetDataList";
|
||||
|
||||
//"[{fld:"name",op:"!=",value:"Notequaltothis"},{fld:"tags",op:"Eq",value:"[23,456,54]"}]
|
||||
dynamic dfilter = new JArray();
|
||||
dynamic df = new JObject();
|
||||
df.fld = "widgetname";
|
||||
df.op = "%-";
|
||||
df.value = "Generic";//lots of seed widgets start with Generic
|
||||
dfilter.Add(df);
|
||||
dynamic dListView = new JArray();
|
||||
// dynamic df = new JObject();
|
||||
// df.fld = "widgetname";
|
||||
// df.op = "%-";
|
||||
// df.value = "Generic";//lots of seed widgets start with Generic
|
||||
// dListView.Add(df);
|
||||
// d.filter = dListView.ToString();//it expects it to be a json string, not actual json
|
||||
dListView.Add(Util.BuildSimpleFilterDataListViewColumn("widgetname", Util.OpStartsWith, "Generic"));
|
||||
d.listView=dListView.ToString(Newtonsoft.Json.Formatting.None);
|
||||
|
||||
d.filter = dfilter.ToString();//it expects it to be a json string, not actual json
|
||||
|
||||
ApiResponse a = await Util.PostAsync("DataListSortFilter", await Util.GetTokenAsync("BizAdminFull"), d.ToString());
|
||||
ApiResponse a = await Util.PostAsync("DataListView", await Util.GetTokenAsync("BizAdminFull"), d.ToString(Newtonsoft.Json.Formatting.None));
|
||||
Util.ValidateDataReturnResponseOk(a);
|
||||
|
||||
long Id = a.ObjectResponse["data"]["id"].Value<long>();
|
||||
@@ -42,38 +43,38 @@ namespace raven_integration
|
||||
|
||||
//RETRIEVE
|
||||
//Get one
|
||||
a = await Util.GetAsync("DataListSortFilter/" + Id.ToString(), await Util.GetTokenAsync("BizAdminFull"));
|
||||
a = await Util.GetAsync("DataListView/" + Id.ToString(), await Util.GetTokenAsync("BizAdminFull"));
|
||||
Util.ValidateDataReturnResponseOk(a);
|
||||
a.ObjectResponse["data"]["name"].Value<string>().Should().StartWith("Test DataListFilter");
|
||||
a.ObjectResponse["data"]["name"].Value<string>().Should().StartWith("Test DataListView");
|
||||
|
||||
//Get as alternate user should work for public filter
|
||||
a = await Util.GetAsync("DataListSortFilter/" + Id.ToString(), await Util.GetTokenAsync("SubContractorLimited"));
|
||||
a = await Util.GetAsync("DataListView/" + Id.ToString(), await Util.GetTokenAsync("SubContractorLimited"));
|
||||
Util.ValidateDataReturnResponseOk(a);
|
||||
a.ObjectResponse["data"]["name"].Value<string>().Should().StartWith("Test DataListFilter");
|
||||
a.ObjectResponse["data"]["name"].Value<string>().Should().StartWith("Test DataListView");
|
||||
|
||||
|
||||
//UPDATE
|
||||
|
||||
//PUT, make private
|
||||
d["public"] = false;
|
||||
d.name = Util.Uniquify("Put - Test DataListFilter (privatized)");
|
||||
d.name = Util.Uniquify("Put - Test DataListView (privatized)");
|
||||
d.concurrencyToken = a.ObjectResponse["data"]["concurrencyToken"].Value<uint>();
|
||||
a = await Util.PutAsync("DataListSortFilter/" + Id.ToString(), await Util.GetTokenAsync("BizAdminFull"), d.ToString());
|
||||
a = await Util.PutAsync("DataListView/" + Id.ToString(), await Util.GetTokenAsync("BizAdminFull"), d.ToString());
|
||||
Util.ValidateHTTPStatusCode(a, 200);
|
||||
|
||||
//check PUT worked
|
||||
a = await Util.GetAsync("DataListSortFilter/" + Id.ToString(), await Util.GetTokenAsync("BizAdminFull"));
|
||||
a = await Util.GetAsync("DataListView/" + Id.ToString(), await Util.GetTokenAsync("BizAdminFull"));
|
||||
Util.ValidateNoErrorInResponse(a);
|
||||
a.ObjectResponse["data"]["name"].Value<string>().Should().Be(d.name.ToString());
|
||||
|
||||
|
||||
//FETCH DISALLOWED
|
||||
//Get as alternate user should fail for private filter
|
||||
a = await Util.GetAsync("DataListSortFilter/" + Id.ToString(), await Util.GetTokenAsync("SubContractorLimited"));
|
||||
a = await Util.GetAsync("DataListView/" + Id.ToString(), await Util.GetTokenAsync("SubContractorLimited"));
|
||||
Util.ValidateResponseNotFound(a);
|
||||
|
||||
// //DELETE
|
||||
ApiResponse DELETETestResponse = await Util.DeleteAsync("DataListSortFilter/" + Id.ToString(), await Util.GetTokenAsync("BizAdminFull"));
|
||||
ApiResponse DELETETestResponse = await Util.DeleteAsync("DataListView/" + Id.ToString(), await Util.GetTokenAsync("BizAdminFull"));
|
||||
Util.ValidateHTTPStatusCode(DELETETestResponse, 204);
|
||||
|
||||
}
|
||||
@@ -86,7 +87,7 @@ namespace raven_integration
|
||||
{
|
||||
//CREATE
|
||||
dynamic d = new JObject();
|
||||
d.name = Util.Uniquify("Test DataListFilter");
|
||||
d.name = Util.Uniquify("Test DataListView");
|
||||
|
||||
d["public"] = true;
|
||||
d.listKey = "nonexistant";
|
||||
@@ -101,7 +102,7 @@ namespace raven_integration
|
||||
|
||||
d.filter = dfilter.ToString();//it expects it to be a json string, not actual json
|
||||
|
||||
ApiResponse a = await Util.PostAsync("DataListSortFilter", await Util.GetTokenAsync("BizAdminFull"), d.ToString());
|
||||
ApiResponse a = await Util.PostAsync("DataListView", await Util.GetTokenAsync("BizAdminFull"), d.ToString());
|
||||
Util.ValidateErrorCodeResponse(a, 2200, 400);
|
||||
Util.ShouldContainValidationError(a, "ListKey", "2203");
|
||||
|
||||
@@ -116,7 +117,7 @@ namespace raven_integration
|
||||
{
|
||||
//CREATE
|
||||
dynamic d = new JObject();
|
||||
d.name = Util.Uniquify("Test DataListFilter");
|
||||
d.name = Util.Uniquify("Test DataListView");
|
||||
|
||||
d["public"] = true;
|
||||
d.listKey="TestWidgetDataList";
|
||||
@@ -131,7 +132,7 @@ namespace raven_integration
|
||||
|
||||
d.filter = dfilter.ToString();//it expects it to be a json string, not actual json
|
||||
|
||||
ApiResponse a = await Util.PostAsync("DataListSortFilter", await Util.GetTokenAsync("BizAdminFull"), d.ToString());
|
||||
ApiResponse a = await Util.PostAsync("DataListView", await Util.GetTokenAsync("BizAdminFull"), d.ToString());
|
||||
Util.ValidateErrorCodeResponse(a, 2200, 400);
|
||||
Util.ShouldContainValidationError(a, "Filter", "2203");
|
||||
|
||||
@@ -139,34 +140,36 @@ namespace raven_integration
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public async void InvalidOperatorShouldFail()
|
||||
{
|
||||
//CREATE
|
||||
dynamic d = new JObject();
|
||||
d.name = Util.Uniquify("Test DataListFilter");
|
||||
//REMOVED THIS VALIDATION TEST AS SWITCH TO DATALISTVIEW NO LONGER VALIDATES FILTER ANYWAY
|
||||
//ONLY COLUMN NAMES AND LIST NAME
|
||||
// /// <summary>
|
||||
// ///
|
||||
// /// </summary>
|
||||
// [Fact]
|
||||
// public async void InvalidOperatorShouldFail()
|
||||
// {
|
||||
// //CREATE
|
||||
// dynamic d = new JObject();
|
||||
// d.name = Util.Uniquify("Test DataListView");
|
||||
|
||||
d["public"] = true;
|
||||
d.listKey="TestWidgetDataList";
|
||||
// d["public"] = true;
|
||||
// d.listKey="TestWidgetDataList";
|
||||
|
||||
//"[{fld:"name",op:"!=",value:"Notequaltothis"},{fld:"tags",op:"Eq",value:"[23,456,54]"}]
|
||||
dynamic dfilter = new JArray();
|
||||
dynamic df = new JObject();
|
||||
df.fld = "name";
|
||||
df.op = "wtf";
|
||||
df.value = "Generic";//lots of seed widgets start with Generic
|
||||
dfilter.Add(df);
|
||||
// //"[{fld:"name",op:"!=",value:"Notequaltothis"},{fld:"tags",op:"Eq",value:"[23,456,54]"}]
|
||||
// dynamic dfilter = new JArray();
|
||||
// dynamic df = new JObject();
|
||||
// df.fld = "name";
|
||||
// df.op = "wtf";
|
||||
// df.value = "Generic";//lots of seed widgets start with Generic
|
||||
// dfilter.Add(df);
|
||||
|
||||
d.filter = dfilter.ToString();//it expects it to be a json string, not actual json
|
||||
// d.filter = dfilter.ToString();//it expects it to be a json string, not actual json
|
||||
|
||||
ApiResponse a = await Util.PostAsync("DataListSortFilter", await Util.GetTokenAsync("BizAdminFull"), d.ToString());
|
||||
Util.ValidateErrorCodeResponse(a, 2200, 400);
|
||||
Util.ShouldContainValidationError(a, "Filter", "2203");
|
||||
// ApiResponse a = await Util.PostAsync("DataListView", await Util.GetTokenAsync("BizAdminFull"), d.ToString());
|
||||
// Util.ValidateErrorCodeResponse(a, 2200, 400);
|
||||
// Util.ShouldContainValidationError(a, "Filter", "2203");
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user