Пример #1
0
        public PrivateApiResponse <object> SendRequestWithIdentityHeader(object content, string headerName, string headerValue, HttpMethod httpMethod, string contentType = "application/json")
        {
            string contentString = ConvertToJsonString(content);

            using (LogHelper.LoggerForCurrentTest.EnterReproStep($"Send request that contains X-IDENTITY header with {InternalTestEndpoint}"))
            {
                InternalConnection.DeleteAllCookies();
                InternalConnection.Headers.Clear();
                InternalConnection.Headers.Add(headerName, headerValue);
                return(ProcessResponseWithContent <object>(InternalConnection.SendAsync(InternalTestEndpoint, contentString, httpMethod, contentType).Result));
            }
        }
Пример #2
0
        public PrivateApiResponse <T> LoginAndSendRequestWithOtherAccount <T>(string companyLoginId, string username, string password, string endpoint, IEnumerable <KeyValuePair <string, string> > request, HttpMethod httpMethod = null)
        {
            var connection = new PrivateApiConnection();

            connection.Authenticate(companyLoginId, username, password);
            return(ProcessResponseWithContent <T>(connection.SendAsync(endpoint, request, httpMethod).Result));
        }
Пример #3
0
        public PrivateApiResponse <T> LoginAndSendRequestWithOtherAccount <T>(string companyLoginId, string username, string password, string endpoint, object request, HttpMethod httpMethod = null)
        {
            var connection = new PrivateApiConnection();

            connection.Authenticate(companyLoginId, username, password);
            var contentString = ConvertToJsonString(request);

            return(ProcessResponseWithContent <T>(connection.SendAsync(endpoint, contentString, httpMethod == null ? HttpMethod.Post : httpMethod).Result));
        }
Пример #4
0
 public PrivateApiResponse<T> ForcePasswordChangeDiffUser<T>(string companyName, string userName, string userPassword, object content, HttpMethod httpMethod, string contentType = "application/json")
 {
     connection.DeAuthenticate();
     connection.Authenticate(companyName, userName, userPassword);
     string contentString = ConvertToJsonString(content);
     using (LogHelper.LoggerForCurrentTest.EnterReproStep($"Force password change with {ForceEndpoint}"))
     {
         return ProcessResponseWithContent<T>(connection.SendAsync(ForceEndpoint, contentString, httpMethod, contentType).Result);
     }
 }
Пример #5
0
        public void ValidResponseDataTypeTest()
        {
            var request = CreateGetRequest(TypeMapper[ValidTypes.Activity], UnixDateMapper[ValidDates.Min].ToString(), UnixDateMapper[ValidDates.Max].ToString());

            request[ParamMapper[Params.User]] = UserAdmin.ToString();
            var connection = new PrivateApiConnection();
            var resultTest = connection.SendAsync(CalendarHelper.calendarEndpoint, request, System.Net.Http.HttpMethod.Get).Result;

            PrAssert.That(resultTest.IsSuccessStatusCode, PrIs.True);
            PrAssert.That(resultTest.Content.Headers.ContentType.MediaType, PrIs.EqualTo("application/json"));
        }
Пример #6
0
        public PrivateApiResponse <List <OptionWriteResponse> > WriteOptionAccessEndpoint(int id, Dictionary <string, object> fields, PrivateApiConnection connect)
        {
            var request = new List <Dictionary <string, object> >
            {
                new Dictionary <string, object>(fields)
                {
                    ["id"] = id,
                }
            };

            var requestString = ConvertToJsonString(request);

            using (var step = LogHelper.LoggerForCurrentTest.EnterReproStep($"Writing option"))
            {
                return(ProcessResponseWithContent <List <OptionWriteResponse> >(connect.SendAsync(OptionUpdateEndpoint, requestString, HttpMethod.Post).Result));
            }
        }