Пример #1
0
        public IList <string> FindRolesByServiceAndControllerAndAction(string service, string controller, string action)
        {
            var headers = new List <Header>();

            foreach (var header in this.HttpContextAccessor.HttpContext.Request.Headers)
            {
                headers.Add(new Header {
                    Key = header.Key, Value = header.Value
                });
            }
            var response = RestfulUtility.Get <PayloadResponseDto <IList <string> > >($"{this.SecurityConfig.Protocol}://{this.SecurityConfig.Host}:{this.SecurityConfig.Port}/api/security/{service}/{controller}/{action}", headers);

            return(response.Payload);
        }
Пример #2
0
        //[TestMethod]
        public void TestPerformance()
        {
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            for (int index = 0; index < 200; index++)
            {
                string url            = $"https://raw.githubusercontent.com/FewBox/fewbox.github.io/master/version.json";
                var    response       = RestfulUtility.Get <Object>(url, new List <Header> {
                });
                string responseString = response.ToString();
                Assert.IsNotNull(responseString);
            }
            stopwatch.Stop();
            Assert.IsTrue(stopwatch.ElapsedMilliseconds < 5000);
        }
Пример #3
0
 //[TestMethod]
 public void TestAuthUtility()
 {
     var result = RestfulUtility.Get <PayloadResponseDto <IList <string> > >($"http://116.196.120.216/api/auth/Auth/Nodes/Get", new List <Header> {
         new Header {
             Key = "Connection", Value = "keep-alive"
         },
         new Header {
             Key = "Content-Type", Value = "application/json"
         },
         new Header {
             Key = "Accept", Value = "application/json"
         },
         new Header {
             Key = "Accept-Encoding", Value = "gzip, deflate, br"
         },
         new Header {
             Key = "Accept-Language", Value = "en-US,en;q=0.9,zh-CN;q=0.8,zh;q=0.7"
         },
         new Header {
             Key = "Authorization", Value = "null"
         },
         new Header {
             Key = "Host", Value = "localhost:5001"
         },
         new Header {
             Key = "Referer", Value = "http://localhost/master/node"
         },
         new Header {
             Key = "User-Agent", Value = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36"
         },
         new Header {
             Key = "Origin", Value = "http://localhost"
         },
         new Header {
             Key = "Sec-Fetch-Mode", Value = "cors"
         },
         new Header {
             Key = "Sec-Fetch-Site", Value = "same-site"
         }
     });
     //Assert.Fail(result);
 }