From 9f9f6a449f28fb932ab2ddd6fb0eec22e4239b66 Mon Sep 17 00:00:00 2001
From: Timm Fitschen <t.fitschen@indiscale.com>
Date: Wed, 18 Oct 2023 17:20:01 +0200
Subject: [PATCH] TST: upgrade tests

---
 Makefile                  |  1 +
 procedures/insertUser.sql | 43 ----------------------
 tests/example.dump.sql    | 76 ---------------------------------------
 tests/test_autotap.sql    |  7 ----
 4 files changed, 1 insertion(+), 126 deletions(-)
 delete mode 100644 procedures/insertUser.sql

diff --git a/Makefile b/Makefile
index 544c0b6..efe8b68 100644
--- a/Makefile
+++ b/Makefile
@@ -88,4 +88,5 @@ pipeline-test:
 	sleep 10
 	make install
 	./utils/make_db restore_db tests/example.dump.sql
+	make upgrade
 	./tests/test_utils.sh
diff --git a/procedures/insertUser.sql b/procedures/insertUser.sql
deleted file mode 100644
index 4f2f01e..0000000
--- a/procedures/insertUser.sql
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * ** header v3.0
- * This file is a part of the CaosDB Project.
- *
- * Copyright (C) 2018 Research Group Biomedical Physics,
- * Max-Planck-Institute for Dynamics and Self-Organization Göttingen
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- *
- * ** end header
- */
-
-Drop Procedure if exists db_5_0.insertUser;
-Delimiter //
-Create Procedure db_5_0.insertUser(in Name VARCHAR(255), in Password VARCHAR(255))
-
-BEGIN 
-
-
-INSERT INTO entities (name, role, acl) VALUES (Name, 'USER', 0);
-
-SET @LAST_UserID = LAST_INSERT_ID();
-
-INSERT INTO passwords VALUES (@LAST_UserID, Password);
-
-Select @LAST_UserID as UserID; 
-
-END;
-//
-
-
-delimiter ;
diff --git a/tests/example.dump.sql b/tests/example.dump.sql
index cad5a03..441e9da 100644
--- a/tests/example.dump.sql
+++ b/tests/example.dump.sql
@@ -563,31 +563,6 @@ INSERT INTO `passwd` VALUES ('guest','3fe82ca86837d4f9ff765d2d4265ded96843314936
 /*!40000 ALTER TABLE `passwd` ENABLE KEYS */;
 UNLOCK TABLES;
 
---
--- Table structure for table `passwords`
---
-
-DROP TABLE IF EXISTS `passwords`;
-/*!40101 SET @saved_cs_client     = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `passwords` (
-  `entity_id` int(10) unsigned NOT NULL COMMENT 'User ID.',
-  `password` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT 'Password.',
-  PRIMARY KEY (`entity_id`),
-  CONSTRAINT `use_entity_id_entity` FOREIGN KEY (`entity_id`) REFERENCES `entities` (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-/*!40101 SET character_set_client = @saved_cs_client */;
-
---
--- Dumping data for table `passwords`
---
-
-LOCK TABLES `passwords` WRITE;
-/*!40000 ALTER TABLE `passwords` DISABLE KEYS */;
-INSERT INTO `passwords` VALUES (98,'37d7bd8a833261b4e4653644ee0a065f522b92b3738ca9ae2cb43a83844bf352c4a59c386a44965997a508c61988c9484c093775027425091d6d3d435c3c0e0c'),(99,'37d7bd8a833261b4e4653644ee0a065f522b92b3738ca9ae2cb43a83844bf352c4a59c386a44965997a508c61988c9484c093775027425091d6d3d435c3c0e0c');
-/*!40000 ALTER TABLE `passwords` ENABLE KEYS */;
-UNLOCK TABLES;
-
 --
 -- Table structure for table `permissions`
 --
@@ -2783,34 +2758,6 @@ BEGIN
 
     INSERT IGNORE INTO units_lin_con (signature_from, signature_to, a, b_dividend, b_divisor, c) VALUES (signature_from, signature_to, a, b_dividend, b_divisor, c);
 
-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 `insertUser` */;
-/*!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_general_ci */ ;
-/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
-/*!50003 SET sql_mode              = 'STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
-DELIMITER ;;
-CREATE DEFINER=`caosdb`@`%` PROCEDURE `insertUser`(in Name VARCHAR(255), in Password VARCHAR(255))
-BEGIN 
-
-
-INSERT INTO entities (name, role, acl) VALUES (Name, 'USER', 0);
-
-SET @LAST_UserID = LAST_INSERT_ID();
-
-INSERT INTO passwords VALUES (@LAST_UserID, Password);
-
-Select @LAST_UserID as UserID; 
-
 END ;;
 DELIMITER ;
 /*!50003 SET sql_mode              = @saved_sql_mode */ ;
@@ -3168,29 +3115,6 @@ BEGIN
 	SELECT collection as collection_override, NULL as name_override, NULL as desc_override, NULL as type_override, entity_id, property_id from collection_type where domain_id=DomainID and entity_id=EntityID;
 	
 
-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 `setPassword` */;
-/*!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_general_ci */ ;
-/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
-/*!50003 SET sql_mode              = 'STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
-DELIMITER ;;
-CREATE DEFINER=`caosdb`@`%` PROCEDURE `setPassword`(in EntityID INT UNSIGNED, in NewPassword VARCHAR(255))
-BEGIN
-
-
-	DELETE FROM passwords where entity_id=EntityID;
-	INSERT INTO passwords (entity_id, password) VALUES (EntityID, NewPassword);
-
 END ;;
 DELIMITER ;
 /*!50003 SET sql_mode              = @saved_sql_mode */ ;
diff --git a/tests/test_autotap.sql b/tests/test_autotap.sql
index 1ae650e..6109dbe 100644
--- a/tests/test_autotap.sql
+++ b/tests/test_autotap.sql
@@ -2572,13 +2572,6 @@ SELECT tap.procedure_is_deterministic('_caosdb_schema_unit_tests','insertLinCon'
 SELECT tap.procedure_security_type_is('_caosdb_schema_unit_tests','insertLinCon','DEFINER','');
 SELECT tap.procedure_sql_data_access_is('_caosdb_schema_unit_tests','insertLinCon','CONTAINS SQL','');
 
--- PROCEDURES _caosdb_schema_unit_tests.insertUser
-
-SELECT tap.has_procedure('_caosdb_schema_unit_tests','insertUser','');
-SELECT tap.procedure_is_deterministic('_caosdb_schema_unit_tests','insertUser','NO','');
-SELECT tap.procedure_security_type_is('_caosdb_schema_unit_tests','insertUser','DEFINER','');
-SELECT tap.procedure_sql_data_access_is('_caosdb_schema_unit_tests','insertUser','CONTAINS SQL','');
-
 -- PROCEDURES _caosdb_schema_unit_tests.intersectTable
 
 SELECT tap.has_procedure('_caosdb_schema_unit_tests','intersectTable','');
-- 
GitLab