DELETE FROM g_user_session_scheme;
DELETE FROM g_user_session;
DELETE FROM g_scope_group_auth_scheme_module_instance;
DELETE FROM g_scope_group;
DELETE FROM g_scope;
DELETE FROM g_user_middleware_module_instance;
DELETE FROM g_user_module_instance;
DELETE FROM g_user_auth_scheme_module_instance;
DELETE FROM g_client_module_instance;
DELETE FROM g_client_module_instance;
DELETE FROM g_plugin_module_instance;
DELETE FROM g_api_key;
DELETE FROM gpr_session;
DELETE FROM gs_webauthn_assertion;
DELETE FROM gs_webauthn_credential;
DELETE FROM gs_webauthn_user;
DELETE FROM gpo_ciba;
DELETE FROM gpo_par;
DELETE FROM gpo_dpop;
DELETE FROM gpo_device_authorization;
DELETE FROM gpo_client_token_request;
DELETE FROM gpo_client_registration;
DELETE FROM gpo_subject_identifier;
DELETE FROM gpo_id_token;
DELETE FROM gpo_access_token;
DELETE FROM gpo_refresh_token;
DELETE FROM gpo_code;
DELETE FROM gpg_device_authorization;
DELETE FROM gpg_access_token;
DELETE FROM gpg_refresh_token;
DELETE FROM gpg_code;
DELETE FROM g_misc_config;

INSERT INTO g_user_module_instance (gumi_module, gumi_name, gumi_display_name, gumi_order, gumi_parameters) VALUES ('mock', 'mock', 'Mock user module', 0, '{"username-prefix":"","password":"password"}');
INSERT INTO g_user_auth_scheme_module_instance (guasmi_module, guasmi_name, guasmi_display_name, guasmi_expiration, guasmi_parameters) VALUES ('mock', 'mock_scheme_42', 'Mock 42', 600, '{"mock-value":"42"}');
INSERT INTO g_user_auth_scheme_module_instance (guasmi_module, guasmi_name, guasmi_display_name, guasmi_expiration, guasmi_parameters, guasmi_max_use) VALUES ('mock', 'mock_scheme_88', 'Mock 88', 600, '{"mock-value":"88"}', 1);
INSERT INTO g_user_auth_scheme_module_instance (guasmi_module, guasmi_name, guasmi_display_name, guasmi_expiration, guasmi_parameters) VALUES ('mock', 'mock_scheme_95', 'Mock 95', 300, '{"mock-value":"95"}');
INSERT INTO g_client_module_instance (gcmi_module, gcmi_name, gcmi_display_name, gcmi_order, gcmi_parameters) VALUES ('mock', 'mock', 'Mock client module', 0, '{"username-prefix":"","password":"password"}');
INSERT INTO g_scope (gs_name, gs_display_name, gs_description, gs_password_required, gs_password_max_age) VALUES ('g_admin', 'Glewlwyd administration', 'Access to Glewlwyd''s administration API', 1, 600);
INSERT INTO g_scope (gs_name, gs_display_name, gs_description, gs_password_required, gs_password_max_age) VALUES ('g_profile', 'Glewlwyd profile', 'Access to the user''s profile API', 1, 600);
INSERT INTO g_scope (gs_name, gs_display_name, gs_description, gs_password_required, gs_password_max_age) VALUES ('openid', 'id_token scope', 'OpenID Connect used for getting id_token in code response type', 0, 0);
INSERT INTO g_scope (gs_name, gs_display_name, gs_description, gs_password_required, gs_password_max_age) VALUES ('scope1', 'Glewlwyd mock scope 1 with password', 'Glewlwyd scope 1 scope description', 1, 0);
INSERT INTO g_scope (gs_name, gs_display_name, gs_description, gs_password_required, gs_password_max_age) VALUES ('scope2', 'Glewlwyd mock scope 2 without password', 'Glewlwyd scope 2 scope description', 0, 0);
INSERT INTO g_scope (gs_name, gs_display_name, gs_description, gs_password_required, gs_password_max_age) VALUES ('scope3', 'Glewlwyd mock scope 3 with password', 'Glewlwyd scope 3 scope description', 1, 0);
INSERT INTO g_scope_group (gs_id, gsg_name) VALUES ((SELECT gs_id FROM g_scope WHERE gs_name = 'scope1'), '0');
INSERT INTO g_scope_group (gs_id, gsg_name) VALUES ((SELECT gs_id FROM g_scope WHERE gs_name = 'scope1'), '1');
INSERT INTO g_scope_group (gs_id, gsg_name) VALUES ((SELECT gs_id FROM g_scope WHERE gs_name = 'scope2'), '2');
INSERT INTO g_scope_group (gs_id, gsg_name) VALUES ((SELECT gs_id FROM g_scope WHERE gs_name = 'scope3'), '3');
INSERT INTO g_scope_group_auth_scheme_module_instance (gsg_id, guasmi_id) VALUES ((SELECT gsg_id FROM g_scope_group WHERE gsg_name = '0'), (SELECT guasmi_id FROM g_user_auth_scheme_module_instance WHERE guasmi_name = 'mock_scheme_42'));
INSERT INTO g_scope_group_auth_scheme_module_instance (gsg_id, guasmi_id) VALUES ((SELECT gsg_id FROM g_scope_group WHERE gsg_name = '0'), (SELECT guasmi_id FROM g_user_auth_scheme_module_instance WHERE guasmi_name = 'mock_scheme_88'));
INSERT INTO g_scope_group_auth_scheme_module_instance (gsg_id, guasmi_id) VALUES ((SELECT gsg_id FROM g_scope_group WHERE gsg_name = '1'), (SELECT guasmi_id FROM g_user_auth_scheme_module_instance WHERE guasmi_name = 'mock_scheme_95'));
INSERT INTO g_scope_group_auth_scheme_module_instance (gsg_id, guasmi_id) VALUES ((SELECT gsg_id FROM g_scope_group WHERE gsg_name = '2'), (SELECT guasmi_id FROM g_user_auth_scheme_module_instance WHERE guasmi_name = 'mock_scheme_95'));
INSERT INTO g_scope_group_auth_scheme_module_instance (gsg_id, guasmi_id) VALUES ((SELECT gsg_id FROM g_scope_group WHERE gsg_name = '3'), (SELECT guasmi_id FROM g_user_auth_scheme_module_instance WHERE guasmi_name = 'mock_scheme_88'));
INSERT INTO g_plugin_module_instance (gpmi_module, gpmi_name, gpmi_display_name, gpmi_parameters) VALUES ('oauth2-glewlwyd', 'glwd', 'OAuth2 Glewlwyd plugin', '{"jwt-type":"sha","jwt-key-size":"256","key":"secret","access-token-duration":3600,"refresh-token-duration":1209600,"code-duration":600,"refresh-token-rolling":true,"auth-type-code-enabled":true,"auth-type-implicit-enabled":true,"auth-type-password-enabled":true,"auth-type-client-enabled":true,"auth-type-refresh-enabled":true,"scope":[{"name":"g_profile","refresh-token-rolling":true},{"name":"scope1","refresh-token-rolling":true},{"name":"scope2","refresh-token-rolling":false,"refresh-token-duration":7200}]}');
INSERT INTO g_plugin_module_instance (gpmi_module, gpmi_name, gpmi_display_name, gpmi_parameters) VALUES ('oidc', 'oidc', 'OpenID Connect Glewlwyd plugin', '{"iss":"https://glewlwyd.tld","jwt-type":"sha","jwt-key-size":"256","key":"secret","access-token-duration":3600,"refresh-token-duration":1209600,"code-duration":600,"refresh-token-rolling":true, "allow-non-oidc":true,"auth-type-code-enabled":true,"auth-type-token-enabled":true,"auth-type-none-enabled":true,"auth-type-password-enabled":true,"auth-type-client-enabled":true,"auth-type-refresh-enabled":true,"scope":[{"name":"g_profile","refresh-token-rolling":true},{"name":"scope1","refresh-token-rolling":true},{"name":"scope2","refresh-token-rolling":false,"refresh-token-duration":7200}]}');
