private string GetTestUser(string name) { using (var context = new DbDataContext(_conf.ConnectionStrings.Deployer)) { context.Users.InsertOnSubmit(new User { Login = name, Password = name }); context.SubmitChanges(); } return name; }
public override void Validate(string userName, string password) { _logger.Info(string.Format("User '{0}' is trying to access to service", userName)); var connString = ConfigurationManager.ConnectionStrings["deployer"].ConnectionString; using (var context = new DbDataContext(connString)) if (!context.Users.Any(u => u.Login.Equals(userName) && u.Password.Equals(password))) { _logger.Info(string.Format("Access for user '{0}' is denied", userName)); throw new SecurityTokenValidationException("User validation is failed."); } else _logger.Info(string.Format("Access for user '{0}' is granted", userName)); }
public void RemoveTestData() { using (var context = new DbDataContext(_conf.ConnectionStrings.Deployer)) { var deploy = context.Deploys.Single(d => d.SessionKey == _conf.SessionKey); var user = context.Users.Single(u => u.Login == _user); context.Deploys.DeleteOnSubmit(deploy); context.Users.DeleteOnSubmit(user); context.SubmitChanges(); } }
public void DeploySessionAutoFixationWithExceptionTest() { using (var context = new DbDataContext(_conf.ConnectionStrings.Deployer)) { try { using (var session = new Session(_conf, _user)) { throw new Exception("Wow, something is happaned."); } } catch (Exception) { } var deploy = context.Deploys.Single(d => d.SessionKey == _conf.SessionKey); Assert.NotNull(deploy); Assert.NotNull(deploy.EndUtc); Assert.That(deploy.Status, Is.EqualTo((int) DeployStatusModel.Failed)); } }
public void DeploySessionFixationTest() { var session = new Session(_conf, _user); using (var context = new DbDataContext(_conf.ConnectionStrings.Deployer)) { var deploy = context.Deploys.Single(d => d.SessionKey == _conf.SessionKey); Assert.Null(deploy.EndUtc); Assert.NotNull(deploy.StartUtc); } session.Close(); using (var context = new DbDataContext(_conf.ConnectionStrings.Deployer)) { var deploy = context.Deploys.Single(d => d.SessionKey == _conf.SessionKey); Assert.NotNull(deploy.EndUtc); } }
public void DeploySessionAutoFixationTest() { using (var context = new DbDataContext(_conf.ConnectionStrings.Deployer)) { Deploy deploy; using (var session = new Session(_conf, _user)) { deploy = context.Deploys.Single(d => d.SessionKey == _conf.SessionKey); Assert.That(deploy.Status, Is.EqualTo((int) DeployStatusModel.InProcess)); Assert.Null(deploy.EndUtc); Assert.NotNull(deploy.StartUtc); session.Commit(); } context.Refresh(RefreshMode.OverwriteCurrentValues, context.Deploys); Assert.NotNull(deploy); Assert.NotNull(deploy.EndUtc); Assert.That(deploy.Status, Is.EqualTo((int) DeployStatusModel.Succeed)); } }
public ActionResult Index() { var connString = ConfigurationManager.ConnectionStrings["deployer"].ConnectionString; List<DeployRecord> deployRecords; using (var context = new DbDataContext(connString)) deployRecords = (from deploy in context.Deploys let exceptions = context.Exceptions.Where(e => deploy.Id == e.DeployId).ToList() orderby deploy.Id descending select new DeployRecord { Name = deploy.SurveyName, User = deploy.User, Key = deploy.SessionKey, Start = deploy.StartUtc, End = deploy.EndUtc, Status = (DeployStatusModel)deploy.Status, Mode = (DeployMode)deploy.Mode, Exceptions = exceptions.Select(e => ExceptionRecord.FromXml(e.ExceptionData)).ToList() }).Take(30).ToList(); return View(deployRecords); }