Ejemplo n.º 1
0
 /// <summary>
 /// Set the maestrano user in session
 /// </summary>
 public void SetSession(HttpSessionState httpSessionObj, User user)
 {
     var mnoSession = new Session(httpSessionObj, user);
     mnoSession.Save();
 }
Ejemplo n.º 2
0
        public void Save_ItShouldSaveTheMaestranoSessionInHttpSession()
        {
            // Http context
            var recheck = DateTime.UtcNow.AddMinutes(1);
            Helpers.injectMnoSession(recheck);
            var httpSession = Helpers.FakeHttpSessionState();

            // Create Mno session and save it
            Session mnoSession = new Session(httpSession);
            mnoSession.SessionToken = "anothertoken";
            mnoSession.Save();

            // Decrypt session and test
            var enc = System.Text.Encoding.UTF8;
            var json = enc.GetString(Convert.FromBase64String(httpSession["maestrano"].ToString()));
            var mnoObj = JObject.Parse(json);

            Assert.AreEqual(mnoSession.SessionToken, mnoObj.Value<String>("session"));
            Assert.AreEqual(mnoSession.Uid, mnoObj.Value<String>("uid"));
            Assert.AreEqual(mnoSession.GroupUid, mnoObj.Value<String>("group_uid"));
            Assert.AreEqual(mnoSession.Recheck, mnoObj.Value<DateTime>("session_recheck"));
        }