mirror of
https://code.forgejo.org/actions/cascading-pr
synced 2025-03-14 22:36:58 +01:00
create two users
This commit is contained in:
parent
607d678e7a
commit
3da0fa91c3
1 changed files with 33 additions and 1 deletions
34
tests/run.sh
34
tests/run.sh
|
@ -1,8 +1,11 @@
|
|||
#!/bin/bash
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
set -e
|
||||
|
||||
SELF_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
source $SELF_DIR/../cascading-pr-lib.sh
|
||||
TMPDIR=/tmp/cascading-pr
|
||||
|
||||
function push_self() {
|
||||
local host_port=$1
|
||||
|
@ -10,17 +13,46 @@ function push_self() {
|
|||
forgejo-test-helper.sh push_self_action http://root:admin1234@$host_port root cascading-pr vTest
|
||||
}
|
||||
|
||||
function user_login() {
|
||||
local username=$1
|
||||
(
|
||||
export DOT=$TMPDIR/$username
|
||||
forgejo-curl.sh logout
|
||||
forgejo-curl.sh --user $username --password "${options[password]}" login ${options[url]}
|
||||
)
|
||||
}
|
||||
|
||||
function user_curl() {
|
||||
local username=$1
|
||||
shift
|
||||
(
|
||||
export DOT=$TMPDIR/$username
|
||||
forgejo-curl.sh "$@"
|
||||
)
|
||||
}
|
||||
|
||||
function create_user() {
|
||||
local username="$1" email="$2"
|
||||
forgejo-curl.sh api_json -X DELETE --data-raw '{"purge":true}' ${options[url]}/api/v1/admin/users/$username >& /dev/null || true
|
||||
forgejo-curl.sh api_json --data-raw '{"username":"'$username'","email":"'$email'","password":"'${options[password]}'","must_change_password":false}' ${options[url]}/api/v1/admin/users
|
||||
user_login $username
|
||||
}
|
||||
|
||||
function run() {
|
||||
push_self ${options[host_port]}
|
||||
|
||||
create_user user1 user1@example.com
|
||||
create_user user2 user2@example.com
|
||||
|
||||
echo do something
|
||||
}
|
||||
|
||||
function main() {
|
||||
local command=run
|
||||
options[host_port]=$(cat forgejo-ip):3000
|
||||
options[url]=http://$host_port
|
||||
options[url]=http://${options[host_port]}
|
||||
options[token]=$(cat forgejo-token)
|
||||
options[password]=admin1234
|
||||
|
||||
while true; do
|
||||
case "$1" in
|
||||
|
|
Loading…
Add table
Reference in a new issue