2021-10-03 12:42:47 +00:00
|
|
|
// Copyright 2021 Woodpecker Authors
|
2019-09-14 12:21:16 +00:00
|
|
|
//
|
2018-02-19 22:24:10 +00:00
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
2019-09-14 12:21:16 +00:00
|
|
|
//
|
2018-02-19 22:24:10 +00:00
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
2019-09-14 12:21:16 +00:00
|
|
|
//
|
2018-02-19 22:24:10 +00:00
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
2015-08-22 19:06:56 +00:00
|
|
|
package testdata
|
|
|
|
|
2021-10-03 12:42:47 +00:00
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
"net/url"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
ServiceHookMethod = http.MethodPost
|
|
|
|
ServiceHookURL, _ = url.Parse(
|
|
|
|
"http://10.40.8.5:8000/hook?owner=test&name=woodpecker&access_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9." +
|
|
|
|
"eyJ0ZXh0IjoidGVzdC93b29kcGVja2VyIiwidHlwZSI6Imhvb2sifQ.x3kPnmZtxZQ_9_eMhfQ1HSmj_SLhdT_Lu2hMczWjKh0")
|
|
|
|
ServiceHookHeaders = http.Header{
|
|
|
|
"Content-Type": []string{"application/json"},
|
|
|
|
"User-Agent": []string{"GitLab/14.3.0"},
|
|
|
|
"X-Gitlab-Event": []string{"Service Hook"},
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
// ServiceHookPushBody is payload of ServiceHook: Push
|
|
|
|
var ServiceHookPushBody = []byte(`{
|
|
|
|
"object_kind": "push",
|
|
|
|
"event_name": "push",
|
|
|
|
"before": "ffe8eb4f91d1fe6bc49f1e610e50e4b5767f0104",
|
|
|
|
"after": "16862e368d8ab812e48833b741dad720d6e2cb7f",
|
|
|
|
"ref": "refs/heads/master",
|
|
|
|
"checkout_sha": "16862e368d8ab812e48833b741dad720d6e2cb7f",
|
|
|
|
"message": null,
|
|
|
|
"user_id": 2,
|
2021-10-08 16:35:56 +00:00
|
|
|
"user_name": "the test",
|
2021-10-03 12:42:47 +00:00
|
|
|
"user_username": "test",
|
|
|
|
"user_email": "",
|
|
|
|
"user_avatar": "https://www.gravatar.com/avatar/dd46a756faad4727fb679320751f6dea?s=80&d=identicon",
|
|
|
|
"project_id": 2,
|
|
|
|
"project": {
|
|
|
|
"id": 2,
|
|
|
|
"name": "Woodpecker",
|
2016-02-22 20:43:54 +00:00
|
|
|
"description": "",
|
2021-10-03 12:42:47 +00:00
|
|
|
"web_url": "http://10.40.8.5:3200/test/woodpecker",
|
|
|
|
"avatar_url": "http://example.com/uploads/project/avatar/555/Outh-20-Logo.jpg",
|
|
|
|
"git_ssh_url": "git@10.40.8.5:test/woodpecker.git",
|
|
|
|
"git_http_url": "http://10.40.8.5:3200/test/woodpecker.git",
|
2021-10-08 16:35:56 +00:00
|
|
|
"namespace": "the test",
|
2021-10-03 12:42:47 +00:00
|
|
|
"visibility_level": 20,
|
|
|
|
"path_with_namespace": "test/woodpecker",
|
|
|
|
"default_branch": "develop",
|
|
|
|
"ci_config_path": null,
|
|
|
|
"homepage": "http://10.40.8.5:3200/test/woodpecker",
|
|
|
|
"url": "git@10.40.8.5:test/woodpecker.git",
|
|
|
|
"ssh_url": "git@10.40.8.5:test/woodpecker.git",
|
|
|
|
"http_url": "http://10.40.8.5:3200/test/woodpecker.git"
|
2016-02-22 20:43:54 +00:00
|
|
|
},
|
2021-10-03 12:42:47 +00:00
|
|
|
"commits": [
|
|
|
|
{
|
|
|
|
"id": "16862e368d8ab812e48833b741dad720d6e2cb7f",
|
|
|
|
"message": "Update main.go",
|
|
|
|
"title": "Update main.go",
|
|
|
|
"timestamp": "2021-09-27T04:46:14+00:00",
|
|
|
|
"url": "http://10.40.8.5:3200/test/woodpecker/-/commit/16862e368d8ab812e48833b741dad720d6e2cb7f",
|
|
|
|
"author": {
|
2021-10-08 16:35:56 +00:00
|
|
|
"name": "the test",
|
2021-10-03 12:42:47 +00:00
|
|
|
"email": "test@test.test"
|
|
|
|
},
|
|
|
|
"added": [
|
|
|
|
|
|
|
|
],
|
|
|
|
"modified": [
|
|
|
|
"cmd/cli/main.go"
|
|
|
|
],
|
|
|
|
"removed": [
|
2016-02-22 20:43:54 +00:00
|
|
|
|
2021-10-03 12:42:47 +00:00
|
|
|
]
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"total_commits_count": 1,
|
|
|
|
"push_options": {
|
|
|
|
},
|
|
|
|
"repository": {
|
|
|
|
"name": "Woodpecker",
|
|
|
|
"url": "git@10.40.8.5:test/woodpecker.git",
|
|
|
|
"description": "",
|
|
|
|
"homepage": "http://10.40.8.5:3200/test/woodpecker",
|
|
|
|
"git_http_url": "http://10.40.8.5:3200/test/woodpecker.git",
|
|
|
|
"git_ssh_url": "git@10.40.8.5:test/woodpecker.git",
|
|
|
|
"visibility_level": 20
|
|
|
|
}
|
|
|
|
}`)
|
|
|
|
|
|
|
|
// ServiceHookTagPushBody is payload of ServiceHook: TagPush
|
|
|
|
var ServiceHookTagPushBody = []byte(`{
|
2015-08-22 19:55:08 +00:00
|
|
|
"object_kind": "tag_push",
|
2021-10-03 12:42:47 +00:00
|
|
|
"event_name": "tag_push",
|
2015-08-22 19:55:08 +00:00
|
|
|
"before": "0000000000000000000000000000000000000000",
|
2021-10-03 12:42:47 +00:00
|
|
|
"after": "fabed3d94cd03e6c2b7958afa9569c18a24d301f",
|
|
|
|
"ref": "refs/tags/v22",
|
|
|
|
"checkout_sha": "16862e368d8ab812e48833b741dad720d6e2cb7f",
|
|
|
|
"message": "hi",
|
|
|
|
"user_id": 2,
|
2021-10-08 16:35:56 +00:00
|
|
|
"user_name": "the test",
|
2021-10-03 12:42:47 +00:00
|
|
|
"user_username": "test",
|
|
|
|
"user_email": "",
|
|
|
|
"user_avatar": "https://www.gravatar.com/avatar/dd46a756faad4727fb679320751f6dea?s=80&d=identicon",
|
|
|
|
"project_id": 2,
|
|
|
|
"project": {
|
|
|
|
"id": 2,
|
|
|
|
"name": "Woodpecker",
|
2015-08-22 19:55:08 +00:00
|
|
|
"description": "",
|
2021-10-03 12:42:47 +00:00
|
|
|
"web_url": "http://10.40.8.5:3200/test/woodpecker",
|
|
|
|
"avatar_url": "http://example.com/uploads/project/avatar/555/Outh-20-Logo.jpg",
|
|
|
|
"git_ssh_url": "git@10.40.8.5:test/woodpecker.git",
|
|
|
|
"git_http_url": "http://10.40.8.5:3200/test/woodpecker.git",
|
2021-10-08 16:35:56 +00:00
|
|
|
"namespace": "the test",
|
2021-10-03 12:42:47 +00:00
|
|
|
"visibility_level": 20,
|
|
|
|
"path_with_namespace": "test/woodpecker",
|
|
|
|
"default_branch": "develop",
|
|
|
|
"ci_config_path": null,
|
|
|
|
"homepage": "http://10.40.8.5:3200/test/woodpecker",
|
|
|
|
"url": "git@10.40.8.5:test/woodpecker.git",
|
|
|
|
"ssh_url": "git@10.40.8.5:test/woodpecker.git",
|
|
|
|
"http_url": "http://10.40.8.5:3200/test/woodpecker.git"
|
2015-08-22 19:55:08 +00:00
|
|
|
},
|
|
|
|
"commits": [
|
|
|
|
{
|
2021-10-03 12:42:47 +00:00
|
|
|
"id": "16862e368d8ab812e48833b741dad720d6e2cb7f",
|
|
|
|
"message": "Update main.go",
|
|
|
|
"title": "Update main.go",
|
|
|
|
"timestamp": "2021-09-27T04:46:14+00:00",
|
|
|
|
"url": "http://10.40.8.5:3200/test/woodpecker/-/commit/16862e368d8ab812e48833b741dad720d6e2cb7f",
|
2015-08-22 19:55:08 +00:00
|
|
|
"author": {
|
2021-10-08 16:35:56 +00:00
|
|
|
"name": "the test",
|
2021-10-03 12:42:47 +00:00
|
|
|
"email": "test@test.test"
|
|
|
|
},
|
|
|
|
"added": [
|
|
|
|
|
|
|
|
],
|
|
|
|
"modified": [
|
|
|
|
"cmd/cli/main.go"
|
|
|
|
],
|
|
|
|
"removed": [
|
|
|
|
|
|
|
|
]
|
2015-08-22 19:55:08 +00:00
|
|
|
}
|
|
|
|
],
|
2021-10-03 12:42:47 +00:00
|
|
|
"total_commits_count": 1,
|
|
|
|
"push_options": {
|
2016-02-28 17:11:50 +00:00
|
|
|
},
|
2021-10-03 12:42:47 +00:00
|
|
|
"repository": {
|
|
|
|
"name": "Woodpecker",
|
|
|
|
"url": "git@10.40.8.5:test/woodpecker.git",
|
2016-02-28 17:11:50 +00:00
|
|
|
"description": "",
|
2021-10-03 12:42:47 +00:00
|
|
|
"homepage": "http://10.40.8.5:3200/test/woodpecker",
|
|
|
|
"git_http_url": "http://10.40.8.5:3200/test/woodpecker.git",
|
|
|
|
"git_ssh_url": "git@10.40.8.5:test/woodpecker.git",
|
|
|
|
"visibility_level": 20
|
2016-02-28 17:11:50 +00:00
|
|
|
}
|
2021-10-03 12:42:47 +00:00
|
|
|
}`)
|
2016-02-28 17:11:50 +00:00
|
|
|
|
2022-01-17 22:46:59 +00:00
|
|
|
// WebhookMergeRequestBody is payload of MergeEvent
|
|
|
|
var WebhookMergeRequestBody = []byte(`{
|
2015-08-22 19:06:56 +00:00
|
|
|
"object_kind": "merge_request",
|
2021-10-03 12:42:47 +00:00
|
|
|
"event_type": "merge_request",
|
2015-08-22 19:06:56 +00:00
|
|
|
"user": {
|
2022-01-17 22:46:59 +00:00
|
|
|
"id": 2251488,
|
|
|
|
"name": "Anbraten",
|
|
|
|
"username": "anbraten",
|
|
|
|
"avatar_url": "https://secure.gravatar.com/avatar/fc9b6fe77c6b732a02925a62a81f05a0?s=80&d=identicon",
|
|
|
|
"email": "some@mail.info"
|
2021-10-03 12:42:47 +00:00
|
|
|
},
|
|
|
|
"project": {
|
2022-01-17 22:46:59 +00:00
|
|
|
"id": 32059612,
|
|
|
|
"name": "woodpecker",
|
2021-10-03 12:42:47 +00:00
|
|
|
"description": "",
|
2022-01-17 22:46:59 +00:00
|
|
|
"web_url": "https://gitlab.com/anbraten/woodpecker",
|
|
|
|
"avatar_url": "http://example.com/uploads/project/avatar/555/Outh-20-Logo.jpg",
|
|
|
|
"git_ssh_url": "git@gitlab.com:anbraten/woodpecker.git",
|
|
|
|
"git_http_url": "https://gitlab.com/anbraten/woodpecker.git",
|
|
|
|
"namespace": "Anbraten",
|
2021-10-03 12:42:47 +00:00
|
|
|
"visibility_level": 20,
|
2022-01-17 22:46:59 +00:00
|
|
|
"path_with_namespace": "anbraten/woodpecker",
|
|
|
|
"default_branch": "main",
|
|
|
|
"ci_config_path": "",
|
|
|
|
"homepage": "https://gitlab.com/anbraten/woodpecker",
|
|
|
|
"url": "git@gitlab.com:anbraten/woodpecker.git",
|
|
|
|
"ssh_url": "git@gitlab.com:anbraten/woodpecker.git",
|
|
|
|
"http_url": "https://gitlab.com/anbraten/woodpecker.git"
|
2015-08-22 19:06:56 +00:00
|
|
|
},
|
|
|
|
"object_attributes": {
|
2022-01-17 22:46:59 +00:00
|
|
|
"assignee_id": 2251488,
|
|
|
|
"author_id": 2251488,
|
|
|
|
"created_at": "2022-01-10 15:23:41 UTC",
|
2015-08-22 19:06:56 +00:00
|
|
|
"description": "",
|
2022-01-17 22:46:59 +00:00
|
|
|
"head_pipeline_id": 449733536,
|
|
|
|
"id": 134400602,
|
|
|
|
"iid": 3,
|
|
|
|
"last_edited_at": "2022-01-17 15:46:23 UTC",
|
|
|
|
"last_edited_by_id": 2251488,
|
2021-10-03 12:42:47 +00:00
|
|
|
"merge_commit_sha": null,
|
|
|
|
"merge_error": null,
|
|
|
|
"merge_params": {
|
|
|
|
"force_remove_source_branch": "1"
|
|
|
|
},
|
|
|
|
"merge_status": "unchecked",
|
|
|
|
"merge_user_id": null,
|
|
|
|
"merge_when_pipeline_succeeds": false,
|
|
|
|
"milestone_id": null,
|
2022-01-17 22:46:59 +00:00
|
|
|
"source_branch": "anbraten-main-patch-05373",
|
|
|
|
"source_project_id": 32059612,
|
2021-10-03 12:42:47 +00:00
|
|
|
"state_id": 1,
|
2022-01-17 22:46:59 +00:00
|
|
|
"target_branch": "main",
|
|
|
|
"target_project_id": 32059612,
|
2021-10-03 12:42:47 +00:00
|
|
|
"time_estimate": 0,
|
|
|
|
"title": "Update client.go 🎉",
|
2022-01-17 22:46:59 +00:00
|
|
|
"updated_at": "2022-01-17 15:47:39 UTC",
|
|
|
|
"updated_by_id": 2251488,
|
|
|
|
"url": "https://gitlab.com/anbraten/woodpecker/-/merge_requests/3",
|
2015-08-22 19:06:56 +00:00
|
|
|
"source": {
|
2022-01-17 22:46:59 +00:00
|
|
|
"id": 32059612,
|
|
|
|
"name": "woodpecker",
|
2021-10-03 12:42:47 +00:00
|
|
|
"description": "",
|
2022-01-17 22:46:59 +00:00
|
|
|
"web_url": "https://gitlab.com/anbraten/woodpecker",
|
|
|
|
"avatar_url": null,
|
|
|
|
"git_ssh_url": "git@gitlab.com:anbraten/woodpecker.git",
|
|
|
|
"git_http_url": "https://gitlab.com/anbraten/woodpecker.git",
|
|
|
|
"namespace": "Anbraten",
|
2015-08-22 19:06:56 +00:00
|
|
|
"visibility_level": 20,
|
2022-01-17 22:46:59 +00:00
|
|
|
"path_with_namespace": "anbraten/woodpecker",
|
|
|
|
"default_branch": "main",
|
|
|
|
"ci_config_path": "",
|
|
|
|
"homepage": "https://gitlab.com/anbraten/woodpecker",
|
|
|
|
"url": "git@gitlab.com:anbraten/woodpecker.git",
|
|
|
|
"ssh_url": "git@gitlab.com:anbraten/woodpecker.git",
|
|
|
|
"http_url": "https://gitlab.com/anbraten/woodpecker.git"
|
2015-08-22 19:06:56 +00:00
|
|
|
},
|
|
|
|
"target": {
|
2022-01-17 22:46:59 +00:00
|
|
|
"id": 32059612,
|
|
|
|
"name": "woodpecker",
|
2021-10-03 12:42:47 +00:00
|
|
|
"description": "",
|
2022-01-17 22:46:59 +00:00
|
|
|
"web_url": "https://gitlab.com/anbraten/woodpecker",
|
2021-10-03 12:42:47 +00:00
|
|
|
"avatar_url": "http://example.com/uploads/project/avatar/555/Outh-20-Logo.jpg",
|
2022-01-17 22:46:59 +00:00
|
|
|
"git_ssh_url": "git@gitlab.com:anbraten/woodpecker.git",
|
|
|
|
"git_http_url": "https://gitlab.com/anbraten/woodpecker.git",
|
|
|
|
"namespace": "Anbraten",
|
2015-08-22 19:06:56 +00:00
|
|
|
"visibility_level": 20,
|
2022-01-17 22:46:59 +00:00
|
|
|
"path_with_namespace": "anbraten/woodpecker",
|
|
|
|
"default_branch": "main",
|
|
|
|
"ci_config_path": "",
|
|
|
|
"homepage": "https://gitlab.com/anbraten/woodpecker",
|
|
|
|
"url": "git@gitlab.com:anbraten/woodpecker.git",
|
|
|
|
"ssh_url": "git@gitlab.com:anbraten/woodpecker.git",
|
|
|
|
"http_url": "https://gitlab.com/anbraten/woodpecker.git"
|
2015-08-22 19:06:56 +00:00
|
|
|
},
|
|
|
|
"last_commit": {
|
2022-01-17 22:46:59 +00:00
|
|
|
"id": "c136499ec574e1034b24c5d306de9acda3005367",
|
|
|
|
"message": "Update folder/todo.txt",
|
|
|
|
"title": "Update folder/todo.txt",
|
|
|
|
"timestamp": "2022-01-17T15:47:38+00:00",
|
|
|
|
"url": "https://gitlab.com/anbraten/woodpecker/-/commit/c136499ec574e1034b24c5d306de9acda3005367",
|
2015-08-22 19:06:56 +00:00
|
|
|
"author": {
|
2022-01-17 22:46:59 +00:00
|
|
|
"name": "Anbraten",
|
|
|
|
"email": "some@mail.info"
|
2015-08-22 19:06:56 +00:00
|
|
|
}
|
|
|
|
},
|
2021-10-03 12:42:47 +00:00
|
|
|
"work_in_progress": false,
|
|
|
|
"total_time_spent": 0,
|
|
|
|
"time_change": 0,
|
|
|
|
"human_total_time_spent": null,
|
|
|
|
"human_time_change": null,
|
|
|
|
"human_time_estimate": null,
|
|
|
|
"assignee_ids": [
|
2022-01-17 22:46:59 +00:00
|
|
|
2251488
|
2021-10-03 12:42:47 +00:00
|
|
|
],
|
|
|
|
"state": "opened",
|
2022-01-17 22:46:59 +00:00
|
|
|
"blocking_discussions_resolved": true,
|
2021-10-03 12:42:47 +00:00
|
|
|
"action": "update",
|
2022-01-17 22:46:59 +00:00
|
|
|
"oldrev": "8b641937b7340066d882b9d8a8cc5b0573a207de"
|
2016-02-22 20:43:54 +00:00
|
|
|
},
|
2021-10-03 12:42:47 +00:00
|
|
|
"labels": [
|
2016-02-22 20:43:54 +00:00
|
|
|
|
2021-10-03 12:42:47 +00:00
|
|
|
],
|
|
|
|
"changes": {
|
|
|
|
"updated_at": {
|
2022-01-17 22:46:59 +00:00
|
|
|
"previous": "2022-01-17 15:46:23 UTC",
|
|
|
|
"current": "2022-01-17 15:47:39 UTC"
|
2021-10-03 12:42:47 +00:00
|
|
|
}
|
|
|
|
},
|
2015-08-22 19:06:56 +00:00
|
|
|
"repository": {
|
2022-01-17 22:46:59 +00:00
|
|
|
"name": "woodpecker",
|
|
|
|
"url": "git@gitlab.com:anbraten/woodpecker.git",
|
2015-08-22 19:06:56 +00:00
|
|
|
"description": "",
|
2022-01-17 22:46:59 +00:00
|
|
|
"homepage": "https://gitlab.com/anbraten/woodpecker"
|
|
|
|
},
|
|
|
|
"assignees": [
|
|
|
|
{
|
|
|
|
"id": 2251488,
|
|
|
|
"name": "Anbraten",
|
|
|
|
"username": "anbraten",
|
|
|
|
"avatar_url": "https://secure.gravatar.com/avatar/fc9b6fe77c6b732a02925a62a81f05a0?s=80&d=identicon",
|
|
|
|
"email": "some@mail.info"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
`)
|