From 077f8bf9f0c8df6d0a8f500f4528332fa5ad3843 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Tue, 2 Jul 2019 18:57:40 +0000 Subject: [PATCH] --- Locale/Locale.cs | 3 +++ User/UserCrud.cs | 61 ++++++++++++++++++++++++++++++++++++------- User/UserOptionsRu.cs | 3 +++ util.cs | 28 +++++++++++++++----- 4 files changed, 79 insertions(+), 16 deletions(-) diff --git a/Locale/Locale.cs b/Locale/Locale.cs index 3726a21..d14a2d5 100644 --- a/Locale/Locale.cs +++ b/Locale/Locale.cs @@ -147,6 +147,9 @@ namespace raven_integration DUSER.roles = 0;//norole (any role can get a subset of locale keys) DUSER.localeId = NewId;//random locale DUSER.userType = 3;//non scheduleable + //Required by form custom rules + DUSER.notes = "notes"; + DUSER.customFields = Util.UserRequiredCustomFieldsJsonString(); a = await Util.PostAsync("User", await Util.GetTokenAsync("manager", "l3tm3in"), DUSER.ToString()); Util.ValidateDataReturnResponseOk(a); long DUSERID = a.ObjectResponse["data"]["id"].Value(); diff --git a/User/UserCrud.cs b/User/UserCrud.cs index 930604d..faac688 100644 --- a/User/UserCrud.cs +++ b/User/UserCrud.cs @@ -19,7 +19,7 @@ namespace raven_integration //CREATE dynamic D1 = new JObject(); D1.name = Util.Uniquify("First Test User"); - + D1.active = true; D1.login = Util.Uniquify("LOGIN"); D1.password = Util.Uniquify("PASSWORD"); @@ -27,6 +27,10 @@ namespace raven_integration D1.localeId = 1;//random locale D1.userType = 3;//non scheduleable + //Required by form custom rules + D1.notes = "notes"; + D1.customFields = Util.UserRequiredCustomFieldsJsonString(); + ApiResponse R1 = await Util.PostAsync("User", await Util.GetTokenAsync("manager", "l3tm3in"), D1.ToString()); Util.ValidateDataReturnResponseOk(R1); long d1Id = R1.ObjectResponse["data"]["id"].Value(); @@ -34,7 +38,9 @@ namespace raven_integration dynamic D2 = new JObject(); D2.name = Util.Uniquify("Second Test User"); - + //Required by form custom rules + D2.notes = "notes"; + D2.customFields = Util.UserRequiredCustomFieldsJsonString(); D2.active = true; D2.login = Util.Uniquify("LOGIN"); D2.password = Util.Uniquify("PASSWORD"); @@ -60,7 +66,7 @@ namespace raven_integration //PUT //update w2id - D2.name = Util.Uniquify("UPDATED VIA PUT SECOND TEST User"); + D2.name = Util.Uniquify("UPDATED VIA PUT SECOND TEST User"); D2.concurrencyToken = R2.ObjectResponse["data"]["concurrencyToken"].Value(); ApiResponse PUTTestResponse = await Util.PutAsync("User/" + d2Id.ToString(), await Util.GetTokenAsync("manager", "l3tm3in"), D2.ToString()); Util.ValidateHTTPStatusCode(PUTTestResponse, 200); @@ -134,7 +140,8 @@ namespace raven_integration //CREATE dynamic D = new JObject(); D.name = Util.Uniquify("PutConcurrencyViolationShouldFail"); - + D.notes = "notes"; + D.customFields = Util.UserRequiredCustomFieldsJsonString(); D.active = true; D.login = Util.Uniquify("LOGIN"); D.password = Util.Uniquify("PASSWORD"); @@ -167,13 +174,17 @@ namespace raven_integration //CREATE dynamic D = new JObject(); D.name = Util.Uniquify("PatchConcurrencyViolationShouldFail"); - + 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 + //Required by form custom rules + D.notes = "notes"; + D.customFields = Util.UserRequiredCustomFieldsJsonString(); + ApiResponse R = await Util.PostAsync("User", await Util.GetTokenAsync("manager", "l3tm3in"), D.ToString()); Util.ValidateDataReturnResponseOk(R); @@ -199,7 +210,7 @@ namespace raven_integration //CREATE dynamic D = new JObject(); D.name = Util.Uniquify("DisallowedPatchAttemptsShouldFail"); - + D.active = true; D.login = Util.Uniquify("LOGIN"); D.password = Util.Uniquify("PASSWORD"); @@ -207,6 +218,10 @@ namespace raven_integration D.localeId = 1;//random locale D.userType = 3;//non scheduleable + //Required by form custom rules + D.notes = "notes"; + D.customFields = Util.UserRequiredCustomFieldsJsonString(); + ApiResponse R = await Util.PostAsync("User", await Util.GetTokenAsync("manager", "l3tm3in"), D.ToString()); Util.ValidateDataReturnResponseOk(R); long w2Id = R.ObjectResponse["data"]["id"].Value(); @@ -218,7 +233,7 @@ namespace raven_integration ApiResponse 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); @@ -240,13 +255,16 @@ namespace raven_integration //CREATE dynamic D = new JObject(); D.name = Util.Uniquify("PatchPasswordShouldWork"); - + 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 + //Required by form custom rules + D.notes = "notes"; + D.customFields = Util.UserRequiredCustomFieldsJsonString(); ApiResponse R = await Util.PostAsync("User", await Util.GetTokenAsync("manager", "l3tm3in"), D.ToString()); Util.ValidateDataReturnResponseOk(R); @@ -285,13 +303,16 @@ namespace raven_integration //CREATE dynamic D = new JObject(); D.name = Util.Uniquify("PutPasswordShouldWork"); - + 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 + //Required by form custom rules + D.notes = "notes"; + D.customFields = Util.UserRequiredCustomFieldsJsonString(); ApiResponse R = await Util.PostAsync("User", await Util.GetTokenAsync("manager", "l3tm3in"), D.ToString()); Util.ValidateDataReturnResponseOk(R); @@ -344,6 +365,9 @@ namespace raven_integration d.roles = 0;//norole d.localeId = 1;//random locale 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); @@ -357,6 +381,9 @@ namespace raven_integration d.localeId = 1;//random locale d.userType = 3;//non scheduleable d.active = true; + //Required by form custom rules + d.notes = "notes"; + d.customFields = Util.UserRequiredCustomFieldsJsonString(); a = await Util.PostAsync("User", await Util.GetTokenAsync("manager", "l3tm3in"), d.ToString()); Util.ValidateDataReturnResponseOk(a); @@ -370,6 +397,10 @@ namespace raven_integration d.localeId = 1;//random locale d.userType = 3;//non scheduleable d.active = false; + //Required by form custom rules + d.notes = "notes"; + d.customFields = Util.UserRequiredCustomFieldsJsonString(); + a = await Util.PostAsync("User", await Util.GetTokenAsync("manager", "l3tm3in"), d.ToString()); Util.ValidateDataReturnResponseOk(a); SecondInOrderId = a.ObjectResponse["data"]["id"].Value(); @@ -492,6 +523,10 @@ namespace raven_integration d.roles = 0;//norole d.localeId = 1;//random locale 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); @@ -505,6 +540,10 @@ namespace raven_integration d.roles = 0;//norole d.localeId = 1;//random locale d.userType = 2;//non scheduleable + //Required by form custom rules + d.notes = "notes"; + d.customFields = Util.UserRequiredCustomFieldsJsonString(); + a = await Util.PostAsync("User", await Util.GetTokenAsync("manager", "l3tm3in"), d.ToString()); Util.ValidateDataReturnResponseOk(a); SecondInOrderId = a.ObjectResponse["data"]["id"].Value(); @@ -517,6 +556,10 @@ namespace raven_integration d.roles = 0;//norole d.localeId = 1;//random locale d.userType = 1;//non scheduleable + //Required by form custom rules + d.notes = "notes"; + d.customFields = Util.UserRequiredCustomFieldsJsonString(); + a = await Util.PostAsync("User", await Util.GetTokenAsync("manager", "l3tm3in"), d.ToString()); Util.ValidateDataReturnResponseOk(a); FirstInOrderId = a.ObjectResponse["data"]["id"].Value(); diff --git a/User/UserOptionsRu.cs b/User/UserOptionsRu.cs index 647ad02..28d5f63 100644 --- a/User/UserOptionsRu.cs +++ b/User/UserOptionsRu.cs @@ -26,6 +26,9 @@ namespace raven_integration D1.roles = 0;//norole D1.localeId = 1;//random locale D1.userType = 3;//non scheduleable + //Required by form custom rules + D1.notes = "notes"; + D1.customFields = Util.UserRequiredCustomFieldsJsonString(); ApiResponse R = await Util.PostAsync("User", await Util.GetTokenAsync("manager", "l3tm3in"), D1.ToString()); Util.ValidateDataReturnResponseOk(R); diff --git a/util.cs b/util.cs index 7563901..46ba693 100644 --- a/util.cs +++ b/util.cs @@ -253,7 +253,7 @@ namespace raven_integration var ERR = a.ObjectResponse["error"]; if (ERR != null) { - ErrorMessage=a.ObjectResponse.ToString(); + ErrorMessage = a.ObjectResponse.ToString(); // var ecode = ERR["code"]; // if (ecode != null) // ErrorMessage += $"CODE: {ecode} "; @@ -427,15 +427,15 @@ namespace raven_integration dCustomField.c13 = c13; dCustomField.c14 = c14; dCustomField.c15 = c15; - dCustomField.c16 = c16; + dCustomField.c16 = c16; return dCustomField.ToString(); } - /// - /// Generate a custom fields string that satisfies the rules in the sample test data - /// - /// - public static string WidgetRequiredCustomFieldsJsonString() + /// + /// Generate a custom fields string that satisfies the rules in the sample test data + /// + /// + public static string WidgetRequiredCustomFieldsJsonString() {/*CURRENT TEMPLATE DEFINITION FOR WIDGET CUSTOM FIELDS, FROM SEEDER.CS SERVER PROJECT { ""template"": [ @@ -489,5 +489,19 @@ namespace raven_integration } + + + /// + /// Generate a custom fields string that satisfies the rules in this project (formCustom) + /// + /// + public static string UserRequiredCustomFieldsJsonString() + { + //Note c1 is only required custom, c2 is defined but is not required so skipping it here + dynamic dCustomField = new JObject(); + dCustomField.c1 = "UnitTestUtilSampleText"; + return dCustomField.ToString(); + } + }//eoc }//eons