4648
This commit is contained in:
@@ -1,9 +1,6 @@
|
||||
using System;
|
||||
using Xunit;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using FluentAssertions;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Concurrent;
|
||||
|
||||
namespace raven_integration
|
||||
{
|
||||
@@ -40,12 +37,12 @@ namespace raven_integration
|
||||
*/
|
||||
|
||||
dynamic d = new JObject();
|
||||
d.formkey = "User";
|
||||
d.formkey = "Vendor";
|
||||
|
||||
dynamic dtemplate = new JArray();
|
||||
|
||||
dynamic dt = new JObject();
|
||||
dt.fld = "UserCustom1";
|
||||
dt.fld = "VendorCustom1";
|
||||
dt.hide = false;
|
||||
dt.required = true;
|
||||
dt.type = AyaUiFieldDataType.Text;
|
||||
@@ -58,7 +55,7 @@ namespace raven_integration
|
||||
dtemplate.Add(dt);
|
||||
|
||||
dt = new JObject();
|
||||
dt.fld = "UserCustom2";
|
||||
dt.fld = "VendorCustom2";
|
||||
dt.hide = true;
|
||||
dt.required = false;
|
||||
dt.type = AyaUiFieldDataType.Bool;
|
||||
@@ -69,23 +66,23 @@ namespace raven_integration
|
||||
|
||||
//RETRIEVE
|
||||
//Get the current one (server will create if non-existent)
|
||||
ApiResponse a = await Util.GetAsync("form-custom/User", await Util.GetTokenAsync("BizAdmin"));
|
||||
ApiResponse a = await Util.GetAsync("form-custom/Vendor", await Util.GetTokenAsync("BizAdmin"));
|
||||
|
||||
//Update
|
||||
d.concurrency = a.ObjectResponse["data"]["concurrency"].Value<uint>();
|
||||
a = await Util.PutAsync("form-custom/User", await Util.GetTokenAsync("BizAdmin"), d.ToString());
|
||||
a = await Util.PutAsync("form-custom/Vendor", await Util.GetTokenAsync("BizAdmin"), d.ToString());
|
||||
Util.ValidateHTTPStatusCode(a, 200);
|
||||
|
||||
//check the concurrency token cache scheme
|
||||
uint token = a.ObjectResponse["data"]["concurrency"].Value<uint>();
|
||||
//This should return a 304 not modified
|
||||
a = await Util.GetAsync($"form-custom/User?concurrency={token}", await Util.GetTokenAsync("BizAdmin"));
|
||||
a = await Util.GetAsync($"form-custom/Vendor?concurrency={token}", await Util.GetTokenAsync("BizAdmin"));
|
||||
Util.ValidateHTTPStatusCode(a, 304);
|
||||
|
||||
//and this should return the whole object
|
||||
token--;//make the token not match
|
||||
//This should return a 200 and the whole object
|
||||
a = await Util.GetAsync($"form-custom/User?concurrency={token}", await Util.GetTokenAsync("BizAdmin"));
|
||||
a = await Util.GetAsync($"form-custom/Vendor?concurrency={token}", await Util.GetTokenAsync("BizAdmin"));
|
||||
Util.ValidateDataReturnResponseOk(a);
|
||||
}
|
||||
|
||||
@@ -100,7 +97,7 @@ namespace raven_integration
|
||||
{
|
||||
|
||||
dynamic d = new JObject();
|
||||
d.formkey = "User";
|
||||
d.formkey = "Vendor";
|
||||
|
||||
dynamic dtemplate = new JArray();
|
||||
|
||||
@@ -123,20 +120,20 @@ namespace raven_integration
|
||||
dtemplate.Add(dt);
|
||||
|
||||
dt = new JObject();
|
||||
dt.fld = "UserCustom1";//expected ApiErrorCode.VALIDATION_INVALID_VALUE type missing for custom field
|
||||
dt.fld = "VendorCustom1";//expected ApiErrorCode.VALIDATION_INVALID_VALUE type missing for custom field
|
||||
dt.hide = false;
|
||||
dt.required = false;
|
||||
dtemplate.Add(dt);
|
||||
|
||||
dt = new JObject();
|
||||
dt.fld = "EmployeeNumber";//expect ApiErrorCode.VALIDATION_INVALID_VALUE not custom field but type specified anyway
|
||||
dt.fld = "AccountNumber";//expect ApiErrorCode.VALIDATION_INVALID_VALUE not custom field but type specified anyway
|
||||
dt.hide = true;
|
||||
dt.required = false;
|
||||
dt.type = AyaUiFieldDataType.EmailAddress;//type specified (doesn't matter what type)
|
||||
dtemplate.Add(dt);
|
||||
|
||||
dt = new JObject();
|
||||
dt.fld = "UserCustom2";//expected ApiErrorCode.VALIDATION_INVALID_VALUE type missing for custom field
|
||||
dt.fld = "VendorCustom2";//expected ApiErrorCode.VALIDATION_INVALID_VALUE type missing for custom field
|
||||
dt.hide = false;
|
||||
dt.required = false;
|
||||
dtemplate.Add(dt);
|
||||
@@ -153,32 +150,71 @@ namespace raven_integration
|
||||
|
||||
//RETRIEVE
|
||||
//Get the current one (server will create if non-existent)
|
||||
ApiResponse a = await Util.GetAsync("form-custom/User", await Util.GetTokenAsync("BizAdmin"));
|
||||
ApiResponse a = await Util.GetAsync("form-custom/Vendor", await Util.GetTokenAsync("BizAdmin"));
|
||||
|
||||
//Update
|
||||
d.concurrency = a.ObjectResponse["data"]["concurrency"].Value<uint>();
|
||||
a = await Util.PutAsync("form-custom/User", await Util.GetTokenAsync("BizAdmin"), d.ToString());
|
||||
a = await Util.PutAsync("form-custom/Vendor", await Util.GetTokenAsync("BizAdmin"), d.ToString());
|
||||
Util.ValidateHTTPStatusCode(a, 400);
|
||||
Util.ShouldContainValidationError(a, "Template", "2201", "Template array item 0, \"fld\" property exists but is empty, a value is required");
|
||||
Util.ShouldContainValidationError(a, "Template", "2203", "Template array item 0, fld property value \"\" is not a valid form field value for formKey specified");
|
||||
Util.ShouldContainValidationError(a, "Template", "2203", "Template array item 1, fld property value \"ThisFieldKeyDoesNotExist\" is not a valid form field value for formKey specified");
|
||||
Util.ShouldContainValidationError(a, "Template", "2203", "Template array item 2 (\"Name\"), \"hide\" property value of \"True\" is not valid, this field is core and cannot be hidden");
|
||||
Util.ShouldContainValidationError(a, "Template", "2203", "Template array item 3 (\"UserCustom1\"), \"type\" property value is MISSING for custom field, Custom fields MUST have types specified");
|
||||
Util.ShouldContainValidationError(a, "Template", "2203", "Template array item 4 (\"EmployeeNumber\"), \"type\" property value is not valid, only Custom fields can have types specified");
|
||||
Util.ShouldContainValidationError(a, "Template", "2203", "Template array item 5 (\"UserCustom2\"), \"type\" property value of \"999\" is not a valid custom field type");
|
||||
Util.ShouldContainValidationError(a, "Template", "2203", "Template array item 2, fld property value \"Name\" is not a valid form field value for formKey specified");
|
||||
Util.ShouldContainValidationError(a, "Template", "2203", "Template array item 3 (\"VendorCustom1\"), \"type\" property value is MISSING for custom field, Custom fields MUST have types specified");
|
||||
Util.ShouldContainValidationError(a, "Template", "2203", "Template array item 4 (\"AccountNumber\"), \"type\" property value is not valid, only Custom fields can have types specified");
|
||||
Util.ShouldContainValidationError(a, "Template", "2203", "Template array item 5 (\"VendorCustom2\"), \"type\" property value of \"999\" is not a valid custom field type");
|
||||
Util.ShouldContainValidationError(a, "Template", "2201", "Template array item 6, object is missing \"required\" property. All items must contain this property.");
|
||||
|
||||
/*
|
||||
"{\"error\":{\"code\":\"2200\",\"details\":[
|
||||
{\"message\":\"Template array item 0, \\\"fld\\\" property exists but is empty, a value is required\",\"target\":\"Template\",\"error\":\"2201\"},
|
||||
{\"message\":\"Template array item 0, fld property value \\\"\\\" is not a valid form field value for formKey specified\",\"target\":\"Template\",\"error\":\"2203\"},
|
||||
{\"message\":\"Template array item 1, fld property value \\\"ThisFieldKeyDoesNotExist\\\" is not a valid form field value for formKey specified\",\"target\":\"Template\",\"error\":\"2203\"},
|
||||
{\"message\":\"Template array item 2 (\\\"Name\\\"), \\\"hide\\\" property value of \\\"True\\\" is not valid, this field is core and cannot be hidden\",\"target\":\"Template\",\"error\":\"2203\"},
|
||||
{\"message\":\"Template array item 3 (\\\"UserCustom1\\\"), \\\"type\\\" property value is MISSING for custom filed, Custom fields MUST have types specified\",\"target\":\"Template\",\"error\":\"2203\"},
|
||||
{\"message\":\"Template array item 4 (\\\"EmployeeNumber\\\"), \\\"type\\\" property value is not valid, only Custom fields can have types specified\",\"target\":\"Template\",\"error\":\"2203\"},
|
||||
{\"message\":\"Template array item 5 (\\\"UserCustom2\\\"), \\\"type\\\" property value of \\\"999\\\" is not a valid custom field type\",\"target\":\"Template\",\"error\":\"2203\"},
|
||||
{\"message\":\"Template array item 6, object is missing \\\"required\\\" property. All items must contain this property. \",\"target\":\"Template\",\"error\":\"2201\"}
|
||||
],\"message\":\"Object did not pass validation\"}}"
|
||||
|
||||
{{
|
||||
"error": {
|
||||
"code": "2200",
|
||||
"details": [
|
||||
{
|
||||
"message": "Template array item 0, \"fld\" property exists but is empty, a value is required",
|
||||
"target": "Template",
|
||||
"error": "2201"
|
||||
},
|
||||
{
|
||||
"message": "Template array item 0, fld property value \"\" is not a valid form field value for formKey specified",
|
||||
"target": "Template",
|
||||
"error": "2203"
|
||||
},
|
||||
{
|
||||
"message": "Template array item 1, fld property value \"ThisFieldKeyDoesNotExist\" is not a valid form field value for formKey specified",
|
||||
"target": "Template",
|
||||
"error": "2203"
|
||||
},
|
||||
{
|
||||
"message": "Template array item 2, fld property value \"Name\" is not a valid form field value for formKey specified",
|
||||
"target": "Template",
|
||||
"error": "2203"
|
||||
},
|
||||
{
|
||||
"message": "Template array item 3 (\"VendorCustom1\"), \"type\" property value is MISSING for custom field, Custom fields MUST have types specified",
|
||||
"target": "Template",
|
||||
"error": "2203"
|
||||
},
|
||||
{
|
||||
"message": "Template array item 4 (\"AccountNumber\"), \"type\" property value is not valid, only Custom fields can have types specified",
|
||||
"target": "Template",
|
||||
"error": "2203"
|
||||
},
|
||||
{
|
||||
"message": "Template array item 5 (\"VendorCustom2\"), \"type\" property value of \"999\" is not a valid custom field type",
|
||||
"target": "Template",
|
||||
"error": "2203"
|
||||
},
|
||||
{
|
||||
"message": "Template array item 6, object is missing \"required\" property. All items must contain this property. ",
|
||||
"target": "Template",
|
||||
"error": "2201"
|
||||
}
|
||||
],
|
||||
"message": "ErrorAPI2200"
|
||||
}
|
||||
}}
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -189,8 +225,8 @@ namespace raven_integration
|
||||
[Fact]
|
||||
public async Task InvalidObjectFieldsFormKeyShouldFail()
|
||||
{
|
||||
ApiResponse a = await Util.GetAsync("form-field-definition/nonexistent", await Util.GetTokenAsync("BizAdmin"));
|
||||
Util.ValidateErrorCodeResponse(a, 2010, 404);
|
||||
ApiResponse a = await Util.GetAsync("form-field-reference/nonexistent", await Util.GetTokenAsync("BizAdmin"));
|
||||
Util.ValidateHTTPStatusCode(a, 404);
|
||||
}
|
||||
|
||||
|
||||
@@ -200,7 +236,7 @@ namespace raven_integration
|
||||
[Fact]
|
||||
public async Task ObjectFieldsWorks()
|
||||
{
|
||||
ApiResponse a = await Util.GetAsync("form-field-definition/Widget", await Util.GetTokenAsync("BizAdmin"));
|
||||
ApiResponse a = await Util.GetAsync("form-field-reference/Vendor", await Util.GetTokenAsync("BizAdmin"));
|
||||
Util.ValidateDataReturnResponseOk(a);
|
||||
((JArray)a.ObjectResponse["data"]).Count.Should().BeGreaterThan(25);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user