public void SendAnalytics() { LogRequestDTO newLog = new LogRequestDTO(); LoggingService _ls = new LoggingService(); newLog.setSource(DTO.Constants.Constants.Sources.Session); newLog.details = "testing stacktrace"; Random rand = new Random(); for (var i = 0; i < 20; i++) { User newUser = CreateUserObject(); Session newSession = CreateSessionObject(newUser); CreateSessionInDb(newSession); newLog.ssoUserId = newUser.Id.ToString(); newLog.setPage(DTO.Constants.Constants.Pages.PointDetails); for (var j = 0; j < 3; j++) { var month = rand.Next(8, 12); newLog.logCreatedAt = new DateTime(2018, 12, 21); newLog.setSource(DTO.Constants.Constants.Sources.Login); var pageDuration = rand.Next(1, 600); newLog.pageDuration = pageDuration; if (j == 0) { newLog.setSource(DTO.Constants.Constants.Sources.Registration); newLog.setPage(DTO.Constants.Constants.Pages.MapView); } var duration = rand.Next(1, 1000); if (duration < 300) { newLog.setPage(DTO.Constants.Constants.Pages.AdminDashboard); } else if (duration < 500) { newLog.setPage(DTO.Constants.Constants.Pages.PointDetails); } else if (duration < 700) { newLog.setPage(DTO.Constants.Constants.Pages.PointEditor); } newLog.sessionCreatedAt = newSession.CreatedAt; newLog.sessionExpiredAt = newSession.ExpiresAt.AddSeconds(duration); newLog.sessionUpdatedAt = newSession.UpdatedAt.AddSeconds(duration); newLog.token = newSession.Token; newLog = (LogRequestDTO)getLogContent(newLog); _ls.sendLogSync(newLog); } } }
public void invalidLogRequestDTO() { newLog = new LogRequestDTO(); newLog.details = "Test details"; newLog.setSource(DTO.Constants.Constants.Sources.Session); newLog = (LogRequestDTO)_tu.getLogContent(newLog); Assert.IsFalse(newLog.isValid()); //No userId }
public void sendLogSyncFail() { newLog = new LogRequestDTO(); newLog.setSource(DTO.Constants.Constants.Sources.Logout); Assert.IsFalse(logger.sendLogSync(newLog));//Missing userId newLog = new LogRequestDTO(); newLog.ssoUserId = newUser.Id.ToString(); Assert.IsFalse(logger.sendLogSync(newLog)); //Missing source }
public async Task sendLogAsyncFail() { newLog = new LogRequestDTO(); newLog.setSource(DTO.Constants.Constants.Sources.Logout); Assert.IsFalse(logger.sendLogSync(newLog)); Assert.IsFalse(await logger.sendLogAsync(newLog)); //Missing UserId newLog = new LogRequestDTO(); newLog.ssoUserId = newUser.Id.ToString(); Assert.IsFalse(logger.sendLogSync(newLog)); Assert.IsFalse(await logger.sendLogAsync(newLog)); //Missing Source }
public void LogSyncResponse401() { newLog = new LogRequestDTO(); newLog.setSource(DTO.Constants.Constants.Sources.AdminDashboard); newLog.details = "testing stacktrace"; newLog.ssoUserId = newUser.Id.ToString(); newLog.sessionCreatedAt = newSession.CreatedAt; newLog.sessionExpiredAt = newSession.ExpiresAt; newLog.sessionUpdatedAt = newSession.UpdatedAt; newLog.token = newSession.Token; //Missing signature and timestamp var responseStatus = _ls.sendLogSync(newLog); Assert.AreEqual(responseStatus, System.Net.HttpStatusCode.Unauthorized); }
public async Task LogAsyncResponse200() { newLog = new LogRequestDTO(); newLog.setSource(DTO.Constants.Constants.Sources.AdminDashboard); newLog.details = "testing stacktrace"; newLog.ssoUserId = newUser.Id.ToString(); newLog.sessionCreatedAt = newSession.CreatedAt; newLog.sessionExpiredAt = newSession.ExpiresAt; newLog.sessionUpdatedAt = newSession.UpdatedAt; newLog.token = newSession.Token; newLog = (LogRequestDTO)_tu.getLogContent(newLog); //[signature, timestamp] var responseStatus = await _ls.sendLogAsync(newLog); Assert.AreEqual(responseStatus, System.Net.HttpStatusCode.OK); }
public void dontNotifySystemAdmin() { newLog = new LogRequestDTO(); newLog.setSource(DTO.Constants.Constants.Sources.AdminDashboard); newLog.details = "testing stacktrace"; newLog.ssoUserId = newUser.Id.ToString(); newLog.sessionCreatedAt = newSession.CreatedAt; newLog.sessionExpiredAt = newSession.ExpiresAt; newLog.sessionUpdatedAt = newSession.UpdatedAt; newLog.token = newSession.Token; newLog = (LogRequestDTO)_tu.getLogContent(newLog); //[signature, timestamp] var content = _ls.getLogContent(newLog); bool adminNotified = _ls.notifyAdmin(System.Net.HttpStatusCode.OK, content); Assert.IsTrue(adminNotified); }