private void PerformTest(IEnumerable <KeyValuePair <string, string> > request, System.Net.HttpStatusCode statusCode = 0, bool isPassed = true, HttpMethod method = HttpMethod.GET) { var fileManager = new FileApiManager(FileHelper.APIMapper[APITypes.Download]); var resultTest = fileManager.Execute <object>(request, method.ToNetHttpMethod()); if (isPassed) { PrAssert.That(resultTest, PrIs.SuccessfulResponse().And.HttpCode(statusCode), "Can not download file."); } else { PrAssert.That(resultTest, PrIs.ErrorResponse().And.HttpCode(statusCode), "Still able to view file."); } }
public void TestSearchOptionIdAlias(ValidOptionId optionId, ValidOptionAlias optionAlias) { OptionManager optionHandler = new OptionManager(); Dictionary <string, string> requestDic = new Dictionary <string, string>() { ["alias"] = ValidAliasMapper[optionAlias], }; ValidIdMapper[optionId](requestDic, OptionCreater.Data.Id); var response = optionHandler.SearchOption(requestDic); PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(HttpStatusCode.BadRequest).And.ErrorCode((int)ResultCode.InvalidParameter), $"Still able to search option with both id = {optionId.ToString()} and alias = {optionAlias.ToString()}"); }
private static void VerifyResponse(TestFramework.ApiResponse <IdentityResponse> response) { PrAssert.That(response, PrIs.SuccessfulResponse()); PrAssert.That(response.Result, PrIs.Not.Null); PrAssert.That(response.Result.User, PrIs.Not.Null); PrAssert.That(response.Result.User.Id, PrIs.Not.Null); PrAssert.That(response.Result.User.Name, PrIs.Not.Null); PrAssert.That(response.Result.User.Language, PrIs.Not.Null); PrAssert.That(response.Result.User.Language, PrIs.EqualTo("en_us")); PrAssert.That(response.Result.Company, PrIs.Not.Null); PrAssert.That(response.Result.Company.Id, PrIs.Not.Null); PrAssert.That(response.Result.Company.Name, PrIs.Not.Null); PrAssert.That(response.Result.Company.CompanyLoginId, PrIs.Not.Null); }
public void InvalidInjectionCustomActionReplaceTest(string parameterName, InjectionInput injection) { var replaceRequest = GetReplaceRequest(PrepareData.Data.Id, new Dictionary <string, object> { [ResourceId.Client.ToString().ToLower()] = RecordsCreator.Data[ResourceId.Client].Id, }); replaceRequest[parameterName] = InjectionInputData.InjectionInputMapper[injection]; var hanlder = new CustomActionManager(); var replaceResponse = hanlder.Replace <object>(replaceRequest, HttpMethod.POST.ToNetHttpMethod()); PrAssert.That(replaceResponse, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.BadRequest), "Can not create custom action"); }
public void ValidMatchingSearchTest(ValidIds ids, ResourceId type) { var request = new List <KeyValuePair <string, string> >(); request.AddRange(MatchingSearchTestCase.FileNameMapper[ids](RecordsCreator.Data[$"{ResourceId.Job}{0}"].Id, RecordsCreator.Data[$"{ResourceId.Job}{1}"].Id, RecordsCreator.Data[$"{ResourceId.Resume}{0}"].Id, RecordsCreator.Data[$"{ResourceId.Resume}{1}"].Id)); request.Add(new KeyValuePair <string, string>(Parameters.Type.GetEnumStringValue(), $"{type.ToString().ToLower()}")); var defaultManager = new DefaultManager(); var response = defaultManager.Send <MatchingSearchResponse>(MatchingSearchTestCase.MatchingSearchEndpoint, request, HttpMethod.GET); PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK)); }
public void InvalidInjectionCreateFolderTests(FolderParam param, Enums.InvalidInjection testcase) { var request = new Dictionary <string, string> { ["name"] = GetStringLengthMapper[Length.Random], ["type"] = Types.Public.ToString().ToLower() }; request[FolderParamMapper[param]] = InjectionMapper[testcase]; var reportHandler = new DefaultManager(); var result = reportHandler.Send <FolderResponse>(EndPoint, request, HttpMethod.POST); PrAssert.That(result, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.BadRequest), "Still create folder successful."); }
public void TestSearchOptionIdLevelCount(ValidOptionId optionId, int optionLevel, OptionCount optionCount) { OptionManager optionHandler = new OptionManager(); Dictionary <string, string> requestDic = new Dictionary <string, string>(RequestOptionSearch); ValidIdMapper[optionId](requestDic, OptionCreator.Data.Id); requestDic["level"] = optionLevel.ToString(); requestDic["count"] = ValidCountMapper[optionCount].ToString(); var response = optionHandler.SearchOption(requestDic); PrAssert.That(response, PrIs.SuccessfulResponse()); PrAssert.That(response.Result, PrIs.Not.Null.And.Not.Empty); PrAssert.That(response.Result.Select(r => r.Id), Has.Exactly(1).EqualTo(OptionCreator.Data.Id), "The expected option cannot be found!"); }
public void InvalidMethodMenusTest(HttpMethod method) { var handler = new DefaultManager(); var request = new Dictionary <string, string> { ["enable"] = "-1", ["language"] = "en_us", ["languageDefault"] = "true", ["_"] = "1536741227", }; var allMenus = handler.SendAsync <MenusResponseData>(SublistMenuTestData.MenusEndPoint, request, method).Result; PrAssert.That(allMenus, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.NotFound), "Still able to use menus api with wrong method"); }
public void ValidMissingResourceIdGetMethodTest() { var MergeSettingManager = new MergeSettingsManager(); var result = MergeSettingManager.MergeSettings <MergeSettingsResponse>(HttpMethod.Get); PrAssert.That(result, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK)); PrAssert.That(result.Result.Settings, PrIs.Not.Null.Or.Empty); PrAssert.That(result.Result.Settings.Count, PrIs.EqualTo(4)); foreach (var setting in result.Result.Settings) { PrAssert.That(new[] { setting.ResourceType }, PrIs.SubsetOf(new[] { 1, 5, 9, 17 })); } }
public void TestOriginalSearchDialogWrongContentType() { var handler = new OriginalSearchManager(); //Create conditions var conditions = handler.OriginalSearch <List <ConditionsDataResponse> >(GetOriginalSearchConditionsParameters(ResourceId.Client), System.Net.Http.HttpMethod.Get); PrAssume.That(conditions, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK)); //Create a condition handler = new OriginalSearchManager("/privateapi/hrbc/condition"); var condition = handler.OriginalSearch <ConditionDataResponse>(GetOriginalSearchConditionParameters(ResourceId.Client, conditions.Result.First().Id), System.Net.Http.HttpMethod.Get, "application/json"); PrAssert.That(condition, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.BadRequest)); }
public void TestValidDeleteTwiceTemplate() { var handler = new DefaultManager(); var request = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>(IdParam, Ids.Last().ToString()) }; var response = handler.Send <CreateTemplateResponse>(TemplateEndPoint, request, HttpMethod.DELETE); PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.NoContent)); //Delete twice response = handler.Send <CreateTemplateResponse>(TemplateEndPoint, request, HttpMethod.DELETE); PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.BadRequest)); }
public void InvalidJsonDeletePhaseEntry(InvalidSpecialCondition json) { var handler = new DefaultManager(); var deleteItem = GetDeleteItem(PreparedPhaseId); var request = new Dictionary <string, object>() { [ParamDelete] = deleteItem }.ToJson(); PrAssert.That(request, PrIs.Not.EqualTo(string.Empty)); var updateResponse = handler.SendAsync <object>(PhaseEntryTestData.PhaseEntryApi, SublistMenuTestData.InvalidBodyJsonTestCasesMapper[json](request), HttpMethod.DELETE).Result; PrAssert.That(updateResponse, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.BadRequest), "Delete Phase Entry sucessfully"); }
public void ValidReturnJsonContentTypeTest(HttpMethod method) { System.Net.Http.HttpResponseMessage response; var connection = PrivateApiConnection.GetConnectionForCurrentTest(); var request = new Dictionary <string, string> { ["id"] = method == HttpMethod.POST ? DataTest.Data[ReportCreateStep.CreateSpec].ToString() : DataTest.Data[ReportCreateStep.CreateTable].ToString() }; response = connection.SendAsync(EndPoint, request, method.ToNetHttpMethod()).Result; PrAssert.That(response.Content.Headers.ContentType.MediaType, PrIs.EqualTo("application/json")); }
public void ValidEntryWithPostMethod(ValidCondition condition, ResourceId resource) { var entryManager = new EntryManager(); var data = PrepareData(condition, resource); var param = new Dictionary <string, string>() { ["condition"] = data }; var result = entryManager.GetEntryRecords <EntryResponse>(resource, param as object, HttpMethod.Post); PrAssert.That(result, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK)); PrAssert.Equals(result.Result.Total, result.Result.Items.Length); }
public void ValidDuplicateHiddenMail(string param, Enums.ValidDuplicated validDuplicated) { var handler = new DefaultManager(); var request = HiddenMailRequest(GetMailsId.Data.First()); GetAndHiddenTestData.ValidGetMailsMapperValue[GetAndHiddenTestData.Valid.One](request, param, new List <int>()); var otherValue = HiddenMailRequest(GetMailsId.Data.Last()); GetAndHiddenTestData.ValidGetMailsMapperValue[GetAndHiddenTestData.Valid.Zero](otherValue, param, new List <int>()); Helpers.DuplicateParam(param, request, otherValue, validDuplicated); var response = handler.Send <object>(MailGetAndHidden.HiddenMail, request.ToJson().ReplaceDuplicate(param), HttpMethod.PUT); PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.NoContent), "Still able to hide mail"); }
public void InvalidCreateMailServer(MailServerTestData.Invalid invalid, string param) { var handler = new DefaultManager(); var request = new Dictionary <string, object>(); MailServerTestData.ValidIncomingMapperValue[MailServerTestData.Valid.Porters](request, MailServerTestData.Server); MailServerTestData.ValidIncomingMapperValue[MailServerTestData.Valid.POP3Port](request, MailServerTestData.Port); MailServerTestData.ValidIncomingMapperValue[MailServerTestData.Valid.Zero](request, MailServerTestData.Ssl); MailServerTestData.ValidIncomingMapperValue[MailServerTestData.Valid.POP3Protocol](request, MailServerTestData.Protocol); MailServerTestData.InvalidIncomingMapperValue[invalid](request, param); var response = handler.Send <object>(MailServer.Server, request.ToJson(), HttpMethod.POST); PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.BadRequest), "Can not create mail server"); }
public void InvalidGetMediaTests(string param, InvalidValue invalidValue) { var request = new Dictionary <string, string>() { [GetMediaParam.jobId.ToString()] = "35", [GetMediaParam.status.ToString()] = Status.Scouted.GetEnumStringValue() }; CommonMapper.InvalidValueMapper[invalidValue](request, param); var defaultManager = new DefaultManager(new MatchingProUIConnection(TestConfig.GetValueFromConfig("MatchingProWeb"))); var response = defaultManager.Send <object>(Endpoints.Media, request, HttpMethod.GET); PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.BadRequest)); }
public void TestInvalidUpdatePhaseTemplateInjection(Phase param, Enums.InvalidInjection invalid) { var handler = new DefaultManager(); var request = BuildCreateTemplateWithProcessRequest(OptionPhaseProcess, OptionEndReason, PhaseType.One, CommonEnums.String, EndFlag.True, EndReason.Valid); request[IdParam] = Id; var phase = request[Parameters.Phase.GetEnumStringValue()] as Dictionary <string, object>; phase[param.GetEnumStringValue()] = MapperData.InvalidInjectionMapper[invalid]; request[Parameters.Phase.GetEnumStringValue()] = phase; var response = handler.Send <object>(TemplateEndPoint, JsonConvert.SerializeObject(request), HttpMethod.PUT); PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.BadRequest)); }
public void UpdatePasswordValid(ValidNewPasswordTestCases inputType) { var creds = AuthenticationInfoProvider.GetAuthSpecForCurrentTest(); var defaultPassword = creds.Companies.First().Value.Users.First().Password; var updatePassRequest = new Dictionary <string, object>(Common.UpdatePasswordParameters); updatePassRequest["newPassword"] = NewPasswordMappingValues[inputType]; updatePassRequest["oldPassword"] = defaultPassword; var updatePassHandler = new UpdatePasswordManager(); var response = updatePassHandler.UpdatePassword(updatePassRequest, HttpMethod.Put); PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.NoContent)); LastPassword = NewPasswordMappingValues[inputType].ToString(); }
public void MergeValid(ResourceId resourceId, ValidTestCases inputType) { var mergeRequest = GetParameters(resourceId, inputType); var mergeHandler = new MergeManager(); var response = mergeHandler.MergeRecords <MergeResponse>(resourceId, mergeRequest, HttpMethod.Post); PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK)); //Waiting for merge task successed before verifing data Assert.That(GetQueueMergeStatus(response.Result.Id.ToString()), "The merging is not finished yet!"); //Verify data VerifyData(resourceId, inputType); }
private void PerformTest <T>(T request, System.Net.HttpStatusCode statusCode = 0, bool isPassed = true, HttpMethod method = HttpMethod.DELETE) { var fileManager = new FileApiManager(FileHelper.APIMapper[APITypes.Storage]); var resultTest = fileManager.Execute <object>(request, method.ToNetHttpMethod()); if (isPassed) { PrAssert.That(resultTest, PrIs.SuccessfulResponse().And.HttpCode(statusCode), "Can not delete file storage."); } else { PrAssert.That(resultTest, PrIs.ErrorResponse().And.HttpCode(statusCode), "File storage is deleted."); } }
private void PerformHappyPathSubqueryTest(ResourceId resource, SearchRequest request) { var expectedId = RecordsCreator.Data[$"{resource}"].Id; var subqueryRequest = SearchRequestComposer.GetBuilderWithRestrictions(resource).SubqueryFilter($"{resource}.P_Id", resource, $"{resource}.P_Id", request.Conditions.Filter); //request.Conditions.Filter.Field.Route, resource, request.Conditions.Filter.Field.Route, request.Conditions.Filter);//(request.Conditions.Filter); //TODO: uncomment the line above and set bug 39348 var handler = new DefaultManager(); var response = handler.Send <SearchResponse>(subqueryRequest); PrAssert.That(response, PrIs.SuccessfulResponse()); PrAssert.That(response?.Result?.Status, PrIs.Not.Null.And.EqualTo("OK")); PrAssert.That(response?.Result?.Items, PrIs.Not.Null.And.Contains(expectedId)); }
public void TestInvalidDeleteGlobalSmtp(InvalidValue invalid) { var handler = new DefaultManager(); var request = new Dictionary <string, object>(); InvalidValueMapper[invalid](request, Parameters.Global.GetEnumStringValue()); var response = handler.Send <object>(SmtpEndPoint, invalid == InvalidValue.MissingParam ? new List <KeyValuePair <string, string> >() : new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>(Parameters.Global.GetEnumStringValue(), request[Parameters.Global.GetEnumStringValue()].ToString()) }, HttpMethod.DELETE); PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.BadRequest)); }
public void InvalidFormulaWithDependenciesTest(ResourceId resource, HRBCClientPrivate.API.Field.FieldType fieldType, string formulas) { var specs = ParseSpecs(formulas, resource, fieldType); foreach (var spec in specs.Take(specs.Count() - 1)) { var response = SetFormula(spec.Value, new FieldDescriptor(resource, fieldType, spec.Key)); PrAssume.That(response, PrIs.SuccessfulResponse()); } var responseToVerify = SetFormula(specs.Last().Value, new FieldDescriptor(resource, fieldType, specs.Last().Key)); PrAssert.That(responseToVerify, PrIs.ErrorResponse().With.HttpCode(400)); }
public void WritingPasswordSettingsInvalidMinLength(Common.InvalidValue invalidMinlength) { var validRequest = new Dictionary <string, object>() { ["companyId"] = Common.OldCompanyId.ToString(), ["minLength"] = Common.DefaultMinLength, ["checkComplexity"] = false, }; var request = Common.InvalidNumberMapper[invalidMinlength](validRequest, "minLength"); var handler = new CorePasswordManager(); var response = handler.Password <object>(request, System.Net.Http.HttpMethod.Put); PrAssert.That(response.HttpStatusCode, PrIs.EqualTo(HttpStatusCode.Redirect)); }
public void TestWriteWebPasswordAccessEndpoint(AccessState accessState, HttpStatusCode httpStatusCode, ResultCode resultCode) { var request = new Dictionary <string, object>() { ["companyId"] = Common.OldCompanyId, ["minLength"] = 8, ["checkComplexity"] = true, }; var handler = new WebPasswordManager(); var response = handler.Password <object>(request, System.Net.Http.HttpMethod.Put); PrAssert.That(response, PrIs.ErrorResponse()); PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(httpStatusCode).And.ContainsError(((int)resultCode).ToString()), "Still able to access merge api."); }
public void TestSearchOptionInvalidLevelCount(ValidOptionId optionId, InvalidOptionLevel optionLevel, InvalidOptionCount optionCount) { OptionManager optionHandler = new OptionManager(); Dictionary <string, string> requestDic = new Dictionary <string, string>() { ["level"] = InvalidLevelMapper[optionLevel], ["count"] = InvalidCountMapper[optionCount], }; ValidIdMapper[optionId](requestDic, OptionCreater.Data.Id); var response = optionHandler.SearchOption(requestDic); PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(HttpStatusCode.BadRequest).And.ErrorCode((int)ResultCode.InvalidValue).Or.ErrorCode((int)ResultCode.ValueRangeExceeded), $"Still able to search option with both id = {optionId.ToString()}, level = {optionLevel.ToString()} and count = {optionCount.ToString()}"); }
public void ValidDuplicateGetNewMails(string param, Enums.ValidDuplicated validDuplicated) { var handler = new DefaultManager(); var request = new Dictionary <string, object>(); GetAndHiddenTestData.ValidGetMailsMapperValue[GetAndHiddenTestData.Valid.One](request, param, new List <int>()); var otherValue = new Dictionary <string, object>(); GetAndHiddenTestData.ValidGetMailsMapperValue[GetAndHiddenTestData.Valid.Zero](otherValue, param, new List <int>()); Helpers.DuplicateParam(param, request, otherValue, validDuplicated); var response = handler.Send <object>(MailGetAndHidden.GetNewMails, request.ToJson().ReplaceDuplicate(param), HttpMethod.POST); PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK), "Still able to get mails"); }
public void TestGetDuplicateParameterTemplate(Enums.ValidDuplicated inputType) { var handler = new DefaultManager(); var param = new KeyValuePair <string, string>(Parameters.Id.GetEnumStringValue(), Ids.First().ToString()); var request = new List <KeyValuePair <string, string> >() { param }; RequestGetDuplicate[inputType](param, request); var response = handler.Send <object>(TemplateEndPoint, request, HttpMethod.GET); PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK)); }
public void InvalidMethodGetMails(HttpMethod httpMethod) { var handler = new DefaultManager(); var request = new Dictionary <string, object>(); GetAndHiddenTestData.ValidGetMailsMapperValue[GetAndHiddenTestData.Valid.One](request, GetAndHiddenTestData.PageNumber, new List <int>()); GetAndHiddenTestData.ValidGetMailsMapperValue[GetAndHiddenTestData.Valid.One](request, GetAndHiddenTestData.PageSize, new List <int>()); GetAndHiddenTestData.ValidGetMailsMapperValue[GetAndHiddenTestData.Valid.One](request, GetAndHiddenTestData.SortOrder, new List <int>()); GetAndHiddenTestData.ValidGetMailsMapperValue[GetAndHiddenTestData.Valid.Box](request, GetAndHiddenTestData.SortField, new List <int>()); GetAndHiddenTestData.ValidGetMailsMapperValue[GetAndHiddenTestData.Valid.One](request, GetAndHiddenTestData.ShowHidden, new List <int>()); var response = handler.Send <GetMailsResponse>(MailGetAndHidden.GetMails, request.ToJson(), httpMethod); PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.NotFound), "Still able to get mails"); }