xref: /dokuwiki/lib/plugins/authpdo/_test/pgsql/django.php (revision c3f4c777155c3ce9e64aff5ff45420d373a92bc0)
132a211c7SAndreas Gohr<?php
232a211c7SAndreas Gohr/**
332a211c7SAndreas Gohr * Django application config
432a211c7SAndreas Gohr *
532a211c7SAndreas Gohr */
632a211c7SAndreas Gohr/** @noinspection SqlResolve */
732a211c7SAndreas Gohr$data = array(
832a211c7SAndreas Gohr    'passcrypt' => 'djangopbkdf2_sha256',
932a211c7SAndreas Gohr    'conf' => array(
1032a211c7SAndreas Gohr        'select-user' => '
1132a211c7SAndreas Gohr            SELECT id AS uid,
1232a211c7SAndreas Gohr                   username AS "user",
1332a211c7SAndreas Gohr                   CONCAT_WS(\' \', first_name, last_name) AS name,
1432a211c7SAndreas Gohr                   password AS hash,
1532a211c7SAndreas Gohr                   email AS mail
1632a211c7SAndreas Gohr              FROM auth_user
1732a211c7SAndreas Gohr             WHERE username = :user
1832a211c7SAndreas Gohr        ',
1932a211c7SAndreas Gohr        'select-user-groups' => '
2032a211c7SAndreas Gohr            SELECT G.name AS "group"
2132a211c7SAndreas Gohr              FROM auth_group G, auth_user_groups UG
2232a211c7SAndreas Gohr             WHERE UG.user_id = :uid
2332a211c7SAndreas Gohr               AND UG.group_id = G.id
2432a211c7SAndreas Gohr        ',
2532a211c7SAndreas Gohr        'select-groups' => '
2632a211c7SAndreas Gohr            SELECT id AS gid, name AS "group"
2732a211c7SAndreas Gohr              FROM auth_group
2832a211c7SAndreas Gohr        ',
2932a211c7SAndreas Gohr        'insert-user' => '
3032a211c7SAndreas Gohr            INSERT INTO auth_user
3132a211c7SAndreas Gohr                   (password, is_superuser, username, first_name, last_name, email, is_staff, is_active, date_joined)
3232a211c7SAndreas Gohr                   VALUES (:hash, false, :user, SPLIT_PART(:name,\' \',1), SPLIT_PART(:name,\' \',2), :mail, false, true, NOW())
3332a211c7SAndreas Gohr        ',
3432a211c7SAndreas Gohr        'delete-user' => '
3532a211c7SAndreas Gohr            DELETE FROM auth_user_user_permissions
3632a211c7SAndreas Gohr             WHERE user_id = :uid
3732a211c7SAndreas Gohr            ;
3832a211c7SAndreas Gohr            DELETE FROM auth_user
3932a211c7SAndreas Gohr             WHERE id = :uid
4032a211c7SAndreas Gohr        ',
4132a211c7SAndreas Gohr        'list-users' => '
4232a211c7SAndreas Gohr            SELECT DISTINCT U.username AS "user"
4332a211c7SAndreas Gohr              FROM auth_user U, auth_user_groups UG, auth_group G
4432a211c7SAndreas Gohr             WHERE U.id = UG.user_id
4532a211c7SAndreas Gohr               AND G.id = UG.group_id
4632a211c7SAndreas Gohr               AND G.name LIKE :group
4732a211c7SAndreas Gohr               AND U.username LIKE :user
4832a211c7SAndreas Gohr               AND CONCAT_WS(\' \', U.first_name, U.last_name) LIKE :name
4932a211c7SAndreas Gohr               AND U.email LIKE :mail
5032a211c7SAndreas Gohr          ORDER BY username
5132a211c7SAndreas Gohr             LIMIT :limit
5232a211c7SAndreas Gohr            OFFSET :start
5332a211c7SAndreas Gohr        ',
5432a211c7SAndreas Gohr        'count-users' => '
5532a211c7SAndreas Gohr            SELECT COUNT(DISTINCT U.username) AS count
5632a211c7SAndreas Gohr              FROM auth_user U, auth_user_groups UG, auth_group G
5732a211c7SAndreas Gohr             WHERE U.id = UG.user_id
5832a211c7SAndreas Gohr               AND G.id = UG.group_id
5932a211c7SAndreas Gohr               AND G.name LIKE :group
6032a211c7SAndreas Gohr               AND U.username LIKE :user
6132a211c7SAndreas Gohr               AND CONCAT_WS(\' \', U.first_name, U.last_name) LIKE :name
6232a211c7SAndreas Gohr               AND U.email LIKE :mail
6332a211c7SAndreas Gohr        ',
6432a211c7SAndreas Gohr        'update-user-info' => '
6532a211c7SAndreas Gohr            UPDATE auth_user
6632a211c7SAndreas Gohr               SET first_name = SPLIT_PART(:name,\' \',1),
6732a211c7SAndreas Gohr                   last_name = SPLIT_PART(:name,\' \',2),
6832a211c7SAndreas Gohr                   email = :mail
6932a211c7SAndreas Gohr             WHERE id = :uid
7032a211c7SAndreas Gohr        ',
7132a211c7SAndreas Gohr        'update-user-login' => '
7232a211c7SAndreas Gohr            UPDATE auth_user
7332a211c7SAndreas Gohr               SET username = :newlogin
7432a211c7SAndreas Gohr             WHERE id = :uid
7532a211c7SAndreas Gohr        ',
7632a211c7SAndreas Gohr        'update-user-pass' => '
7732a211c7SAndreas Gohr            UPDATE auth_user
7832a211c7SAndreas Gohr               SET password = :hash
7932a211c7SAndreas Gohr             WHERE id = :uid
8032a211c7SAndreas Gohr        ',
8132a211c7SAndreas Gohr        'insert-group' => '
8232a211c7SAndreas Gohr            INSERT INTO auth_group (name) VALUES (:group)
8332a211c7SAndreas Gohr        ',
8432a211c7SAndreas Gohr        'join-group' => '
8532a211c7SAndreas Gohr            INSERT INTO auth_user_groups (user_id, group_id) VALUES (:uid, :gid)
8632a211c7SAndreas Gohr        ',
8732a211c7SAndreas Gohr        'leave-group' => '
8832a211c7SAndreas Gohr            DELETE FROM auth_user_groups
8932a211c7SAndreas Gohr             WHERE user_id = :uid
9032a211c7SAndreas Gohr               AND group_id = :gid
9132a211c7SAndreas Gohr        ',
9232a211c7SAndreas Gohr    ),
9332a211c7SAndreas Gohr    'users' => array(
9432a211c7SAndreas Gohr        array(
9532a211c7SAndreas Gohr            'user' => 'test-billing',
9632a211c7SAndreas Gohr            'pass' => 'P4zzW0rd!',
9732a211c7SAndreas Gohr            'name' => 'Joana Gröschel',
9832a211c7SAndreas Gohr            'mail' => 'jg@billing.com',
9932a211c7SAndreas Gohr            'grps' =>
10032a211c7SAndreas Gohr                array(
10132a211c7SAndreas Gohr                    0 => 'Billing',
10232a211c7SAndreas Gohr                ),
10332a211c7SAndreas Gohr        ),
10432a211c7SAndreas Gohr        array(
10532a211c7SAndreas Gohr            'user' => 'test-kunde',
10632a211c7SAndreas Gohr            'pass' => 'P4zzW0rd!',
10732a211c7SAndreas Gohr            'name' => 'Niels Buchberger',
10832a211c7SAndreas Gohr            'mail' => 'ng@kunde.com',
10932a211c7SAndreas Gohr            'grps' =>
11032a211c7SAndreas Gohr                array(
11132a211c7SAndreas Gohr                    0 => 'Kunden',
11232a211c7SAndreas Gohr                ),
11332a211c7SAndreas Gohr        ),
11432a211c7SAndreas Gohr        array(
11532a211c7SAndreas Gohr            'user' => 'test-mitarbeiter',
11632a211c7SAndreas Gohr            'pass' => 'P4zzW0rd!',
11732a211c7SAndreas Gohr            'name' => 'Claus Wernke',
11832a211c7SAndreas Gohr            'mail' => 'cw@mitarbeiter.com',
11932a211c7SAndreas Gohr            'grps' =>
12032a211c7SAndreas Gohr                array(
12132a211c7SAndreas Gohr                    0 => 'Mitarbeiter',
12232a211c7SAndreas Gohr                ),
12332a211c7SAndreas Gohr        ),
12432a211c7SAndreas Gohr        array(
12532a211c7SAndreas Gohr            'user' => 'test-projektleiter',
12632a211c7SAndreas Gohr            'pass' => 'P4zzW0rd!',
12732a211c7SAndreas Gohr            'name' => 'Sascha Weiher',
12832a211c7SAndreas Gohr            'mail' => 'sw@projektleiter.com',
12932a211c7SAndreas Gohr            'grps' =>
13032a211c7SAndreas Gohr                array(
13132a211c7SAndreas Gohr                    0 => 'Projektleiter',
13232a211c7SAndreas Gohr                ),
13332a211c7SAndreas Gohr        ),
13432a211c7SAndreas Gohr    ),
13532a211c7SAndreas Gohr);
136*c3f4c777SAndreas Gohr
137*c3f4c777SAndreas Gohr// passwords in the dump use the newest format, we need PHP support for that
138*c3f4c777SAndreas Gohrif(!function_exists('hash_pbkdf2') || !in_array('sha256', hash_algos())){
139*c3f4c777SAndreas Gohr    $data = 'missing pbkdf2 hash support to check passwords - django test has to be skipped';
140*c3f4c777SAndreas Gohr}
141