This commit is contained in:
2018-11-30 20:58:46 +00:00
parent 06c4b76c17
commit 460d50109f
4 changed files with 110 additions and 52 deletions

View File

@@ -78,10 +78,96 @@ namespace raven_integration
}
//TEST: invalid options test for failure
//- invalid list key
//- invalid field name
//- invalid operator
/// <summary>
///
/// </summary>
[Fact]
public async void InvalidListKeyShouldFail()
{
//CREATE
dynamic d = new JObject();
d.name = Util.Uniquify("Test DataFilter");
// d.ownerId = 1L;
d["public"] = true;
d.listKey = "nonexistant";
//"[{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 = "%-";
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
ApiResponse a = await Util.PostAsync("DataFilter", await Util.GetTokenAsync("BizAdminFull"), d.ToString());
Util.ValidateErrorCodeResponse(a, 2200, 400);
Util.ShouldContainValidationError(a, "ListKey", "InvalidValue");
}
/// <summary>
///
/// </summary>
[Fact]
public async void InvalidFieldNameShouldFail()
{
//CREATE
dynamic d = new JObject();
d.name = Util.Uniquify("Test DataFilter");
// d.ownerId = 1L;
d["public"] = true;
d.listKey = "widget";
//"[{fld:"name",op:"!=",value:"Notequaltothis"},{fld:"tags",op:"Eq",value:"[23,456,54]"}]
dynamic dfilter = new JArray();
dynamic df = new JObject();
df.fld = "doesntexist";
df.op = "%-";
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
ApiResponse a = await Util.PostAsync("DataFilter", await Util.GetTokenAsync("BizAdminFull"), d.ToString());
Util.ValidateErrorCodeResponse(a, 2200, 400);
Util.ShouldContainValidationError(a, "Filter", "InvalidValue");
}
/// <summary>
///
/// </summary>
[Fact]
public async void InvalidOperatorShouldFail()
{
//CREATE
dynamic d = new JObject();
d.name = Util.Uniquify("Test DataFilter");
// d.ownerId = 1L;
d["public"] = true;
d.listKey = "widget";
//"[{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
ApiResponse a = await Util.PostAsync("DataFilter", await Util.GetTokenAsync("BizAdminFull"), d.ToString());
Util.ValidateErrorCodeResponse(a, 2200, 400);
Util.ShouldContainValidationError(a, "Filter", "InvalidValue");
}
//==================================================