public static void test(StringBuilder sb) { var db = driverLow.create(); sb.AppendLine(); sb.AppendLine("*************************************************************"); sb.AppendLine("Admin/CompanyAdmin.ts"); db.testDeleteAll(); var adm = new adminCompanyController(); var globAdm = new adminGlobalController(); sb.AppendLine("***** otherCompanyAdmins, add, remove"); adm.setCompanyUserRoles("comp1", "p&p.p", CompRole.Department | CompRole.Admin); adm.setCompanyUserRoles("comp1", "p2&p.p", CompRole.HumanEvalManager); sb.AppendLine(JsonConvert.SerializeObject(adm.getCompanyUserRoles("comp1"))); adm.setCompanyUserRoles("comp1", "p2&p.p", 0); sb.AppendLine(JsonConvert.SerializeObject(adm.getCompanyUserRoles("comp1"))); db.testDeleteAll(); sb.AppendLine("***** otherCompanyAdmins, add company and system admin"); globAdm.createNewCompany("comp1", "[email protected]", true); adm.setCompanyUserRoles("comp1", "[email protected]", CompRole.Department); sb.AppendLine(JsonConvert.SerializeObject(adm.getCompanyUserRoles("comp1"))); sb.AppendLine("***** otherCompanyAdmins, remove company admin"); adm.setCompanyUserRoles("comp1", "[email protected]", 0); sb.AppendLine(JsonConvert.SerializeObject(adm.getCompanyUserRoles("comp1"))); sb.AppendLine(JsonConvert.SerializeObject(globAdm.getCompaniesAndTheirAdmins())); sb.AppendLine(); sb.AppendLine("*************************************************************"); sb.AppendLine("Admin/HumanEvalManager.ts"); db.testDeleteAll(); sb.AppendLine("***** evaluator: add, remove"); adm.setHumanEvaluator("comp1", "[email protected]", new LineIds[] { LineIds.English, LineIds.German }); sb.AppendLine("ADD: " + JsonConvert.SerializeObject(adm.getCompanyUserRoles("comp1"))); adm.setHumanEvaluator("comp1", "[email protected]", new LineIds[] { LineIds.English }); sb.AppendLine("EDIT: " + JsonConvert.SerializeObject(adm.getCompanyUserRoles("comp1"))); adm.setHumanEvaluator("comp1", "[email protected]", new LineIds[0]); sb.AppendLine("REMOVE:" + JsonConvert.SerializeObject(adm.getCompanyUserRoles("comp1"))); sb.AppendLine(JsonConvert.SerializeObject(db.compRead<Company_User>("comp1").usersObj)); }
public static void test(StringBuilder sb) { var db = driverLow.create(); sb.AppendLine(); sb.AppendLine("*************************************************************"); sb.AppendLine("Admin/Admin.ts"); db.testDeleteAll(); var adm = new adminGlobalController(); var logSrv = new azure.LoginController(); var packedPsw = LowUtils.packStr("xstdg"); sb.AppendLine("***** systemAdmin, add, not exist"); var email = adm.createSystemAdmin("[email protected]", true); sb.AppendLine(JsonConvert.SerializeObject(db.userRead<User_Data>(email))); email = logSrv.CreateLmUserStart(new LMCookieJS { EMail = "[email protected]" }, packedPsw); logSrv.CreateLmUserEnd(email); sb.AppendLine(JsonConvert.SerializeObject(db.userRead<User_Data>(email))); sb.AppendLine(db.sysRead<Sys_Admin>().strData); sb.AppendLine("***** systemAdmin, add, exist"); email = logSrv.CreateLmUserStart(new LMCookieJS { EMail = "[email protected]" }, packedPsw); logSrv.CreateLmUserEnd(email); sb.AppendLine(JsonConvert.SerializeObject(db.userRead<User_Data>(email))); email = adm.createSystemAdmin("[email protected]", true); sb.AppendLine(JsonConvert.SerializeObject(db.userRead<User_Data>(email))); sb.AppendLine(db.sysRead<Sys_Admin>().strData); sb.AppendLine("***** systemAdmin, remove, exist"); email = adm.createSystemAdmin("[email protected]", false); sb.AppendLine(JsonConvert.SerializeObject(db.userRead<User_Data>(email))); sb.AppendLine(db.sysRead<Sys_Admin>().strData); sb.AppendLine(); db.testDeleteAll(); sb.AppendLine("***** mainCompanyAdmin, add"); //new azureModel.Company("comp1").insert(); //new azureModel.User("[email protected]").insert(); //new azureModel.User("[email protected]").insert(); adm.createNewCompany("comp1", "[email protected]", true); sb.AppendLine("company." + JsonConvert.SerializeObject(db.compRead<Company_User>("comp1").usersObj)); sb.AppendLine("user" + JsonConvert.SerializeObject(db.userRead<User_Company>("[email protected]").companiesObj)); sb.AppendLine("***** mainCompanyAdmin, remove"); adm.createNewCompany("comp1", "[email protected]", false); sb.AppendLine("company." + JsonConvert.SerializeObject(db.compRead<Company_User>("comp1").usersObj)); sb.AppendLine("user" + JsonConvert.SerializeObject(db.userRead<User_Company>("[email protected]").companiesObj)); sb.AppendLine("***** mainCompanyAdmin, add, add"); adm.createNewCompany("comp1", "[email protected]", true); adm.createNewCompany("comp1", "[email protected]", true); sb.AppendLine("company." + JsonConvert.SerializeObject(db.compRead<Company_User>("comp1").usersObj)); sb.AppendLine("user" + JsonConvert.SerializeObject(db.userRead<User_Company>("[email protected]").companiesObj)); sb.AppendLine("user" + JsonConvert.SerializeObject(db.userRead<User_Company>("[email protected]").companiesObj)); sb.AppendLine("***** mainCompanyAdmin, add, remove"); adm.createNewCompany("comp1", "[email protected]", true); adm.createNewCompany("comp1", "[email protected]", false); sb.AppendLine("company." + JsonConvert.SerializeObject(db.compRead<Company_User>("comp1").usersObj)); sb.AppendLine("user" + JsonConvert.SerializeObject(db.userRead<User_Company>("[email protected]").companiesObj)); sb.AppendLine("user" + JsonConvert.SerializeObject(db.userRead<User_Company>("[email protected]").companiesObj)); sb.AppendLine("***** mainCompanyAdmin, getMainCompanyAdmins"); sb.AppendLine(JsonConvert.SerializeObject(adm.getCompaniesAndTheirAdmins())); }
public static void test(StringBuilder sb) { var db = driverLow.create(); sb.AppendLine(); sb.AppendLine("*************************************************************"); sb.AppendLine("Admin/products.ts"); db.testDeleteAll(); var adm = new adminLicenceController(); var admGlob = new adminGlobalController(); sb.AppendLine("***** add products"); admGlob.createNewCompany("comp1", "p&p.p", true); adm.createNewProduct("comp1", "/a/b/c/", false, 10, true); adm.createNewProduct("comp1", "/a/b/c/", false, 15, true); adm.createNewProduct("comp1", "/a/b/c/d/", false, 10, true); sb.AppendLine(JsonConvert.SerializeObject(adm.getAllProductsLicInfo("comp1"))); sb.AppendLine("company." + JsonConvert.SerializeObject(db.compRead<Company_Licence>("comp1"))); sb.AppendLine("***** delete products"); adm.createNewProduct("comp1", "/a/b/c/", null, 10, false); adm.createNewProduct("comp1", "/a/b/c/", null, 15, false); sb.AppendLine(JsonConvert.SerializeObject(adm.getAllProductsLicInfo("comp1"))); sb.AppendLine(); sb.AppendLine("*************************************************************"); sb.AppendLine("Admin/keyGen.ts, schools/my.ts"); db.testDeleteAll(); var logSrv = new azure.LoginController(); var packedPsw = LowUtils.packStr("xstdg"); admGlob.createNewCompany("comp1", "a&p.p", true); adm.createNewProduct("comp1", "/a/b/c/", false, 10, true); logSrv.CreateLmUserStart(new LMCookieJS { EMail = "[email protected]" }, packedPsw); logSrv.CreateLmUserEnd("[email protected]"); logSrv.CreateLmUserStart(new LMCookieJS { EMail = "[email protected]" }, packedPsw); logSrv.CreateLmUserEnd("[email protected]"); var keys1 = adm.generateLicenceKeys("comp1", "/a/b/c/", 10, 5); sb.AppendLine("comp1.licenceObj=" + JsonConvert.SerializeObject(db.compRead<Company_Licence>("comp1").licenceObj)); sb.AppendLine("keys=" + JsonConvert.SerializeObject(keys1)); var res = adm.enterLicenceKey("[email protected]", keys1[0].CompShortId, keys1[0].LicId, keys1[0].LicKeyId); sb.AppendLine("comp1.licenceObj=" + JsonConvert.SerializeObject(db.compRead<Company_Licence>("comp1").licenceObj)); sb.AppendLine("[email protected]=" + JsonConvert.SerializeObject(db.userRead<User_Company>("[email protected]").companiesObj)); res = adm.enterLicenceKey("[email protected]", keys1[0].CompShortId, keys1[0].LicId, keys1[0].LicKeyId); sb.AppendLine("The same user: "******"[email protected]", keys1[1].CompShortId, keys1[1].LicId, keys1[1].LicKeyId); sb.AppendLine("comp1.licenceObj=" + JsonConvert.SerializeObject(db.compRead<Company_Licence>("comp1").licenceObj)); res = adm.enterLicenceKey("[email protected]", keys1[1].CompShortId, keys1[1].LicId, keys1[1].LicKeyId); sb.AppendLine("Other user: " + res.ToString()); }