Home Products Download Learn Buy Now Why Typemock? Support & Community About
Community > Forum
 FAQFAQ    SearchSearch   RegisterRegister   RssRss   ProfileProfile   Log inLog in 

Ivonna, session state problem

 
Post new topic   Reply to topic    Typemock Forum Index -> Bugs
View previous topic :: View next topic  
Author Message
pma
Newbie
Newbie


Joined: 15 Jun 2010
Posts: 8

PostPosted: Tue Jun 15, 2010 10:06 am    Post subject: Ivonna, session state problem Reply with quote

Hi,

I'm having a problem with disappearing session state between requests.

There is an ancient topic regarding the subject (How to simulate session?) and test case presented there works fine.

However, test fails when I issue an extra request. It seems that Session_Start event is triggered one more time and test fails:
Code:

[Test, Isolated]
public void KeepsSessionValuesAcrossMultipleRequests2()
{
   TestSession session = new TestSession();
   WebRequest request = new WebRequest("test/Page1.aspx");
   request.EventHandlers.Page_PreInit = delegate(object sender, System.EventArgs e)
   {
      HttpSessionState httpsession = HttpContext.Current.Session;
      httpsession["test"] = "testvalue";
   };
   session.ProcessRequest(request); //1st Session_Start

   request = new WebRequest("test/Page1.aspx");
   request.EventHandlers.Page_PreInit = delegate(object sender, System.EventArgs e)
   {
      HttpSessionState httpsession = HttpContext.Current.Session;
      Assert.AreEqual("testvalue", httpsession["test"], "Invalid session value");
   };
   session.ProcessRequest(request);

   WebRequest thirdRequest = new WebRequest("test/Page1.aspx");
   thirdRequest.EventHandlers.Page_PreInit = delegate(object sender, System.EventArgs e)
   {
      HttpSessionState httpsession = HttpContext.Current.Session;
      Assert.AreEqual("testvalue", httpsession["test"], "Invalid session value on 3rd request");
   };

   session.ProcessRequest(thirdRequest); //2nd Session_Start, session is empty - test fails
}


It seems that cookie containing session state id is not sent to server. Am I doing something wrong here?

I'm running Ivonna 2.1.1.22205 and TypeMock Isolator 6.0.3.0.

Thanks,
Back to top
View user's profile Send private message
ulu
Advanced
Advanced


Joined: 18 Apr 2007
Posts: 15

PostPosted: Wed Jun 16, 2010 10:51 am    Post subject: Reply with quote

Hi,

You have discovered a bug in Ivonna. The problem is that the authentication cookie is not being sent with the third request.

I'll publish the fix today and let you know.

Artem
Back to top
View user's profile Send private message
ulu
Advanced
Advanced


Joined: 18 Apr 2007
Posts: 15

PostPosted: Wed Jun 16, 2010 8:26 pm    Post subject: Reply with quote

You can download the fixed version at http://budurl.com/ivdl
Back to top
View user's profile Send private message
pma
Newbie
Newbie


Joined: 15 Jun 2010
Posts: 8

PostPosted: Thu Jul 08, 2010 4:53 pm    Post subject: Reply with quote

Hi,

Fix works perfectly, but there seems to be a problem when application adds additional cookies to response.

Please take a look at test:
Code:

[Test, Isolated]
public void CookiesWrittenOnFirstRequestShouldBeAvailableOnSecondRequest()
{
   const string url = "/testpage.aspx";         
   const string additionalCookieName = "mc_1";
   var session = new TestSession();
   session.SetUser("foo", new string[0]);

   var sessionKeyFromFirstRequest = "";
   var firstRequest = new WebRequest(url);
   firstRequest.EventHandlers.Page_PreRender += (s, e) =>
   {
      var page = (Page) s;
      sessionKeyFromFirstRequest = page.Session.SessionID;

      var newCookie = new HttpCookie(additionalCookieName);
      newCookie.Values.Add("10394", "1");
      page.Response.Cookies.Add(newCookie);
   };

   session.ProcessRequest(firstRequest);

   var secondRequest = new WebRequest(url);
   secondRequest.EventHandlers.Page_Init += (s, e) =>
   {
      var page = (Page)s;
      var cookieHeaders = "Cookie header: " + page.Request.Headers["Cookie"].ToString();
      Assert.AreEqual(sessionKeyFromFirstRequest, page.Session.SessionID, cookieHeaders);
      Assert.NotNull(page.Request.Cookies[additionalCookieName], cookieHeaders);            
   };
   session.ProcessRequest(secondRequest);
}



It seems like there is a problem when cookies are sent back to ASP .NET.

E.g. cookie header instead of:
Cookie: ASP.NET_SessionId=51pncynqyhc3iy452ny1cnmm; mc_1=10394

looks like:
Cookie: ASP.NET_SessionId=51pncynqyhc3iy452ny1cnmm:mc_1=10394

Note ':' instead of '; '
This totally confuses ASP .NET, session starts again and 'mc_1' cookie gets overwritten.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Typemock Forum Index -> Bugs All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group