mirror of
https://code.forgejo.org/actions/cascading-pr.git
synced 2025-06-29 21:33:43 +00:00
create the repositories, tokens and secrets
This commit is contained in:
parent
cdd3f46d7b
commit
2892041d6c
3 changed files with 40 additions and 4 deletions
23
tests/run.sh
23
tests/run.sh
|
@ -31,7 +31,19 @@ function user_curl() {
|
|||
)
|
||||
}
|
||||
|
||||
function create_user() {
|
||||
function user_token() {
|
||||
local username=$1 name=$2
|
||||
|
||||
curl -sS -f -H Content-Type:application/json --user "$username:${options[password]}" --data-raw '{"name":"'$name'","scopes":["write:repository","write:issue"]}' ${options[url]}/api/v1/users/$username/tokens | jq --raw-output .sha1
|
||||
}
|
||||
|
||||
function user_secret() {
|
||||
local username=$1 name=$2 token=$3
|
||||
|
||||
user_curl $username api_json -X PUT --data-raw '{"data":"'$token'"}' ${options[url]}/api/v1/repos/user1/originrepo/actions/secrets/$name
|
||||
}
|
||||
|
||||
function user_create() {
|
||||
local username="$1" email="$2"
|
||||
forgejo-curl.sh api_json -X DELETE ${options[url]}/api/v1/admin/users/$username?purge=true >& /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
|
||||
|
@ -39,10 +51,13 @@ function create_user() {
|
|||
}
|
||||
|
||||
function run() {
|
||||
create_user user1 user1@example.com
|
||||
forgejo-test-helper.sh push tests/originrepo http://user1:admin1234@${options[host_port]} user1 originrepo cascading-pr
|
||||
user_create user2 user2@example.com
|
||||
forgejo-test-helper.sh push tests/destinationrepo http://user2:admin1234@${options[host_port]} user2 destinationrepo
|
||||
|
||||
create_user user2 user2@example.com
|
||||
user_create user1 user1@example.com
|
||||
forgejo-test-helper.sh push tests/originrepo http://user1:admin1234@${options[host_port]} user1 originrepo cascading-pr
|
||||
user_secret user1 ORIGIN_TOKEN $(user_token user1 ORIGIN_TOKEN)
|
||||
user_secret user1 DESTINATION_TOKEN $(user_token user2 DESTINATION_TOKEN)
|
||||
|
||||
push_self ${options[host_port]}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue