コード例 #1
0
 public void CanCreateAndSet() {
     var logon = _container.Get<ILogonService>();
     var req = new HttpRequestDescriptor {
         User = new GenericPrincipal(logon.Logon("fuser", Fpass), null),
         UserAgent = "testagent",
         RemoteEndPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"),3456 )
     };
     var hts = _container.Get<IHttpTokenService>();
     var token = hts.Create(req);
     Assert.True(hts.IsValid(req,token));
     var res = new HttpResponseDescriptor();
     hts.Store(res,new Uri("http://my.best.com"),token);
     var cookie = res.Cookies["testauth"];
     Assert.NotNull(cookie);
     Assert.True(cookie.Secure);
     Assert.True(cookie.HttpOnly);
     Assert.AreEqual(".best.com",cookie.Domain);
     Assert.AreEqual("/",cookie.Path);
     Assert.Less(100,cookie.Value.Length);
 }
コード例 #2
0
ファイル: HostUtils.cs プロジェクト: Qorpent/qorpent.sys
        public static string Call(this IHostServer host, string command)
        {
            var h  = host.GetHandler(command);
            var ms = new MemoryStream();
            var rs = new HttpResponseDescriptor {
                Stream = ms, NoCloseStream = true
            };
            var rq = new HttpRequestDescriptor {
                Uri = new Uri("http://localhost" + command)
            };

            var ctx = new WebContext {
                Request = rq, Response = rs
            };

            h.Run(host, ctx, null, new CancellationToken());
            var len = ms.Position;

            ms.Position = 0;
            var result = Encoding.UTF8.GetString(ms.GetBuffer(), 0, (int)len);

            return(result);
        }
コード例 #3
0
        public void CanCreateAndSet()
        {
            var logon = _container.Get <ILogonService>();
            var req   = new HttpRequestDescriptor {
                User           = new GenericPrincipal(logon.Logon("fuser", Fpass), null),
                UserAgent      = "testagent",
                RemoteEndPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 3456)
            };
            var hts   = _container.Get <IHttpTokenService>();
            var token = hts.Create(req);

            Assert.True(hts.IsValid(req, token));
            var res = new HttpResponseDescriptor();

            hts.Store(res, new Uri("http://my.best.com"), token);
            var cookie = res.Cookies["testauth"];

            Assert.NotNull(cookie);
            Assert.True(cookie.Secure);
            Assert.True(cookie.HttpOnly);
            Assert.AreEqual(".best.com", cookie.Domain);
            Assert.AreEqual("/", cookie.Path);
            Assert.Less(100, cookie.Value.Length);
        }
コード例 #4
0
ファイル: HostUtils.cs プロジェクト: Qorpent/qorpent.sys
	    public static string Call(this IHostServer host, string command) {
            var h = host.GetHandler(command);
            var ms = new MemoryStream();
            var rs = new HttpResponseDescriptor { Stream = ms, NoCloseStream = true };
            var rq = new HttpRequestDescriptor { Uri = new Uri("http://localhost" + command) };

	        var ctx = new WebContext{Request = rq,Response=rs};
            h.Run(host, ctx, null, new CancellationToken());
            var len = ms.Position;
            ms.Position = 0;
            var result = Encoding.UTF8.GetString(ms.GetBuffer(), 0, (int)len);
            return result;
	    }