Ejemplo n.º 1
0
        public void BigArrayObjectWithJsonShoulNotdMakeServerHang(string mediaType)
        {
            //Console.WriteLine(this.Client.GetStringAsync(this.BaseAddress + "/$metadata").Result);

            var           model      = new Security_ArrayModel();
            List <string> stringList = new List <string>();
            List <Security_ComplexModel> complexList    = new List <Security_ComplexModel>();
            List <Security_NestedModel>  navigationList = new List <Security_NestedModel>();

            for (int i = 0; i < 10000; i++)
            {
                stringList.Add(string.Empty);
                complexList.Add(new Security_ComplexModel());
                navigationList.Add(new Security_NestedModel());
            }
            model.StringArray          = stringList;
            model.ComplexArray         = complexList;
            model.NavigationCollection = navigationList;

            HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, this.BaseAddress + "/Security_ArrayModel");

            request.Content = new ObjectContent <Security_ArrayModel>(model, new JsonMediaTypeFormatter(), MediaTypeHeaderValue.Parse(mediaType));
            var response = this.Client.SendAsync(request).Result;

            response.EnsureSuccessStatusCode();
        }
Ejemplo n.º 2
0
        public void BigDataServiceVersionHeaderShouldBeRejected()
        {
            var model = new Security_ArrayModel();

            AttackStringBuilder asb = new AttackStringBuilder();

            asb.Append("3.0").Repeat("0", 100000);
            HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, this.BaseAddress + "/Security_ArrayModel");

            request.Content = new ObjectContent <Security_ArrayModel>(model, new JsonMediaTypeFormatter(), MediaTypeHeaderValue.Parse("application/json"));
            request.Headers.Add("DataServiceVersion", asb.ToString());
            var response = this.Client.SendAsync(request).Result;

            Assert.False(response.IsSuccessStatusCode);
        }
Ejemplo n.º 3
0
        public void BigArrayObjectWithAtomShoulNotdMakeServerHang()
        {
            //Console.WriteLine(this.Client.GetStringAsync(this.BaseAddress + "/$metadata").Result);

            var           model      = new Security_ArrayModel();
            List <string> stringList = new List <string>();
            List <Security_ComplexModel> complexList    = new List <Security_ComplexModel>();
            List <Security_NestedModel>  navigationList = new List <Security_NestedModel>();

            for (int i = 0; i < 10000; i++)
            {
                stringList.Add(string.Empty);
                complexList.Add(new Security_ComplexModel());
                navigationList.Add(new Security_NestedModel());
            }
            model.StringArray          = stringList;
            model.ComplexArray         = complexList;
            model.NavigationCollection = navigationList;

            DataServiceContext ctx = new DataServiceContext(new Uri(this.BaseAddress), DataServiceProtocolVersion.V3);

            ctx.AddObject("Security_ArrayModel", model);
            ctx.SaveChanges();
        }