public void VerifyResponseContentTypeUpdatePhaseEntryTest()
 {
     System.Net.Http.HttpResponseMessage response;
     using (var step = LogHelper.LoggerForCurrentTest.EnterReproStep($"Menu api"))
     {
         var con       = PrivateApiConnection.GetConnectionForCurrentTest();
         var result    = new List <Dictionary <string, object> >();
         var dataItem  = GetDataItem();
         var phaseItem = GetUpdatePhaseItem(dataItem, RecordsCreator, PreparedPhaseId);
         result.Add(phaseItem);
         var request = new Dictionary <string, object>()
         {
             [ParamUpdate] = result
         };
         var requestJson = request.ToJson();
         response = con.SendAsync(PhaseEntryTestData.PhaseEntryApi, requestJson, HttpMethod.PUT.ToNetHttpMethod()).Result;
     }
     PrAssert.That(response.IsSuccessStatusCode, "Can not request successfull");
     PrAssert.That(response.Content.Headers.ContentType.MediaType, PrIs.EqualTo("application/json"), "The content type is not as expected");
 }
Exemplo n.º 2
0
        public void TestCreateOptionalParameterValid(ResourceId resource, Properties.Alias alias, Properties.Caption caption, Properties.Search search, Properties.Match match, Properties.Web web, Properties.Highlight highlight, Properties.Require require, Properties.Length length, Properties.Default deft, Properties.Height height)
        {
            var handler    = new DefaultManager();
            var properties = TextHelpers.GenerateWithRequireProperties(Defines.FieldTypeApi, caption, search, match, web, highlight, require, length, deft, height);
            var request    = TextHelpers.GenerateCreateRequest(resource, alias, properties);
            var response   = handler.Send <FieldCreateResponse>(FieldManager.FieldHandlingRelativeUrl, JsonConvert.SerializeObject(request), HttpMethod.POST);

            PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK));
            PrAssert.That(response.Result.Id, PrIs.Not.Null.Or.Not.Empty);

            var result = (new FieldManager()).GetFieldDetails(response.Result.Id);

            //Clearn up
            CommonHelpers.DeleteField(new List <Guid> {
                response.Result.Id
            });
            //Verify
            PrAssert.That(result.Result.Values.SingleOrDefault().Value.Id, PrIs.EqualTo(response.Result.Id));
            TextHelpers.VerifyProperties(result.Result.Values.SingleOrDefault().Value.Properties, properties);
        }
        public void TestInvalidUpdateTemplateWithPhase(Phase param, Enum invalid)
        {
            var handler = new DefaultManager();
            var request = BuildCreateTemplateWithProcessRequest(OptionPhaseProcess, OptionEndReason, PhaseType.One, CommonEnums.String, EndFlag.True, EndReason.Valid);
            var phases  = request[Parameters.Phase.GetEnumStringValue()] as Dictionary <string, object>;

            if (param != Phase.Resource)
            {
                InvalidValueMapper[(InvalidValue)invalid](phases, param.GetEnumStringValue());
            }
            else
            {
                phases[Phase.Resource.GetEnumStringValue()] = invalid.ToString();
            }
            request[Parameters.Phase.GetEnumStringValue()] = phases;
            request[IdParam] = Id;
            var response = handler.Send <object>(TemplateEndPoint, JsonConvert.SerializeObject(request), HttpMethod.PUT);

            PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.BadRequest));
        }
Exemplo n.º 4
0
        public void ValidGetJobsTests(ValidStringValue q, ValidStringValue workArea, ValidIdValue companyId, ValidIdValue ownerId, ValidIdValue positionId, ValidIdValue industryId, Offset offset, Limit limit)
        {
            var request = new Dictionary <string, string>()
            {
                [GetJobsParam.jobId.ToString()] = "35"
            };

            GetJobsTestCases.ValidStringMapper[q](request, GetJobsParam.q.ToString());
            GetJobsTestCases.ValidStringMapper[workArea](request, GetJobsParam.workArea.ToString());
            GetJobsTestCases.ValidIdValueMapper[companyId](request, GetJobsParam.companyId);
            GetJobsTestCases.ValidIdValueMapper[ownerId](request, GetJobsParam.ownerId);
            GetJobsTestCases.ValidIdValueMapper[positionId](request, GetJobsParam.positionId);
            GetJobsTestCases.ValidIdValueMapper[industryId](request, GetJobsParam.industryId);
            CommonMapper.ValidOffsetMapper[offset](request);
            CommonMapper.ValidLimitMapper[limit](request);
            var defaultManager = new DefaultManager(new MatchingProUIConnection(TestConfig.GetValueFromConfig("MatchingProWeb")));
            var response       = defaultManager.Send <object>(Endpoints.Jobs, request, HttpMethod.GET);

            PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK));
        }
Exemplo n.º 5
0
        public void TestInvalidBodyJson(InvalidSpecialCondition inputType)
        {
            var handler = new DashboardManager(DashboardHelpers.DashboardRegistrationEndPoint);
            var request = new Dictionary <string, object>(DashboardHelpers.DashboardRegistrationDefaultParameters(UserIds));

            string jsonContent = string.Empty;

            if (inputType == InvalidSpecialCondition.BrokenJsonFormat)
            {
                jsonContent = JsonConvert.SerializeObject(request).Remove(0, 1);
            }
            else
            {
                jsonContent = DashboardHelpers.InvalidBodyJsonTestCasesMapper[inputType].ToString();
            }

            var response = handler.SendDashboard <object>(jsonContent, System.Net.Http.HttpMethod.Put);

            PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.BadRequest));
        }
        public void DeleteOptionByOtherHttpMethod(HttpMethod inputType)
        {
            var deleteParameters = new Dictionary <string, object>();
            var optionHandler    = new OptionManager();
            var options          = new List <Dictionary <string, object> >();

            deleteParameters["id"] = Common.GetOptionsByCurrentContext("parentOptionCreateResponse").FirstOrDefault().Id;

            var httpMethod = new Dictionary <HttpMethod, System.Net.Http.HttpMethod>()
            {
                [HttpMethod.GET]    = System.Net.Http.HttpMethod.Get,
                [HttpMethod.DELETE] = System.Net.Http.HttpMethod.Delete,
                [HttpMethod.PUT]    = System.Net.Http.HttpMethod.Put,
            };

            options.Add(deleteParameters);
            var response = optionHandler.DeleteOptions(options, urlParameters, httpMethod[inputType]);

            PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(HttpStatusCode.BadRequest).And.ErrorCode((int)ResultCode.InvalidParameter));
        }
Exemplo n.º 7
0
        public void TestUpdateValidSpecialProperties(ResourceId resource, FieldTypes fType, Properties.PropertyName propName)
        {
            var guid     = TextHelpers.Guid[fType](resource, FieldsCreator, Defines.FieldTypeApi, ApplicationFieldNames[Defines.FieldTypeApi]().First());
            var handler  = new DefaultManager();
            var request  = GenerateUpdateRequest(resource, guid.ToString(), GenerateExceptedProperties(Defines.FieldTypeApi, propName.GetEnumStringValue(), SpecialMappingValue[propName]));
            var response = handler.Send <object>(FieldManager.FieldHandlingRelativeUrl, JsonConvert.SerializeObject(request), TestCoreFramework.Enums.HttpMethod.PUT);

            PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.NoContent));

            var result = (new FieldManager()).GetFieldDetails(guid);

            if (propName == Properties.PropertyName.Enabled)
            {
                PrAssert.That(result.Result.Values.SingleOrDefault().Key.ToString(), PrIs.Not.EqualTo(propName.GetEnumStringValue()));
            }
            else
            {
                PrAssert.That(result.Result.Values.SingleOrDefault().Value.Properties[propName.GetEnumStringValue()], PrIs.Not.EqualTo(SpecialMappingValue[propName]));
            }
        }
Exemplo n.º 8
0
        public void ValidDuplicateGetReportData(string param, Enums.ValidDuplicated validDuplicated)
        {
            var handler = new DefaultManager();
            var tableId = PrepareTableId.Data[ResourceType.Client];
            var request = new Dictionary <string, string>()
            {
                ["%24select"] = "*",
                ["_"]         = "21313354679",
                ["id"]        = $"{tableId}",
                ["limit"]     = "25",
                ["page"]      = "0",
            };
            var    requestList = request.ToList();
            string value       = validDuplicated == Enums.ValidDuplicated.NotSameValue ? "This is duplicated value" : request[param];

            requestList.Add(new KeyValuePair <string, string> (param, value));
            var dataResponse = handler.Send <GetReportDataResponse>($"privateapi/report/{EndpointMapper[Endpoint.Data]}", request, HttpMethod.GET);

            PrAssert.That(dataResponse, PrIs.SuccessfulResponse().And.HttpCode(HttpStatusCode.OK), "Can not request data successfully");
        }
Exemplo n.º 9
0
        public void InvalidResourcePhaseItemUpdatePhaseEntry()
        {
            var handler   = new DefaultManager();
            var result    = new List <Dictionary <string, object> >();
            var dataItem  = GetDataItem(DateTime.Now.ToString(PhaseEntryTestData.DateTimeFormat));
            var phaseItem = GetCreatePhaseItem(dataItem, RecordsCreator);

            phaseItem[ParamPhaseId]  = PreparedPhaseId.Data[ResourceId.Client].Data[0].PhaseId;
            phaseItem[ParamResource] = (int)ResourceId.Job;
            result.Add(phaseItem);
            var request = new Dictionary <string, object>()
            {
                [ParamUpdate] = result
            }.ToJson();

            PrAssert.That(request, PrIs.Not.EqualTo(string.Empty));
            var updateResponse = handler.SendAsync <CreatePhaseEntryResponse>(PhaseEntryTestData.PhaseEntryApi, request, HttpMethod.PUT).Result;

            PrAssert.That(updateResponse, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.BadRequest), "Still able to create Phase Entry");
        }
Exemplo n.º 10
0
 public static void PerformTest(Title title, Dictionary <string, object> request, PrivateApiResponse <FieldCreateResponse> response, Guid fieldUuid, Guid layoutUuid, bool isCreate = true)
 {
     if (title.ToString().ContainsStrings(new[] { Lang.En.ToString() }))
     {
         PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.BadRequest));
     }
     else
     {
         if (isCreate)
         {
             PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK));
             ReadAndVerifyCreatedData(response.Result.Id, fieldUuid, request);
         }
         else
         {
             PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.NoContent));
             ReadAndVerifyUpdatedData(layoutUuid, fieldUuid, request);
         }
     }
 }
Exemplo n.º 11
0
        public void InvalidCreateMailIncoming(MailIncomingTestData.Valid global, MailIncomingTestData.Invalid invalid, string param)
        {
            var handler = new DefaultManager();
            var request = new Dictionary <string, object>();

            MailIncomingTestData.ValidIncomingMapperValue[global](request, MailIncomingTestData.Global, string.Empty);
            MailIncomingTestData.ValidIncomingMapperValue[MailIncomingTestData.Valid.Porters](request, MailIncomingTestData.Server, string.Empty);
            MailIncomingTestData.ValidIncomingMapperValue[MailIncomingTestData.Valid.POP3Port](request, MailIncomingTestData.Port, string.Empty);
            MailIncomingTestData.ValidIncomingMapperValue[MailIncomingTestData.Valid.Zero](request, MailIncomingTestData.Ssl, string.Empty);
            MailIncomingTestData.ValidIncomingMapperValue[MailIncomingTestData.Valid.POP3Protocol](request, MailIncomingTestData.Protocol, string.Empty);
            MailIncomingTestData.ValidIncomingMapperValue[MailIncomingTestData.Valid.ValidAccount](request, MailIncomingTestData.AccountName, string.Empty);
            MailIncomingTestData.ValidIncomingMapperValue[MailIncomingTestData.Valid.ValidPassword](request, MailIncomingTestData.Password, string.Empty);
            MailIncomingTestData.ValidIncomingMapperValue[MailIncomingTestData.Valid.Zero](request, MailIncomingTestData.FetchStart, string.Empty);
            MailIncomingTestData.ValidIncomingMapperValue[MailIncomingTestData.Valid.Zero](request, MailIncomingTestData.DefaultSharing, string.Empty);
            MailIncomingTestData.ValidIncomingMapperValue[MailIncomingTestData.Valid.ValidMailServer](request, MailIncomingTestData.MailServerId, string.Empty);
            MailIncomingTestData.InvalidIncomingMapperValue[invalid](request, param);
            var response = handler.Send <object>(MailIncoming.IncomingConfiguration, request.ToJson(), HttpMethod.PUT);

            PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.BadRequest), "Can not update mail incoming");
        }
        public void ValidUpdateAclActionListTests(ValidValue underscore, ValidValue target, ValidValue category, ValidValue type, ValidValue subType)
        {
            var request = new Dictionary <string, object>()
            {
                [ActionListPermissionParam.CustomActionId.GetEnumStringValue()] = string.Empty,
                [ActionListPermissionParam.SubType.GetEnumStringValue()]        = string.Empty
            };
            var defaultManager = new DefaultManager();

            CommonMapperData.ValidValueMapper[target](ActionListPermissionParam.Target.GetEnumStringValue(), request);
            CommonMapperData.ValidValueMapper[category](ActionListPermissionParam.Category.GetEnumStringValue(), request);
            CommonMapperData.ValidValueMapper[type](ActionListPermissionParam.Type.GetEnumStringValue(), request);
            CommonMapperData.ValidValueMapper[subType](ActionListPermissionParam.SubType.GetEnumStringValue(), request);
            var rq = request.ToDictionary(r => r.Key, r => r.Value.ToString());

            CommonMapperData.ValidUnderscoreValueMapper[underscore](rq);
            var response = defaultManager.Send <object>(ActionEndpoints.ActionPermission, rq, HttpMethod.GET);

            PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.BadRequest));
        }
Exemplo n.º 13
0
        public void ValidPutAclActionListTests(ValidValue target, ValidValue category, ValidValue type, ValidValue subType, ValidValue allow, ValidValue deny)
        {
            var request        = new Dictionary <string, object>();
            var securityGroups = new Dictionary <string, object>();
            var defaultManager = new DefaultManager();

            request[ActionPermissionSecurityGroupsParam.CustomActionId.GetEnumStringValue()] = string.Empty;
            CommonMapperData.ValidValueMapper[target](ActionPermissionSecurityGroupsParam.Target.GetEnumStringValue(), request);
            CommonMapperData.ValidValueMapper[category](ActionPermissionSecurityGroupsParam.Category.GetEnumStringValue(), request);
            CommonMapperData.ValidValueMapper[type](ActionPermissionSecurityGroupsParam.Type.GetEnumStringValue(), request);
            CommonMapperData.ValidValueMapper[subType](ActionPermissionSecurityGroupsParam.SubType.GetEnumStringValue(), request);
            request[ActionPermissionSecurityGroupsParam.SecurityGroups.GetEnumStringValue()]   = securityGroups;
            securityGroups[ActionPermissionSecurityGroupsParam.Id.GetEnumStringValue()]        = string.Empty;
            securityGroups[ActionPermissionSecurityGroupsParam.SubjectId.GetEnumStringValue()] = string.Empty;
            CommonMapperData.ValidValueMapper[allow](ActionPermissionSecurityGroupsParam.Target.GetEnumStringValue(), securityGroups);
            CommonMapperData.ValidValueMapper[deny](ActionPermissionSecurityGroupsParam.Category.GetEnumStringValue(), securityGroups);
            var response = defaultManager.Send <GetAclActionListPermissionsResponse>(ActionEndpoints.ActionPermissionSecurityGroups, request.ToJson(), HttpMethod.PUT);

            PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK));
        }
Exemplo n.º 14
0
        public void ReadHrbcCoreSessionInjection(Fields field, InjectionInput inputType)
        {
            var creds              = AuthenticationInfoProvider.GetAuthSpecForCurrentTest();
            var adminUserId        = creds.Companies.First().Value.Users.First().Metadata["userId"].ToString();
            var fieldName          = Char.ToLowerInvariant(field.ToString()[0]) + field.ToString().Substring(1);
            var readSessionHandler = new HrbcCoreManager();
            var request            = new Dictionary <string, string>()
            {
                ["companyId"] = CompanyId,
                ["userId"]    = adminUserId,
                ["sessionId"] = readSessionHandler.GetDefaultSessionId(_testConnection),
            };

            creds.Dispose();
            request[fieldName] = InjectionInputData.InjectionInputMapper[inputType];

            var response = readSessionHandler.SendHrbcCoreSession <HrbcCoreSessionResponse>(_testConnection, request, System.Net.Http.HttpMethod.Get, null);

            PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(HttpStatusCode.BadRequest));
        }
Exemplo n.º 15
0
        public void DuplicateParametersTest(Fields field, Values value)
        {
            var companyInfoHandler = new HrbcCoreManager();

            var parametersSameValue = new Dictionary <Fields, string>
            {
                [Fields.CompanyId] = $"/{CompanyId}/{CompanyId}?fullMode=true",
                [Fields.FullMode]  = $"/{CompanyId}?fullMode=true&fullMode=true",
            };

            var parametersNotSameValue = new Dictionary <Fields, string>
            {
                [Fields.CompanyId] = $"/{CompanyId}/{SecondCompanyId}?fullMode=true",
                [Fields.FullMode]  = $"/{CompanyId}?fullMode=true&fullMode=false",
            };

            var response = companyInfoHandler.SendHrbcCoreTmpCompanyInfo <HrbcCoreTmpCompanyInfoResponse>(_testConnection, value == Values.Same ? parametersSameValue[field] : parametersNotSameValue[field]);

            PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(HttpStatusCode.BadRequest));
        }
Exemplo n.º 16
0
        public void InvalidCreateCustomActionTest(string parameterName, CustomActionTestData.InvalidValue invalidValue)
        {
            var createRequest = GetCreateRequest(CustomActionTestData.ValidUrlMapper[CustomActionTestData.ValidUrl.ExistingUrl],
                                                 CustomActionTestData.ValidLabelMapper[CustomActionTestData.ValidLabel.BothEnJa](CustomActionTestData.ValidLabelValueMapper[CustomActionTestData.ValidLabelValue.StringNoSpaceBoth]),
                                                 CustomActionTestData.ValidPlaceValueMapper[CustomActionTestData.ValidPlaceValue.Client]);

            CustomActionTestData.InvalidValueMapper[invalidValue](createRequest, parameterName);
            var hanlder  = new CustomActionManager();
            var response = hanlder.CustomAction <CreateCustomActionResponse>(createRequest, HttpMethod.POST.ToNetHttpMethod());

            if (parameterName == CustomActionTestData.UrlParam && (invalidValue != CustomActionTestData.InvalidValue.MissingParam && invalidValue != CustomActionTestData.InvalidValue.Empty))
            {
                PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK), "Can not create custom action successfully");
                DeleteCustomAction(response.Result.Id);
            }
            else
            {
                PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.BadRequest), "Create custom action successfully");
            }
        }
Exemplo n.º 17
0
        public void UtlTest(string url)
        {
            var response = (new DefaultManager(_settingsConnection)).Send(PrepareUpdateRequest(url), additionalSettings: new DefaultManager.AdditionalRequestSettings
            {
                UrlParameters = new Dictionary <string, string>
                {
                    ["companyId"] = AuthenticationInfoProvider.Current.DefaultPartition,
                }
            });

            PrAssert.That(response, PrIs.SuccessfulResponse(), "Update settings request was not successful.");

            using (var loginResponse = AuthApiConnection.GetConnectionForCurrentTest().SendAsync(CommonConstants.LoginUrl, new Dictionary <string, string> {
                ["companyId"] = AuthenticationInfoProvider.Current.DefaultPartition
            }, System.Net.Http.HttpMethod.Get).Result)
            {
                PrAssert.That(loginResponse.StatusCode, PrIs.EqualTo(System.Net.HttpStatusCode.Redirect), "Wrong HTTP reponse code returned from the server");
                PrAssert.That(loginResponse.Headers.Location.ToString().Contains(url), PrIs.True, "Wrong redirect url in reponse header");
            }
        }
Exemplo n.º 18
0
        public void InvalidInjectionUpdateCustomActionTest(string parameterName, InjectionInput injection)
        {
            var updateRequest = GetUpdateRequest(PrepareData.Data.Id,
                                                 PrepareData.Data.LocalizedTextId,
                                                 CustomActionTestData.ValidUrlMapper[CustomActionTestData.ValidUrl.ExistingUrl],
                                                 CustomActionTestData.ValidLabelMapper[CustomActionTestData.ValidLabel.BothEnJa](CustomActionTestData.ValidLabelValueMapper[CustomActionTestData.ValidLabelValue.StringNoSpaceBoth]));

            updateRequest[parameterName] = InjectionInputData.InjectionInputMapper[injection];
            var hanlder  = new CustomActionManager();
            var response = hanlder.CustomAction <UpdateCustomActionResponse>(updateRequest, HttpMethod.PUT.ToNetHttpMethod());

            if (parameterName == CustomActionTestData.UrlParam)
            {
                PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK), " Can not create custom action");
            }
            else
            {
                PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.BadRequest), "Create custom action successfully");
            }
        }
        public void UpdateOptionValidAlias(OptionAliasData.ValidOptionAlias validType)
        {
            var optionHandler = new OptionManager();
            var childRequest  = OptionAliasData.GetOptionRequestDictionary($"my option {validType.ToString()} child", OptionCreater.Data.Children.Single().Id);

            OptionAliasData.ValidAliasMapper[validType](childRequest, "Child");
            var updateRequest = new Dictionary <string, object>()
            {
                ["alias"]    = OptionAliasData.ValidAliasMapper[validType],
                ["children"] = new List <Dictionary <string, object> >
                {
                    childRequest
                },
            };

            OptionAliasData.ValidAliasMapper[validType](updateRequest, string.Empty);
            var updateResult = optionHandler.UpdateOption(OptionCreater.Data.Id, updateRequest);

            PrAssert.That(updateResult, PrIs.ErrorResponse().And.HttpCode(HttpStatusCode.BadRequest).And.ErrorCode((int)ResultCode.InvalidParameter), "Update Option Successfully");
        }
Exemplo n.º 20
0
        public void ValidUpdateCustomActionTest(CustomActionTestData.ValidUrl url, CustomActionTestData.ValidLabel validLabel, CustomActionTestData.ValidLabelValue validLabelValue)
        {
            var updateRequest = GetUpdateRequest(PrepareData.Data.Id,
                                                 PrepareData.Data.LocalizedTextId,
                                                 CustomActionTestData.ValidUrlMapper[url],
                                                 CustomActionTestData.ValidLabelMapper[validLabel](CustomActionTestData.ValidLabelValueMapper[validLabelValue]));
            var hanlder  = new CustomActionManager();
            var response = hanlder.CustomAction <UpdateCustomActionResponse>(updateRequest, HttpMethod.PUT.ToNetHttpMethod());

            if (validLabel == CustomActionTestData.ValidLabel.BothEnJa)
            {
                PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK), "Can not update custom action");
                var allCustomAction = hanlder.GetAllCustomActions();
                PrAssert.That(allCustomAction.Result[PrepareData.Data.Id].Url, PrIs.EqualTo(CustomActionTestData.ValidUrlMapper[url]), "The url is not as expected");
            }
            else
            {
                PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.BadRequest), "Create update custom action");
            }
        }
Exemplo n.º 21
0
        private static void ValidSpecicalCases(ResourceId resourceId, bool isCustomMenu, SublistMenuTestData.FieldsInput fieldsInput, SublistMenuTestData.LabelValue labelValue)
        {
            var handler  = new HrbcSublistManager();
            var menuId   = isCustomMenu ? SublistMenuTestData.ValidMenuIdMapper[resourceId] : SublistMenuTestData.MenuId[resourceId];
            var sublist  = SublistMenuTestData.GetSublistOfSpecificMenuId(menuId, handler);
            var request  = SublistMenuTestData.GetSublistMenuUpdateRequest(sublist.Id, SublistMenuTestData.GetSublistMenuUpdateIdFields(SublistMenuTestData.ValidFieldMapper[fieldsInput](sublist.IdFields.Enabled)), SublistMenuTestData.GetSublistMenuUpdateLabelValue(SublistMenuTestData.ValidLabelMapper[labelValue]));
            var response = handler.SublistMenu <object>(request, HttpMethod.PUT.ToNetHttpMethod());

            PrAssume.That(response, PrIs.SuccessfulResponse(), "Can not update sublist menu");
            var sublists = handler.SublistsMenu <SublistsMenuResponse>(new Dictionary <string, string> {
                ["menu_id"] = menuId.ToString()
            }, HttpMethod.GET.ToNetHttpMethod());

            PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK), "Can not get sublists menu");
            var specificSublist = sublists.Result.Values.Where(value => value.Value.Id == sublist.Id).Select(dic => dic.Value).SingleOrDefault();

            PrAssert.That(specificSublist.Label.EnUs.Value, PrIs.EqualTo(SublistMenuTestData.ValidLabelMapper[labelValue]), "Value of en_us is not as expected");
            PrAssert.That(specificSublist.Label.Ja.Value, PrIs.EqualTo(SublistMenuTestData.ValidLabelMapper[labelValue]), "Value of ja is not as expected");
            PrAssert.That(specificSublist.IdFields.Enabled, PrIs.EqualTo(SublistMenuTestData.ValidFieldMapper[fieldsInput](sublist.IdFields.Enabled)), "Value of enable is not as expected");
        }
Exemplo n.º 22
0
        public void InvalidUpdateCustomActionTest(string parameterName, CustomActionTestData.InvalidValue invalidValue)
        {
            var updateRequest = GetUpdateRequest(PrepareData.Data.Id,
                                                 PrepareData.Data.LocalizedTextId,
                                                 CustomActionTestData.ValidUrlMapper[CustomActionTestData.ValidUrl.ExistingUrl],
                                                 new Dictionary <string, object>(CustomActionTestData.ValidLabelMapper[CustomActionTestData.ValidLabel.BothEnJa](CustomActionTestData.ValidLabelValueMapper[CustomActionTestData.ValidLabelValue.StringNoSpaceBoth])));

            CustomActionTestData.InvalidValueMapper[invalidValue](updateRequest, parameterName);
            var hanlder  = new CustomActionManager();
            var response = hanlder.CustomAction <UpdateCustomActionResponse>(updateRequest, HttpMethod.PUT.ToNetHttpMethod());

            if (parameterName == CustomActionTestData.UrlParam && (invalidValue != CustomActionTestData.InvalidValue.Empty && invalidValue != CustomActionTestData.InvalidValue.MissingParam))
            {
                PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK), "Can not create custom action successfully");
            }
            else
            {
                PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.BadRequest), "Create custom action successfully");
            }
        }
Exemplo n.º 23
0
        public static void SendAndVerifyRequest(int fieldType, ResourceId resourceId, Properties.Alias alias, Properties.Caption caption, Properties.Search search, Properties.Match match, Properties.Highlight highlight, Properties.Require require, Properties.Default defaultProperty, FileType mimeType, Properties.Height height, string fieldUUID)
        {
            var handler     = new DefaultManager();
            var properties  = GenerateProperties(fieldType, Properties.Label.Max, caption, search, match, highlight, require, defaultProperty, mimeType, height);
            var updateParam = GenerateUpdateParam(resourceId, properties);
            var request     = GenerateRequestUpdate(fieldUUID, updateParam).ToJson();

            PrAssert.That(request, PrIs.Not.EqualTo(string.Empty));
            var response = handler.Send <object>(FieldManager.FieldHandlingRelativeUrl, request, HttpMethod.PUT);

            PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.NoContent), "Can not update Field");
            var fieldHandler = new FieldManager();
            var readResponse = fieldHandler.GetFieldDetails(new Guid(fieldUUID));

            PrAssert.That(readResponse, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK), "Can not Read Field");
            PrAssert.That(readResponse.Result.Values.Count, PrIs.EqualTo(1), "Can not read Field");
            PrAssert.That(readResponse.Result.Values.First().Value.Properties[Properties.PropertyName.SType.GetEnumStringValue()], PrIs.EqualTo($"{fieldType}"), "Not as expected s.type");
            PrAssert.That(readResponse.Result.Values.First().Value.Properties[Properties.PropertyName.Label.GetEnumStringValue()], PrIs.EqualTo(CommonMapperValue.LabelMapperValue[Properties.Label.Max]), "Not as expected d.label.ja");
            VerifyProperties(readResponse.Result.Values.First().Value.Properties, properties);
        }
Exemplo n.º 24
0
        public void ValidCreateMailServer(MailServerTestData.Valid port, MailServerTestData.Valid protocol, MailServerTestData.Valid server, MailServerTestData.Valid ssl)
        {
            var handler = new DefaultManager();
            var request = new Dictionary <string, object>();

            MailServerTestData.ValidIncomingMapperValue[server](request, MailServerTestData.Server);
            MailServerTestData.ValidIncomingMapperValue[port](request, MailServerTestData.Port);
            MailServerTestData.ValidIncomingMapperValue[ssl](request, MailServerTestData.Ssl);
            MailServerTestData.ValidIncomingMapperValue[protocol](request, MailServerTestData.Protocol);
            var response = handler.Send <CreateMailServerResponse>(MailServer.Server, request.ToJson(), HttpMethod.POST);

            PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK), "Can not create mail server");
            var deleteRequest = new Dictionary <string, object>()
            {
                [MailServerTestData.Id] = response.Result.Id
            };
            var delete = handler.Send <object>(MailServer.Server, deleteRequest.ToJson(), HttpMethod.DELETE);

            PrAssert.That(delete, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.NoContent), "Can not delete mail server");
        }
        public void TestInvalidComputeFieldValueMissingFieldValuePairInThreeParams(ResourceId resourceId, Operations op, string fieldValuePair1, string fieldValuePair2, string fieldValuePair3, string targetField)
        {
            var expression = GenerateExpressionByThreeParams(resourceId, op, fieldValuePair1, fieldValuePair2, fieldValuePair3);

            targetField = GetTargetField(resourceId, FieldsCreator, targetField);
            var request = GenerateComputeFieldValueRequest(resourceId, targetField,
                                                           new Dictionary <string, object>
            {
                [$"{resourceId.ToString()}.{fieldValuePair1}"] = 10,
                [$"{resourceId.ToString()}.{fieldValuePair2}"] = 20
            });
            var effectedTerminalField = ReadField(resourceId, targetField);

            UpdateExpressionField(resourceId, effectedTerminalField.ToString(), expression);

            var handler  = new DefaultManager();
            var response = handler.Send <object>(ComputeFieldValueEndPoint, JsonConvert.SerializeObject(request), HttpMethod.POST);

            PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.BadRequest));
        }
Exemplo n.º 26
0
        public void TestUpdateRequireParameterValid(ResourceId resource, TextHelpers.FieldTypes fType, Properties.Label label)
        {
            var guid    = TextHelpers.Guid[fType](resource, FieldsCreator, Defines.FieldTypeApi, TextHelpers.ApplicationFieldNames[Defines.FieldTypeApi]().First());
            var handler = new DefaultManager();
            var props   = new Dictionary <string, object>
            {
                [Properties.PropertyName.Label.GetEnumStringValue()] = CommonMapperValue.LabelMapperValue[label]
            };

            var request  = TextHelpers.GenerateUpdateRequest(resource, guid.ToString(), props);
            var response = handler.Send <object>(FieldManager.FieldHandlingRelativeUrl, JsonConvert.SerializeObject(request), HttpMethod.PUT);

            PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.NoContent));

            //Verify
            var result = (new FieldManager()).GetFieldDetails(guid);

            PrAssert.That(result.Result.Values.SingleOrDefault().Value.Properties[Properties.PropertyName.SType.GetEnumStringValue()], PrIs.EqualTo(((int)Defines.FieldTypeApi).ToString()), "Not as expected s.type");
            PrAssert.That(result.Result.Values.SingleOrDefault().Value.Properties[Properties.PropertyName.Label.GetEnumStringValue()], PrIs.EqualTo(CommonMapperValue.LabelMapperValue[label]), "Not as expected d.label.ja");
        }
        public void TestInvalidBodyJson(OriginalSearchHelpers.InvalidSpecialCondition inputType)
        {
            var handler = new BulkUpdateManager();
            var bulkUpdateContentObject = GetBulkUpdateContent(RecordTypes.Single, Filters.Replace, HRBCClientPrivate.Common.ResourceId.Client, "P_Name", "Test Name", RecordsCreator, Filters.Replace);

            string jsonContent = string.Empty;

            if (inputType == OriginalSearchHelpers.InvalidSpecialCondition.BrokenJsonFormat)
            {
                jsonContent = JsonConvert.SerializeObject(bulkUpdateContentObject).ToString().Substring(1);
            }
            else
            {
                jsonContent = DashboardHelpers.InvalidBodyJsonTestCasesMapper[inputType].ToString();
            }

            var response = handler.BulkUpdate <BulkUpdateResponse>(jsonContent, System.Net.Http.HttpMethod.Post);

            PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.BadRequest));
        }
Exemplo n.º 28
0
        public void UpdateValidRecordWithOwnerTest(TestCoreFramework.Enums.ResourceType resourceId, ResourceFields.ValidPhase phase, ResourceFields.ValidDateTime time)
        {
            var fieldHandler = new FieldManager();
            var fields       = fieldHandler.GetFieldGuid(new List <string>()
            {
                "P_Phase", "P_PhaseDate"
            }, new[] { resourceId })
                               .Result.Result.ToDictionary(x => $"{char.ToUpper(x.Resource[0]) + x.Resource.Substring(1)}.{x.Alias}", x => (int)UuidUtil.GetId(x.Id));
            var recordHandler = new RecordManager();
            var response      = recordHandler.UpdateRecords(
                RecordRequestComposer.ComposeUpdateRequest().Append(item => item.ForResource(resourceId)
                                                                    .Append(x => x.WithId((int)RecordsCreator.Data[resourceId.ToPrivateApiResource()].Id)
                                                                            .AppendFields(new Dictionary <int, object> {
                [fields[$"{resourceId.ToResourceName()}.P_Phase"]] = RootPhaseOption.Data[resourceId], [fields[$"{resourceId.ToResourceName()}.P_PhaseDate"]] = ResourceFields.PhaseTimeMapper[time]
            }))).Result);

            PrAssert.That(response, PrIs.SuccessfulResponse());
            PrAssert.That(response.Result, PrIs.Not.Null);
            PrAssert.That(response.Result.Ids[0][0], PrIs.Not.Null);
        }
Exemplo n.º 29
0
        public void ValidDuplicatePutQueueTest(QueueParam param, Enums.ValidDuplicated duplicated)
        {
            var request = new Dictionary <string, object>
            {
                [QueueParam.Id.ToString().ToLower()]     = $"{PreparedQueueId.Data[ValidQueueTask.Export]}",
                [QueueParam.Status.ToString().ToLower()] = ValidStatus.Interrupted.GetEnumStringValue(),
            };
            var otherValue = new Dictionary <string, object>
            {
                [QueueParam.Id.ToString().ToLower()]     = $"{PreparedQueueId.Data[ValidQueueTask.Import]}",
                [QueueParam.Status.ToString().ToLower()] = ValidStatus.Executing.GetEnumStringValue(),
            };

            request.Add($"{param.GetEnumStringValue()}_dup", duplicated == Enums.ValidDuplicated.SameValue ? request[param.GetEnumStringValue()] : otherValue[param.GetEnumStringValue()]);
            var defaultManager = new DefaultManager();
            var requestJson    = request.ToJson().Replace($"{param.GetEnumStringValue()}_dup", param.GetEnumStringValue());
            var response       = defaultManager.Send <object>(QueueTestCaseData.QueueEndpoint, requestJson, HttpMethod.PUT);

            PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.BadRequest));
        }
Exemplo n.º 30
0
        public void ReadHrbcCoreSessionAccessEndpointTest(AccessState accessState, HttpStatusCode httpStatusCode, ResultCode resultCode)
        {
            var creds                 = AuthenticationInfoProvider.GetAuthSpecForCurrentTest();
            var adminUserId           = creds.Companies.First().Value.Users.First().Metadata["userId"].ToString();
            var companyId             = creds.Companies.First().Value.Id;
            var readSessionHandler    = new HrbcCoreManager();
            var accessEndpointHandler = new AccessEndpointManager();
            var request               = new Dictionary <string, string>()
            {
                ["companyId"] = companyId,
                ["userId"]    = adminUserId,
                ["sessionId"] = readSessionHandler.GetDefaultSessionId(),
            };

            creds.Dispose();

            var response = accessEndpointHandler.AccessEndpoint <HrbcCoreSessionResponse>(accessState, HrbcCoreManager.GetSessionEndpoint, request, System.Net.Http.HttpMethod.Get);

            PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(httpStatusCode), "Still able to access entry api.");
        }