From d8e5a1362077a8ec88cda2b838ce78ea8ba9dde7 Mon Sep 17 00:00:00 2001
From: Runxi Yu <me@runxiyu.org>
Date: Thu, 6 Mar 2025 20:57:48 +0800
Subject: sql: Create user too in the test script

---
 test.sql | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

(limited to 'test.sql')

diff --git a/test.sql b/test.sql
index 43c898f..b270b76 100644
--- a/test.sql
+++ b/test.sql
@@ -8,10 +8,30 @@ child_group AS (
 	SELECT 'forge', 'Lindenii Forge', id
 	FROM parent_group
 	RETURNING id
+),
+create_repos AS (
+	INSERT INTO repos (name, group_id, contrib_requirements, filesystem_path)
+	SELECT 'server', id, 'public', '/home/runxiyu/Lindenii/forge/server/.git'
+	FROM child_group
+),
+new_user AS (
+	INSERT INTO users (username, type, password)
+	VALUES ('test', 'registered', '$argon2id$v=19$m=4096,t=3,p=1$YWFhYWFhYWFhYWFh$i40k7TPFHqXRH4eQOAYGH3LvzwQ38jqqlfap9Rtiy3c')
+	RETURNING id
+),
+new_ssh AS (
+	INSERT INTO ssh_public_keys (key_string, user_id)
+	SELECT 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAuavKDhEM1L6CufIecy2P712gp151CqZuwSYahTWvmq', id
+	FROM new_user
+	RETURNING user_id
 )
-INSERT INTO repos (name, group_id, contrib_requirements, filesystem_path)
-SELECT 'server', id, 'public', '/home/runxiyu/Lindenii/forge/server/.git'
-FROM child_group;
+INSERT INTO user_group_roles (group_id, user_id)
+SELECT child_group.id, new_ssh.user_id
+FROM child_group, new_ssh;
 
 SELECT * FROM groups;
 SELECT * FROM repos;
+SELECT * FROM users;
+SELECT * FROM ssh_public_keys;
+SELECT * FROM user_group_roles;
+
-- 
cgit v1.2.3

