diff --git a/User/UserCrud.cs b/User/UserCrud.cs index 74c8b74..4a63d51 100644 --- a/User/UserCrud.cs +++ b/User/UserCrud.cs @@ -24,7 +24,7 @@ namespace raven_integration D1.login = Util.Uniquify("LOGIN"); D1.password = Util.Uniquify("PASSWORD"); D1.roles = 0;//norole - + D1.userType = 3;//non scheduleable //Required by form custom rules @@ -45,7 +45,7 @@ namespace raven_integration D2.login = Util.Uniquify("LOGIN"); D2.password = Util.Uniquify("PASSWORD"); D2.roles = 0;//norole - + D2.userType = 3;//non scheduleable ApiResponse R2 = await Util.PostAsync("User", await Util.GetTokenAsync("manager", "l3tm3in"), D2.ToString()); @@ -146,7 +146,7 @@ namespace raven_integration D.login = Util.Uniquify("LOGIN"); D.password = Util.Uniquify("PASSWORD"); D.roles = 0;//norole - + D.userType = 3;//non scheduleable ApiResponse R = await Util.PostAsync("User", await Util.GetTokenAsync("manager", "l3tm3in"), D.ToString()); @@ -179,7 +179,7 @@ namespace raven_integration D.login = Util.Uniquify("LOGIN"); D.password = Util.Uniquify("PASSWORD"); D.roles = 0;//norole - + D.userType = 3;//non scheduleable //Required by form custom rules D.notes = "notes"; @@ -215,7 +215,7 @@ namespace raven_integration D.login = Util.Uniquify("LOGIN"); D.password = Util.Uniquify("PASSWORD"); D.roles = 0;//norole - + D.userType = 3;//non scheduleable //Required by form custom rules @@ -250,95 +250,55 @@ namespace raven_integration /// /// [Fact] - public async void PatchPasswordShouldWork() + public async void PutPasswordShouldWork() { //CREATE - dynamic D = new JObject(); - D.name = Util.Uniquify("PatchPasswordShouldWork"); + 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.userType = 3;//non scheduleable + d.active = true; + d.login = Util.Uniquify("LOGIN"); + d.password = Util.Uniquify("PASSWORD"); + d.roles = 0;//norole + + d.userType = 3;//non scheduleable //Required by form custom rules - D.notes = "notes"; - D.customFields = Util.UserRequiredCustomFieldsJsonString(); + d.notes = "notes"; + d.customFields = Util.UserRequiredCustomFieldsJsonString(); - ApiResponse R = await Util.PostAsync("User", await Util.GetTokenAsync("manager", "l3tm3in"), D.ToString()); - Util.ValidateDataReturnResponseOk(R); - long UserId = R.ObjectResponse["data"]["id"].Value(); - uint OriginalConcurrencyToken = R.ObjectResponse["data"]["concurrencyToken"].Value(); + ApiResponse a = await Util.PostAsync("User", await Util.GetTokenAsync("manager", "l3tm3in"), d.ToString()); + Util.ValidateDataReturnResponseOk(a); + long UserId = a.ObjectResponse["data"]["id"].Value(); + uint OriginalConcurrencyToken = a.ObjectResponse["data"]["concurrencyToken"].Value(); //Test can login dynamic DCreds = new JObject(); - DCreds.password = D.password; - DCreds.login = D.login; - R = await Util.PostAsync("Auth", null, DCreds.ToString()); - Util.ValidateDataReturnResponseOk(R); + DCreds.password = d.password; + DCreds.login = d.login; + a = await Util.PostAsync("Auth", null, DCreds.ToString()); + Util.ValidateDataReturnResponseOk(a); + + //GET user (login changed concurrency token above) + a = await Util.GetAsync("User/" + UserId.ToString(), await Util.GetTokenAsync("manager", "l3tm3in")); + Util.ValidateDataReturnResponseOk(a); + d = a.ObjectResponse["data"]; + //PUT var NewPassword = "NEW_PASSWORD"; - D.password = NewPassword; - D.concurrencyToken = OriginalConcurrencyToken; - R = await Util.PutAsync("User/" + UserId.ToString(), await Util.GetTokenAsync("manager", "l3tm3in"), D.ToString()); - Util.ValidateDataReturnResponseOk(R); + d.password = NewPassword; + a = await Util.PutAsync("User/" + UserId.ToString(), await Util.GetTokenAsync("manager", "l3tm3in"), d.ToString()); + Util.ValidateDataReturnResponseOk(a); //Test can login with new creds //dynamic DCreds = new JObject(); DCreds.password = NewPassword; - DCreds.login = D.login; - R = await Util.PostAsync("Auth", null, DCreds.ToString()); - Util.ValidateDataReturnResponseOk(R); + DCreds.login = d.login; + a = await Util.PostAsync("Auth", null, DCreds.ToString()); + Util.ValidateDataReturnResponseOk(a); } - /// - /// - /// - [Fact] - public async void PutPasswordShouldWork() - { - //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.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 UserId = R.ObjectResponse["data"]["id"].Value(); - uint OriginalConcurrencyToken = R.ObjectResponse["data"]["concurrencyToken"].Value(); - - //Test can login - dynamic DCreds = new JObject(); - DCreds.password = D.password; - DCreds.login = D.login; - R = await Util.PostAsync("Auth", null, DCreds.ToString()); - Util.ValidateDataReturnResponseOk(R); - - //PATCH - var newPassword = "NEW_PASSWORD"; - string patchJson = "[{\"value\": \"" + newPassword + "\",\"path\": \"/password\",\"op\": \"replace\"}]"; - R = await Util.PatchAsync("User/" + UserId.ToString() + "/" + OriginalConcurrencyToken.ToString(), await Util.GetTokenAsync("manager", "l3tm3in"), patchJson); - Util.ValidateDataReturnResponseOk(R); - - //Test can login with new creds - //dynamic DCreds = new JObject(); - DCreds.password = newPassword; - DCreds.login = D.login; - R = await Util.PostAsync("Auth", null, DCreds.ToString()); - Util.ValidateDataReturnResponseOk(R); - } @@ -363,7 +323,7 @@ namespace raven_integration d.login = Util.Uniquify("LOGIN"); d.password = Util.Uniquify("PASSWORD"); d.roles = 0;//norole - + d.userType = 3;//non scheduleable //Required by form custom rules d.notes = "notes"; @@ -378,7 +338,7 @@ namespace raven_integration d.login = Util.Uniquify("LOGIN"); d.password = Util.Uniquify("PASSWORD"); d.roles = 0;//norole - + d.userType = 3;//non scheduleable d.active = true; //Required by form custom rules @@ -394,7 +354,7 @@ namespace raven_integration d.login = Util.Uniquify("LOGIN"); d.password = Util.Uniquify("PASSWORD"); d.roles = 0;//norole - + d.userType = 3;//non scheduleable d.active = false; //Required by form custom rules @@ -436,7 +396,7 @@ namespace raven_integration //name starts with filter to constrict to widgets that this test block created only dListView.Add(Util.BuildSimpleFilterDataListViewColumn("username", Util.OpStartsWith, ObjectNameStart)); dListView.Add(Util.BuildSimpleSortDataListViewColumn("useractive", "+")); - //DEPRECATED NO DF ANYMORE dListView.Add(Util.BuildSimpleSortDataListViewColumn("df", "+")); + //DEPRECATED NO DF ANYMORE dListView.Add(Util.BuildSimpleSortDataListViewColumn("df", "+")); //NOW FETCH WIDGET LIST WITH FILTER UserDataList // a = await Util.GetAsync($"DataList/list?DataListKey=UserDataList&Offset=0&Limit=999&DataFilterId={DataFilterId.ToString()}", await Util.GetTokenAsync("manager", "l3tm3in"));