From cc23fd13371edd4ddcccfa970efe9db466baf332 Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 17 May 2023 09:23:37 +0200 Subject: [PATCH] refs #5579 fix mockTimes and remove userLog_add --- db/dump/mockDate.sql | 37 +++- db/dump/structure.sql | 198 +----------------- .../02_alias_create_and_basic_data.spec.js | 2 +- 3 files changed, 34 insertions(+), 203 deletions(-) diff --git a/db/dump/mockDate.sql b/db/dump/mockDate.sql index 79ae05455..b9852a480 100644 --- a/db/dump/mockDate.sql +++ b/db/dump/mockDate.sql @@ -1,12 +1,33 @@ -CREATE SCHEMA IF NOT EXISTS `util`; -USE `util`; - -DELIMITER ;; DROP FUNCTION IF EXISTS `util`.`mockTime`; -CREATE OR REPLACE FUNCTION `util`.`mockTime`() -RETURNS DATETIME -DETERMINISTIC + +DELIMITER $$ +$$ +CREATE DEFINER=`root`@`localhost` FUNCTION `util`.`mockTime`() RETURNS datetime + DETERMINISTIC +BEGIN + RETURN CONVERT_TZ('2001-01-01 11:00:00', 'utc', 'Europe/Madrid'); +END$$ +DELIMITER ; + +DROP FUNCTION IF EXISTS `util`.`mockUtcTime`; + +DELIMITER $$ +$$ +CREATE DEFINER=`root`@`localhost` FUNCTION `util`.`mockUtcTime`() RETURNS datetime + DETERMINISTIC +BEGIN + RETURN CONVERT_TZ('2001-01-01 11:00:00', 'utc', 'Europe/Madrid'); +END$$ +DELIMITER ; + +DROP FUNCTION IF EXISTS `util`.`mockTimeBase`; + +DELIMITER $$ +$$ +CREATE DEFINER=`root`@`localhost` FUNCTION `util`.`mockTimeBase`(vIsUtc BOOL) RETURNS datetime + DETERMINISTIC BEGIN RETURN CONVERT_TZ('2001-01-01 11:00:00', 'utc', 'Europe/Madrid'); -END ;; +END$$ DELIMITER ; + diff --git a/db/dump/structure.sql b/db/dump/structure.sql index 73f88f53e..aff6e5f8f 100644 --- a/db/dump/structure.sql +++ b/db/dump/structure.sql @@ -72,16 +72,11 @@ DELIMITER ;; AFTER INSERT ON `account` FOR EACH ROW BEGIN - CALL `userLog_add`('Account', NEW.id, NEW.id, 'insert', NULL, NULL, - JSON_OBJECT( - 'id', NEW.id - ) - ); - INSERT IGNORE INTO userSync (`name`) SELECT `name` FROM `user` WHERE id = NEW.id; END */;; DELIMITER ; + /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; @@ -115,43 +110,10 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `account`.`account_afterUpdate` - AFTER UPDATE ON `account` - FOR EACH ROW -BEGIN - CALL `userLog_add`('Account', NEW.id, NEW.id, 'update', NULL, - JSON_OBJECT( - 'id', OLD.id - ), - JSON_OBJECT( - 'id', NEW.id - ) - ); -END */;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `account`.`account_afterDelete` AFTER DELETE ON `account` FOR EACH ROW BEGIN - INSERT INTO userLog - SET `action` = 'delete', - `changedModel` = 'Account', - `changedModelId` = OLD.id, - `userFk` = account.myUser_getId(); - INSERT IGNORE INTO userSync (`name`) SELECT `name` FROM `user` WHERE id = OLD.id; END */;; @@ -281,32 +243,7 @@ BEGIN SET NEW.editorFk = account.myUser_getId(); END */;; DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `account`.`mailAlias_afterInsert` - AFTER INSERT ON `mailAlias` - FOR EACH ROW -BEGIN - CALL `userLog_add`('MailAlias', NEW.id, NEW.id, 'insert', NULL, NULL, - JSON_OBJECT( - 'alias', NEW.alias, - 'description', NEW.description, - 'isPublic', NEW.isPublic - ) - ); -END */;; -DELIMITER ; + /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; @@ -340,37 +277,6 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `account`.`mailAlias_afterUpdate` - AFTER UPDATE ON `mailAlias` - FOR EACH ROW -BEGIN - CALL `userLog_add`('MailAlias', NEW.id, NEW.id, 'update', NULL, - JSON_OBJECT( - 'alias', OLD.alias, - 'description', OLD.description, - 'isPublic', OLD.isPublic - ), - JSON_OBJECT( - 'alias', NEW.alias, - 'description', NEW.description, - 'isPublic', NEW.isPublic - ) - ); -END */;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `account`.`mailAlias_afterDelete` AFTER DELETE ON `mailAlias` FOR EACH ROW @@ -441,6 +347,7 @@ CREATE TABLE `mailConfig` ( -- Table structure for table `mailForward` -- + DROP TABLE IF EXISTS `mailForward`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; @@ -490,30 +397,7 @@ BEGIN SET NEW.editorFk = account.myUser_getId(); END */;; DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `account`.`mailForward_afterDelete` - AFTER DELETE ON `mailForward` - FOR EACH ROW -BEGIN - INSERT INTO userLog - SET `action` = 'delete', - `changedModel` = 'MailForward', - `changedModelId` = OLD.account, - `userFk` = account.myUser_getId(); -END */;; -DELIMITER ; + /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; @@ -967,34 +851,7 @@ BEGIN END */;; DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `account`.`user_afterDelete` - AFTER DELETE ON `user` - FOR EACH ROW -BEGIN - INSERT INTO userLog - SET `action` = 'delete', - `changedModel` = 'User', - `changedModelId` = OLD.id, - `userFk` = account.myUser_getId(); - CALL hedera.image_unref('user', OLD.image); - - INSERT IGNORE INTO userSync SET `name` = OLD.`name`; -END */;; -DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; @@ -2397,54 +2254,7 @@ BEGIN FLUSH PRIVILEGES; END ;; DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `userLog_add` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `userLog_add`( - vChangedModel VARCHAR(45), - vOriginFk INT, - vChangedModelId INT, - vActionCode VARCHAR(45), - vChangedModelValue VARCHAR(255), - vOldInstance JSON, - vNewInstance JSON) -BEGIN -/** - * Guarda las acciones realizadas por el usuario - * - * @param vChangedModel Nombre que hace referencia a la tabla que se modifica - * @param vOriginFk Id del registro de la tabla origen - * @param vChangedModelId Id del registro de la tabla a la que se realiza la acción - * @param vActionCode Código de la acción {insert | delete | update} - * @param vOldInstance JSON que contiene los valores viejos - * @param vNewInstance JSON que contiene los valores nuevos - */ - CALL util.log_cleanInstances(vActionCode, vOldInstance, vNewInstance); - IF !(vOldInstance = '{}' AND vNewInstance = '{}') THEN - INSERT INTO userLog SET - changedModel = vChangedModel, - originFk = vOriginFk, - changedModelId = vChangedModelId, - `action` = vActionCode, - changedModelValue = vChangedModelValue, - oldInstance = vOldInstance, - newInstance = vNewInstance, - userFk = account.myUser_getId(); - END IF; -END ;; -DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; diff --git a/e2e/paths/14-account/02_alias_create_and_basic_data.spec.js b/e2e/paths/14-account/02_alias_create_and_basic_data.spec.js index 78a17d353..dd35dd740 100644 --- a/e2e/paths/14-account/02_alias_create_and_basic_data.spec.js +++ b/e2e/paths/14-account/02_alias_create_and_basic_data.spec.js @@ -1,7 +1,7 @@ import selectors from '../../helpers/selectors.js'; import getBrowser from '../../helpers/puppeteer'; -fdescribe('Account Alias create and basic data path', () => { +describe('Account Alias create and basic data path', () => { let browser; let page;