/engine/hooks/tasks_bitbucket_test.go

https://github.com/ovh/cds · Go · 3079 lines · 3011 code · 68 blank · 0 comment · 14 complexity · 3b58b2a6de972863f5cc2bee8b2df13c MD5 · raw file

  1. package hooks
  2. import (
  3. "context"
  4. "testing"
  5. "github.com/ovh/cds/engine/api/test"
  6. "github.com/ovh/cds/sdk"
  7. "github.com/ovh/cds/sdk/log"
  8. "github.com/stretchr/testify/assert"
  9. )
  10. func Test_doWebHookExecutionBitbucket(t *testing.T) {
  11. log.SetLogger(t)
  12. s, cancel := setupTestHookService(t)
  13. defer cancel()
  14. task := &sdk.TaskExecution{
  15. UUID: sdk.RandomString(10),
  16. Type: TypeRepoManagerWebHook,
  17. WebHook: &sdk.WebHookExecution{
  18. RequestBody: []byte(bitbucketPushEvent),
  19. RequestHeader: map[string][]string{
  20. BitbucketHeader: {"repo:refs_changed"},
  21. },
  22. RequestURL: "",
  23. },
  24. }
  25. hs, err := s.doWebHookExecution(context.TODO(), task)
  26. test.NoError(t, err)
  27. assert.Equal(t, 1, len(hs))
  28. assert.Equal(t, "repo:refs_changed", hs[0].Payload["git.hook"])
  29. assert.Equal(t, "name-of-branch", hs[0].Payload["git.branch"])
  30. assert.Equal(t, "steven.guiheux", hs[0].Payload["git.author"])
  31. assert.Equal(t, "9f4fac7ec5642099982a86f584f2c4a362adb670", hs[0].Payload["git.hash"])
  32. }
  33. func Test_doWebHookExecutionBitbucketPRReviewerUpdated(t *testing.T) {
  34. log.SetLogger(t)
  35. s, cancel := setupTestHookService(t)
  36. defer cancel()
  37. task := &sdk.TaskExecution{
  38. UUID: sdk.RandomString(10),
  39. Type: TypeRepoManagerWebHook,
  40. WebHook: &sdk.WebHookExecution{
  41. RequestBody: []byte(bitbucketPrReviewerUpdated),
  42. RequestHeader: map[string][]string{
  43. BitbucketHeader: {"pr:reviewer:updated"},
  44. },
  45. RequestURL: "",
  46. },
  47. Config: map[string]sdk.WorkflowNodeHookConfigValue{
  48. sdk.HookConfigEventFilter: {
  49. Value: "pr:opened;pr:approved;pr:reviewer:updated",
  50. },
  51. },
  52. }
  53. hs, err := s.doWebHookExecution(context.TODO(), task)
  54. test.NoError(t, err)
  55. test.Equal(t, "john.doe", hs[0].Payload[CDS_TRIGGERED_BY_USERNAME])
  56. test.Equal(t, "john doe", hs[0].Payload[CDS_TRIGGERED_BY_FULLNAME])
  57. test.Equal(t, "john.doe@targate.fr", hs[0].Payload[CDS_TRIGGERED_BY_EMAIL])
  58. test.Equal(t, "john.doe", hs[0].Payload[GIT_AUTHOR])
  59. test.Equal(t, "john.doe@targate.fr", hs[0].Payload[GIT_AUTHOR_EMAIL])
  60. test.Equal(t, "dest_branch", hs[0].Payload[GIT_BRANCH_DEST])
  61. test.Equal(t, "my/repo", hs[0].Payload[GIT_REPOSITORY_DEST])
  62. test.Equal(t, "654321654321", hs[0].Payload[GIT_HASH_DEST])
  63. test.Equal(t, "pr:reviewer:updated", hs[0].Payload[GIT_EVENT])
  64. test.Equal(t, "src_branch", hs[0].Payload[GIT_BRANCH])
  65. test.Equal(t, "12345671234567", hs[0].Payload[GIT_HASH])
  66. test.Equal(t, "1234567", hs[0].Payload[GIT_HASH_SHORT])
  67. test.Equal(t, "666", hs[0].Payload[PR_ID])
  68. test.Equal(t, "OPEN", hs[0].Payload[PR_STATE])
  69. test.Equal(t, "My First PR", hs[0].Payload[PR_TITLE])
  70. test.Equal(t, "fork/repo", hs[0].Payload[GIT_REPOSITORY])
  71. }
  72. func Test_doWebHookExecutionBitbucketPRReviewerApproved(t *testing.T) {
  73. log.SetLogger(t)
  74. s, cancel := setupTestHookService(t)
  75. defer cancel()
  76. task := &sdk.TaskExecution{
  77. UUID: sdk.RandomString(10),
  78. Type: TypeRepoManagerWebHook,
  79. WebHook: &sdk.WebHookExecution{
  80. RequestBody: []byte(bitbucketPrReviewerApproved),
  81. RequestHeader: map[string][]string{
  82. BitbucketHeader: {"pr:reviewer:approved"},
  83. },
  84. RequestURL: "",
  85. },
  86. Config: map[string]sdk.WorkflowNodeHookConfigValue{
  87. sdk.HookConfigEventFilter: {
  88. Value: "pr:opened;pr:approved;pr:reviewer:approved",
  89. },
  90. },
  91. }
  92. hs, err := s.doWebHookExecution(context.TODO(), task)
  93. test.NoError(t, err)
  94. test.Equal(t, "john.doe", hs[0].Payload[CDS_TRIGGERED_BY_USERNAME])
  95. test.Equal(t, "john doe", hs[0].Payload[CDS_TRIGGERED_BY_FULLNAME])
  96. test.Equal(t, "john.doe@targate.fr", hs[0].Payload[CDS_TRIGGERED_BY_EMAIL])
  97. test.Equal(t, "john.doe", hs[0].Payload[GIT_AUTHOR])
  98. test.Equal(t, "john.doe@targate.fr", hs[0].Payload[GIT_AUTHOR_EMAIL])
  99. test.Equal(t, "dest_branch", hs[0].Payload[GIT_BRANCH_DEST])
  100. test.Equal(t, "my/repo", hs[0].Payload[GIT_REPOSITORY_DEST])
  101. test.Equal(t, "654321654321", hs[0].Payload[GIT_HASH_DEST])
  102. test.Equal(t, "pr:reviewer:approved", hs[0].Payload[GIT_EVENT])
  103. test.Equal(t, "src_branch", hs[0].Payload[GIT_BRANCH])
  104. test.Equal(t, "12345671234567", hs[0].Payload[GIT_HASH])
  105. test.Equal(t, "1234567", hs[0].Payload[GIT_HASH_SHORT])
  106. test.Equal(t, "666", hs[0].Payload[PR_ID])
  107. test.Equal(t, "OPEN", hs[0].Payload[PR_STATE])
  108. test.Equal(t, "My First PR", hs[0].Payload[PR_TITLE])
  109. test.Equal(t, "fork/repo", hs[0].Payload[GIT_REPOSITORY])
  110. test.Equal(t, "francois.samin", hs[0].Payload[PR_REVIEWER])
  111. test.Equal(t, "francois.samin@foo", hs[0].Payload[PR_REVIEWER_EMAIL])
  112. test.Equal(t, "APPROVED", hs[0].Payload[PR_REVIEWER_STATUS])
  113. test.Equal(t, "REVIEWER", hs[0].Payload[PR_REVIEWER_ROLE])
  114. test.Equal(t, "UNAPPROVED", hs[0].Payload[PR_PREVIOUS_STATE])
  115. }
  116. func Test_doWebHookExecutionBitbucketPRReviewerUnapproved(t *testing.T) {
  117. log.SetLogger(t)
  118. s, cancel := setupTestHookService(t)
  119. defer cancel()
  120. task := &sdk.TaskExecution{
  121. UUID: sdk.RandomString(10),
  122. Type: TypeRepoManagerWebHook,
  123. WebHook: &sdk.WebHookExecution{
  124. RequestBody: []byte(bitbucketPrReviewerUnapproved),
  125. RequestHeader: map[string][]string{
  126. BitbucketHeader: {"pr:reviewer:unapproved"},
  127. },
  128. RequestURL: "",
  129. },
  130. Config: map[string]sdk.WorkflowNodeHookConfigValue{
  131. sdk.HookConfigEventFilter: {
  132. Value: "pr:opened;pr:approved;pr:reviewer:unapproved",
  133. },
  134. },
  135. }
  136. hs, err := s.doWebHookExecution(context.TODO(), task)
  137. test.NoError(t, err)
  138. test.Equal(t, "john.doe", hs[0].Payload[CDS_TRIGGERED_BY_USERNAME])
  139. test.Equal(t, "john doe", hs[0].Payload[CDS_TRIGGERED_BY_FULLNAME])
  140. test.Equal(t, "john.doe@targate.fr", hs[0].Payload[CDS_TRIGGERED_BY_EMAIL])
  141. test.Equal(t, "john.doe", hs[0].Payload[GIT_AUTHOR])
  142. test.Equal(t, "john.doe@targate.fr", hs[0].Payload[GIT_AUTHOR_EMAIL])
  143. test.Equal(t, "dest_branch", hs[0].Payload[GIT_BRANCH_DEST])
  144. test.Equal(t, "my/repo", hs[0].Payload[GIT_REPOSITORY_DEST])
  145. test.Equal(t, "654321654321", hs[0].Payload[GIT_HASH_DEST])
  146. test.Equal(t, "pr:reviewer:unapproved", hs[0].Payload[GIT_EVENT])
  147. test.Equal(t, "src_branch", hs[0].Payload[GIT_BRANCH])
  148. test.Equal(t, "12345671234567", hs[0].Payload[GIT_HASH])
  149. test.Equal(t, "1234567", hs[0].Payload[GIT_HASH_SHORT])
  150. test.Equal(t, "666", hs[0].Payload[PR_ID])
  151. test.Equal(t, "OPEN", hs[0].Payload[PR_STATE])
  152. test.Equal(t, "My First PR", hs[0].Payload[PR_TITLE])
  153. test.Equal(t, "fork/repo", hs[0].Payload[GIT_REPOSITORY])
  154. test.Equal(t, "francois.samin", hs[0].Payload[PR_REVIEWER])
  155. test.Equal(t, "francois.samin@foo", hs[0].Payload[PR_REVIEWER_EMAIL])
  156. test.Equal(t, "UNAPPROVED", hs[0].Payload[PR_REVIEWER_STATUS])
  157. test.Equal(t, "REVIEWER", hs[0].Payload[PR_REVIEWER_ROLE])
  158. test.Equal(t, "APPROVED", hs[0].Payload[PR_PREVIOUS_STATE])
  159. }
  160. func Test_doWebHookExecutionBitbucketPRReviewerNeedsWork(t *testing.T) {
  161. log.SetLogger(t)
  162. s, cancel := setupTestHookService(t)
  163. defer cancel()
  164. task := &sdk.TaskExecution{
  165. UUID: sdk.RandomString(10),
  166. Type: TypeRepoManagerWebHook,
  167. WebHook: &sdk.WebHookExecution{
  168. RequestBody: []byte(bitbucketPrReviewerNeedsWorks),
  169. RequestHeader: map[string][]string{
  170. BitbucketHeader: {"pr:reviewer:needs_work"},
  171. },
  172. RequestURL: "",
  173. },
  174. Config: map[string]sdk.WorkflowNodeHookConfigValue{
  175. sdk.HookConfigEventFilter: {
  176. Value: "pr:opened;pr:approved;pr:reviewer:needs_work",
  177. },
  178. },
  179. }
  180. hs, err := s.doWebHookExecution(context.TODO(), task)
  181. test.NoError(t, err)
  182. test.Equal(t, "john.doe", hs[0].Payload[CDS_TRIGGERED_BY_USERNAME])
  183. test.Equal(t, "john doe", hs[0].Payload[CDS_TRIGGERED_BY_FULLNAME])
  184. test.Equal(t, "john.doe@targate.fr", hs[0].Payload[CDS_TRIGGERED_BY_EMAIL])
  185. test.Equal(t, "john.doe", hs[0].Payload[GIT_AUTHOR])
  186. test.Equal(t, "john.doe@targate.fr", hs[0].Payload[GIT_AUTHOR_EMAIL])
  187. test.Equal(t, "dest_branch", hs[0].Payload[GIT_BRANCH_DEST])
  188. test.Equal(t, "my/repo", hs[0].Payload[GIT_REPOSITORY_DEST])
  189. test.Equal(t, "654321654321", hs[0].Payload[GIT_HASH_DEST])
  190. test.Equal(t, "pr:reviewer:needs_work", hs[0].Payload[GIT_EVENT])
  191. test.Equal(t, "src_branch", hs[0].Payload[GIT_BRANCH])
  192. test.Equal(t, "12345671234567", hs[0].Payload[GIT_HASH])
  193. test.Equal(t, "1234567", hs[0].Payload[GIT_HASH_SHORT])
  194. test.Equal(t, "666", hs[0].Payload[PR_ID])
  195. test.Equal(t, "OPEN", hs[0].Payload[PR_STATE])
  196. test.Equal(t, "My First PR", hs[0].Payload[PR_TITLE])
  197. test.Equal(t, "fork/repo", hs[0].Payload[GIT_REPOSITORY])
  198. test.Equal(t, "francois.samin", hs[0].Payload[PR_REVIEWER])
  199. test.Equal(t, "francois.samin@foo", hs[0].Payload[PR_REVIEWER_EMAIL])
  200. test.Equal(t, "NEEDS_WORK", hs[0].Payload[PR_REVIEWER_STATUS])
  201. test.Equal(t, "REVIEWER", hs[0].Payload[PR_REVIEWER_ROLE])
  202. test.Equal(t, "UNAPPROVED", hs[0].Payload[PR_PREVIOUS_STATE])
  203. }
  204. func Test_doWebHookExecutionBitbucketPRCommentAdded(t *testing.T) {
  205. log.SetLogger(t)
  206. s, cancel := setupTestHookService(t)
  207. defer cancel()
  208. task := &sdk.TaskExecution{
  209. UUID: sdk.RandomString(10),
  210. Type: TypeRepoManagerWebHook,
  211. WebHook: &sdk.WebHookExecution{
  212. RequestBody: []byte(bitbucketPrCommentAdded),
  213. RequestHeader: map[string][]string{
  214. BitbucketHeader: {"pr:comment:added"},
  215. },
  216. RequestURL: "",
  217. },
  218. Config: map[string]sdk.WorkflowNodeHookConfigValue{
  219. sdk.HookConfigEventFilter: {
  220. Value: "pr:opened;pr:approved;pr:comment:added",
  221. },
  222. },
  223. }
  224. hs, err := s.doWebHookExecution(context.TODO(), task)
  225. test.NoError(t, err)
  226. test.Equal(t, "john.doe", hs[0].Payload[CDS_TRIGGERED_BY_USERNAME])
  227. test.Equal(t, "john doe", hs[0].Payload[CDS_TRIGGERED_BY_FULLNAME])
  228. test.Equal(t, "john.doe@targate.fr", hs[0].Payload[CDS_TRIGGERED_BY_EMAIL])
  229. test.Equal(t, "john.doe", hs[0].Payload[GIT_AUTHOR])
  230. test.Equal(t, "john.doe@targate.fr", hs[0].Payload[GIT_AUTHOR_EMAIL])
  231. test.Equal(t, "dest_branch", hs[0].Payload[GIT_BRANCH_DEST])
  232. test.Equal(t, "my/repo", hs[0].Payload[GIT_REPOSITORY_DEST])
  233. test.Equal(t, "654321654321", hs[0].Payload[GIT_HASH_DEST])
  234. test.Equal(t, "pr:comment:added", hs[0].Payload[GIT_EVENT])
  235. test.Equal(t, "src_branch", hs[0].Payload[GIT_BRANCH])
  236. test.Equal(t, "12345671234567", hs[0].Payload[GIT_HASH])
  237. test.Equal(t, "1234567", hs[0].Payload[GIT_HASH_SHORT])
  238. test.Equal(t, "666", hs[0].Payload[PR_ID])
  239. test.Equal(t, "OPEN", hs[0].Payload[PR_STATE])
  240. test.Equal(t, "My First PR", hs[0].Payload[PR_TITLE])
  241. test.Equal(t, "fork/repo", hs[0].Payload[GIT_REPOSITORY])
  242. test.Equal(t, "my comment added", hs[0].Payload[PR_COMMENT_TEXT])
  243. test.Equal(t, "steven.guiheux", hs[0].Payload[PR_COMMENT_AUTHOR])
  244. test.Equal(t, "steven.guiheux@foo", hs[0].Payload[PR_COMMENT_AUTHOR_EMAIL])
  245. }
  246. func Test_doWebHookExecutionBitbucketPRCommentDeleted(t *testing.T) {
  247. log.SetLogger(t)
  248. s, cancel := setupTestHookService(t)
  249. defer cancel()
  250. task := &sdk.TaskExecution{
  251. UUID: sdk.RandomString(10),
  252. Type: TypeRepoManagerWebHook,
  253. WebHook: &sdk.WebHookExecution{
  254. RequestBody: []byte(bitbucketPrCommentDeleted),
  255. RequestHeader: map[string][]string{
  256. BitbucketHeader: {"pr:comment:deleted"},
  257. },
  258. RequestURL: "",
  259. },
  260. Config: map[string]sdk.WorkflowNodeHookConfigValue{
  261. sdk.HookConfigEventFilter: {
  262. Value: "pr:opened;pr:approved;pr:comment:deleted",
  263. },
  264. },
  265. }
  266. hs, err := s.doWebHookExecution(context.TODO(), task)
  267. test.NoError(t, err)
  268. test.Equal(t, "john.doe", hs[0].Payload[CDS_TRIGGERED_BY_USERNAME])
  269. test.Equal(t, "john doe", hs[0].Payload[CDS_TRIGGERED_BY_FULLNAME])
  270. test.Equal(t, "john.doe@targate.fr", hs[0].Payload[CDS_TRIGGERED_BY_EMAIL])
  271. test.Equal(t, "john.doe", hs[0].Payload[GIT_AUTHOR])
  272. test.Equal(t, "john.doe@targate.fr", hs[0].Payload[GIT_AUTHOR_EMAIL])
  273. test.Equal(t, "dest_branch", hs[0].Payload[GIT_BRANCH_DEST])
  274. test.Equal(t, "my/repo", hs[0].Payload[GIT_REPOSITORY_DEST])
  275. test.Equal(t, "654321654321", hs[0].Payload[GIT_HASH_DEST])
  276. test.Equal(t, "pr:comment:deleted", hs[0].Payload[GIT_EVENT])
  277. test.Equal(t, "src_branch", hs[0].Payload[GIT_BRANCH])
  278. test.Equal(t, "12345671234567", hs[0].Payload[GIT_HASH])
  279. test.Equal(t, "1234567", hs[0].Payload[GIT_HASH_SHORT])
  280. test.Equal(t, "666", hs[0].Payload[PR_ID])
  281. test.Equal(t, "OPEN", hs[0].Payload[PR_STATE])
  282. test.Equal(t, "My First PR", hs[0].Payload[PR_TITLE])
  283. test.Equal(t, "fork/repo", hs[0].Payload[GIT_REPOSITORY])
  284. test.Equal(t, "my comment deleted", hs[0].Payload[PR_COMMENT_TEXT])
  285. test.Equal(t, "steven.guiheux", hs[0].Payload[PR_COMMENT_AUTHOR])
  286. test.Equal(t, "steven.guiheux@foo", hs[0].Payload[PR_COMMENT_AUTHOR_EMAIL])
  287. }
  288. func Test_doWebHookExecutionBitbucketPRCommentModified(t *testing.T) {
  289. log.SetLogger(t)
  290. s, cancel := setupTestHookService(t)
  291. defer cancel()
  292. task := &sdk.TaskExecution{
  293. UUID: sdk.RandomString(10),
  294. Type: TypeRepoManagerWebHook,
  295. WebHook: &sdk.WebHookExecution{
  296. RequestBody: []byte(bitbucketPrCommentModified),
  297. RequestHeader: map[string][]string{
  298. BitbucketHeader: {"pr:comment:edited"},
  299. },
  300. RequestURL: "",
  301. },
  302. Config: map[string]sdk.WorkflowNodeHookConfigValue{
  303. sdk.HookConfigEventFilter: {
  304. Value: "pr:opened;pr:approved;pr:comment:edited",
  305. },
  306. },
  307. }
  308. hs, err := s.doWebHookExecution(context.TODO(), task)
  309. test.NoError(t, err)
  310. test.Equal(t, "john.doe", hs[0].Payload[CDS_TRIGGERED_BY_USERNAME])
  311. test.Equal(t, "john doe", hs[0].Payload[CDS_TRIGGERED_BY_FULLNAME])
  312. test.Equal(t, "john.doe@targate.fr", hs[0].Payload[CDS_TRIGGERED_BY_EMAIL])
  313. test.Equal(t, "john.doe", hs[0].Payload[GIT_AUTHOR])
  314. test.Equal(t, "john.doe@targate.fr", hs[0].Payload[GIT_AUTHOR_EMAIL])
  315. test.Equal(t, "dest_branch", hs[0].Payload[GIT_BRANCH_DEST])
  316. test.Equal(t, "my/repo", hs[0].Payload[GIT_REPOSITORY_DEST])
  317. test.Equal(t, "654321654321", hs[0].Payload[GIT_HASH_DEST])
  318. test.Equal(t, "pr:comment:edited", hs[0].Payload[GIT_EVENT])
  319. test.Equal(t, "src_branch", hs[0].Payload[GIT_BRANCH])
  320. test.Equal(t, "12345671234567", hs[0].Payload[GIT_HASH])
  321. test.Equal(t, "1234567", hs[0].Payload[GIT_HASH_SHORT])
  322. test.Equal(t, "666", hs[0].Payload[PR_ID])
  323. test.Equal(t, "OPEN", hs[0].Payload[PR_STATE])
  324. test.Equal(t, "My First PR", hs[0].Payload[PR_TITLE])
  325. test.Equal(t, "fork/repo", hs[0].Payload[GIT_REPOSITORY])
  326. test.Equal(t, "my comment edited", hs[0].Payload[PR_COMMENT_TEXT])
  327. test.Equal(t, "steven.guiheux", hs[0].Payload[PR_COMMENT_AUTHOR])
  328. test.Equal(t, "steven.guiheux@foo", hs[0].Payload[PR_COMMENT_AUTHOR_EMAIL])
  329. test.Equal(t, "moi aussi", hs[0].Payload[PR_COMMENT_TEXT_PREVIOUS])
  330. }
  331. func Test_doWebHookExecutionBitbucketPROpened(t *testing.T) {
  332. log.SetLogger(t)
  333. s, cancel := setupTestHookService(t)
  334. defer cancel()
  335. task := &sdk.TaskExecution{
  336. UUID: sdk.RandomString(10),
  337. Type: TypeRepoManagerWebHook,
  338. WebHook: &sdk.WebHookExecution{
  339. RequestBody: []byte(bitbucketPrOpened),
  340. RequestHeader: map[string][]string{
  341. BitbucketHeader: {"pr:opened"},
  342. },
  343. RequestURL: "",
  344. },
  345. Config: map[string]sdk.WorkflowNodeHookConfigValue{
  346. sdk.HookConfigEventFilter: {
  347. Value: "pr:opened;pr:approved",
  348. },
  349. },
  350. }
  351. hs, err := s.doWebHookExecution(context.TODO(), task)
  352. test.NoError(t, err)
  353. test.Equal(t, "john.doe", hs[0].Payload[CDS_TRIGGERED_BY_USERNAME])
  354. test.Equal(t, "john doe", hs[0].Payload[CDS_TRIGGERED_BY_FULLNAME])
  355. test.Equal(t, "john.doe@targate.fr", hs[0].Payload[CDS_TRIGGERED_BY_EMAIL])
  356. test.Equal(t, "john.doe", hs[0].Payload[GIT_AUTHOR])
  357. test.Equal(t, "john.doe@targate.fr", hs[0].Payload[GIT_AUTHOR_EMAIL])
  358. test.Equal(t, "dest_branch", hs[0].Payload[GIT_BRANCH_DEST])
  359. test.Equal(t, "my/repo", hs[0].Payload[GIT_REPOSITORY_DEST])
  360. test.Equal(t, "654321654321", hs[0].Payload[GIT_HASH_DEST])
  361. test.Equal(t, "pr:opened", hs[0].Payload[GIT_EVENT])
  362. test.Equal(t, "src_branch", hs[0].Payload[GIT_BRANCH])
  363. test.Equal(t, "12345671234567", hs[0].Payload[GIT_HASH])
  364. test.Equal(t, "1234567", hs[0].Payload[GIT_HASH_SHORT])
  365. test.Equal(t, "666", hs[0].Payload[PR_ID])
  366. test.Equal(t, "OPEN", hs[0].Payload[PR_STATE])
  367. test.Equal(t, "My First PR", hs[0].Payload[PR_TITLE])
  368. test.Equal(t, "fork/repo", hs[0].Payload[GIT_REPOSITORY])
  369. }
  370. func Test_doWebHookExecutionBitbucketPRModified(t *testing.T) {
  371. log.SetLogger(t)
  372. s, cancel := setupTestHookService(t)
  373. defer cancel()
  374. task := &sdk.TaskExecution{
  375. UUID: sdk.RandomString(10),
  376. Type: TypeRepoManagerWebHook,
  377. WebHook: &sdk.WebHookExecution{
  378. RequestBody: []byte(bitbucketPrModified),
  379. RequestHeader: map[string][]string{
  380. BitbucketHeader: {"pr:modified"},
  381. },
  382. RequestURL: "",
  383. },
  384. Config: map[string]sdk.WorkflowNodeHookConfigValue{
  385. sdk.HookConfigEventFilter: {
  386. Value: "pr:opened;pr:modified",
  387. },
  388. },
  389. }
  390. hs, err := s.doWebHookExecution(context.TODO(), task)
  391. test.NoError(t, err)
  392. test.Equal(t, "john.doe", hs[0].Payload[CDS_TRIGGERED_BY_USERNAME])
  393. test.Equal(t, "john doe", hs[0].Payload[CDS_TRIGGERED_BY_FULLNAME])
  394. test.Equal(t, "john.doe@targate.fr", hs[0].Payload[CDS_TRIGGERED_BY_EMAIL])
  395. test.Equal(t, "john.doe", hs[0].Payload[GIT_AUTHOR])
  396. test.Equal(t, "john.doe@targate.fr", hs[0].Payload[GIT_AUTHOR_EMAIL])
  397. test.Equal(t, "dest_branch", hs[0].Payload[GIT_BRANCH_DEST])
  398. test.Equal(t, "my/repo", hs[0].Payload[GIT_REPOSITORY_DEST])
  399. test.Equal(t, "654321654321", hs[0].Payload[GIT_HASH_DEST])
  400. test.Equal(t, "pr:modified", hs[0].Payload[GIT_EVENT])
  401. test.Equal(t, "src_branch", hs[0].Payload[GIT_BRANCH])
  402. test.Equal(t, "12345671234567", hs[0].Payload[GIT_HASH])
  403. test.Equal(t, "1234567", hs[0].Payload[GIT_HASH_SHORT])
  404. test.Equal(t, "666", hs[0].Payload[PR_ID])
  405. test.Equal(t, "OPEN", hs[0].Payload[PR_STATE])
  406. test.Equal(t, "My First PR", hs[0].Payload[PR_TITLE])
  407. test.Equal(t, "fork/repo", hs[0].Payload[GIT_REPOSITORY])
  408. test.Equal(t, "Update README.md", hs[0].Payload[PR_PREVIOUS_TITLE])
  409. test.Equal(t, "prev_branch", hs[0].Payload[PR_PREVIOUS_BRANCH])
  410. test.Equal(t, "0987654321", hs[0].Payload[PR_PREVIOUS_HASH])
  411. }
  412. func Test_doWebHookExecutionBitbucketPRMerged(t *testing.T) {
  413. log.SetLogger(t)
  414. s, cancel := setupTestHookService(t)
  415. defer cancel()
  416. task := &sdk.TaskExecution{
  417. UUID: sdk.RandomString(10),
  418. Type: TypeRepoManagerWebHook,
  419. WebHook: &sdk.WebHookExecution{
  420. RequestBody: []byte(bitbucketPrMerged),
  421. RequestHeader: map[string][]string{
  422. BitbucketHeader: {"pr:merged"},
  423. },
  424. RequestURL: "",
  425. },
  426. Config: map[string]sdk.WorkflowNodeHookConfigValue{
  427. sdk.HookConfigEventFilter: {
  428. Value: "pr:opened;pr:merged",
  429. },
  430. },
  431. }
  432. hs, err := s.doWebHookExecution(context.TODO(), task)
  433. test.NoError(t, err)
  434. test.Equal(t, "john.doe", hs[0].Payload[CDS_TRIGGERED_BY_USERNAME])
  435. test.Equal(t, "john doe", hs[0].Payload[CDS_TRIGGERED_BY_FULLNAME])
  436. test.Equal(t, "john.doe@targate.fr", hs[0].Payload[CDS_TRIGGERED_BY_EMAIL])
  437. test.Equal(t, "john.doe", hs[0].Payload[GIT_AUTHOR])
  438. test.Equal(t, "john.doe@targate.fr", hs[0].Payload[GIT_AUTHOR_EMAIL])
  439. test.Equal(t, "dest_branch", hs[0].Payload[GIT_BRANCH_DEST])
  440. test.Equal(t, "my/repo", hs[0].Payload[GIT_REPOSITORY_DEST])
  441. test.Equal(t, "654321654321", hs[0].Payload[GIT_HASH_DEST])
  442. test.Equal(t, "pr:opened", hs[0].Payload[GIT_EVENT])
  443. test.Equal(t, "src_branch", hs[0].Payload[GIT_BRANCH])
  444. test.Equal(t, "12345671234567", hs[0].Payload[GIT_HASH])
  445. test.Equal(t, "1234567", hs[0].Payload[GIT_HASH_SHORT])
  446. test.Equal(t, "666", hs[0].Payload[PR_ID])
  447. test.Equal(t, "MERGED", hs[0].Payload[PR_STATE])
  448. test.Equal(t, "My First PR", hs[0].Payload[PR_TITLE])
  449. test.Equal(t, "fork/repo", hs[0].Payload[GIT_REPOSITORY])
  450. }
  451. func Test_doWebHookExecutionBitbucketPRDeleted(t *testing.T) {
  452. log.SetLogger(t)
  453. s, cancel := setupTestHookService(t)
  454. defer cancel()
  455. task := &sdk.TaskExecution{
  456. UUID: sdk.RandomString(10),
  457. Type: TypeRepoManagerWebHook,
  458. WebHook: &sdk.WebHookExecution{
  459. RequestBody: []byte(bitbucketPrDeleted),
  460. RequestHeader: map[string][]string{
  461. BitbucketHeader: {"pr:deleted"},
  462. },
  463. RequestURL: "",
  464. },
  465. Config: map[string]sdk.WorkflowNodeHookConfigValue{
  466. sdk.HookConfigEventFilter: {
  467. Value: "pr:deleted;pr:approved",
  468. },
  469. },
  470. }
  471. hs, err := s.doWebHookExecution(context.TODO(), task)
  472. test.NoError(t, err)
  473. test.Equal(t, "john.doe", hs[0].Payload[CDS_TRIGGERED_BY_USERNAME])
  474. test.Equal(t, "john doe", hs[0].Payload[CDS_TRIGGERED_BY_FULLNAME])
  475. test.Equal(t, "john.doe@targate.fr", hs[0].Payload[CDS_TRIGGERED_BY_EMAIL])
  476. test.Equal(t, "john.doe", hs[0].Payload[GIT_AUTHOR])
  477. test.Equal(t, "john.doe@targate.fr", hs[0].Payload[GIT_AUTHOR_EMAIL])
  478. test.Equal(t, "dest_branch", hs[0].Payload[GIT_BRANCH_DEST])
  479. test.Equal(t, "my/repo", hs[0].Payload[GIT_REPOSITORY_DEST])
  480. test.Equal(t, "654321654321", hs[0].Payload[GIT_HASH_DEST])
  481. test.Equal(t, "pr:deleted", hs[0].Payload[GIT_EVENT])
  482. test.Equal(t, "src_branch", hs[0].Payload[GIT_BRANCH])
  483. test.Equal(t, "12345671234567", hs[0].Payload[GIT_HASH])
  484. test.Equal(t, "1234567", hs[0].Payload[GIT_HASH_SHORT])
  485. test.Equal(t, "666", hs[0].Payload[PR_ID])
  486. test.Equal(t, "DELETED", hs[0].Payload[PR_STATE])
  487. test.Equal(t, "My First PR", hs[0].Payload[PR_TITLE])
  488. test.Equal(t, "fork/repo", hs[0].Payload[GIT_REPOSITORY])
  489. }
  490. func Test_doWebHookExecutionBitbucketPRDeclined(t *testing.T) {
  491. log.SetLogger(t)
  492. s, cancel := setupTestHookService(t)
  493. defer cancel()
  494. task := &sdk.TaskExecution{
  495. UUID: sdk.RandomString(10),
  496. Type: TypeRepoManagerWebHook,
  497. WebHook: &sdk.WebHookExecution{
  498. RequestBody: []byte(bitbucketPrDeclined),
  499. RequestHeader: map[string][]string{
  500. BitbucketHeader: {"pr:declined"},
  501. },
  502. RequestURL: "",
  503. },
  504. Config: map[string]sdk.WorkflowNodeHookConfigValue{
  505. sdk.HookConfigEventFilter: {
  506. Value: "pr:deleted;pr:declined",
  507. },
  508. },
  509. }
  510. hs, err := s.doWebHookExecution(context.TODO(), task)
  511. test.NoError(t, err)
  512. test.Equal(t, "john.doe", hs[0].Payload[CDS_TRIGGERED_BY_USERNAME])
  513. test.Equal(t, "john doe", hs[0].Payload[CDS_TRIGGERED_BY_FULLNAME])
  514. test.Equal(t, "john.doe@targate.fr", hs[0].Payload[CDS_TRIGGERED_BY_EMAIL])
  515. test.Equal(t, "john.doe", hs[0].Payload[GIT_AUTHOR])
  516. test.Equal(t, "john.doe@targate.fr", hs[0].Payload[GIT_AUTHOR_EMAIL])
  517. test.Equal(t, "dest_branch", hs[0].Payload[GIT_BRANCH_DEST])
  518. test.Equal(t, "my/repo", hs[0].Payload[GIT_REPOSITORY_DEST])
  519. test.Equal(t, "654321654321", hs[0].Payload[GIT_HASH_DEST])
  520. test.Equal(t, "pr:declined", hs[0].Payload[GIT_EVENT])
  521. test.Equal(t, "src_branch", hs[0].Payload[GIT_BRANCH])
  522. test.Equal(t, "12345671234567", hs[0].Payload[GIT_HASH])
  523. test.Equal(t, "1234567", hs[0].Payload[GIT_HASH_SHORT])
  524. test.Equal(t, "666", hs[0].Payload[PR_ID])
  525. test.Equal(t, "DECLINED", hs[0].Payload[PR_STATE])
  526. test.Equal(t, "My First PR", hs[0].Payload[PR_TITLE])
  527. test.Equal(t, "fork/repo", hs[0].Payload[GIT_REPOSITORY])
  528. }
  529. func Test_doWebHookExecutionBitbucketMultiple(t *testing.T) {
  530. log.SetLogger(t)
  531. s, cancel := setupTestHookService(t)
  532. defer cancel()
  533. task := &sdk.TaskExecution{
  534. UUID: sdk.RandomString(10),
  535. Type: TypeRepoManagerWebHook,
  536. WebHook: &sdk.WebHookExecution{
  537. RequestBody: []byte(bitbucketMultiplePushEvent),
  538. RequestHeader: map[string][]string{
  539. BitbucketHeader: {"repo:refs_changed"},
  540. },
  541. RequestURL: "",
  542. },
  543. }
  544. hs, err := s.doWebHookExecution(context.TODO(), task)
  545. test.NoError(t, err)
  546. assert.Equal(t, 2, len(hs))
  547. assert.Equal(t, "name-of-branch", hs[0].Payload["git.branch"])
  548. assert.Equal(t, "steven.guiheux", hs[0].Payload["git.author"])
  549. assert.Equal(t, "9f4fac7ec5642099982a86f584f2c4a362adb670", hs[0].Payload["git.hash"])
  550. assert.Equal(t, "name-of-branch-bis", hs[1].Payload["git.branch"])
  551. assert.Equal(t, "steven.guiheux", hs[1].Payload["git.author"])
  552. assert.Equal(t, "9f4fac7ec5642099982a86f584f2c4a362adb670", hs[0].Payload["git.hash"])
  553. }
  554. var bitbucketPrReviewerUpdated = `
  555. {
  556. "eventKey": "pr:reviewer:updated",
  557. "date": "2019-10-15T09:33:38+0200",
  558. "actor": {
  559. "name": "john.doe",
  560. "emailAddress": "john.doe@targate.fr",
  561. "id": 1363,
  562. "displayName": "john doe",
  563. "active": true,
  564. "slug": "foo",
  565. "type": "NORMAL",
  566. "links": {
  567. "self": [
  568. {
  569. "href": "https://bitbucket/users/bar"
  570. }
  571. ]
  572. }
  573. },
  574. "pullRequest": {
  575. "id": 666,
  576. "version": 0,
  577. "title": "My First PR",
  578. "state": "OPEN",
  579. "open": true,
  580. "closed": false,
  581. "createdDate": 1569939813210,
  582. "updatedDate": 1569939813210,
  583. "fromRef": {
  584. "id": "refs/heads/workflowUpdate1",
  585. "displayId": "src_branch",
  586. "latestCommit": "12345671234567",
  587. "repository": {
  588. "slug": "repo",
  589. "id": 11444,
  590. "name": "FOO",
  591. "scmId": "git",
  592. "state": "AVAILABLE",
  593. "statusMessage": "Available",
  594. "forkable": true,
  595. "project": {
  596. "key": "fork",
  597. "id": 112,
  598. "name": "foo",
  599. "type": "PERSONAL",
  600. "owner": {
  601. "name": "foo",
  602. "emailAddress": "foo@bar",
  603. "id": 1363,
  604. "displayName": "foo",
  605. "active": true,
  606. "slug": "foo",
  607. "type": "NORMAL",
  608. "links": {
  609. "self": [
  610. {
  611. "href": "https://bitbucket/users/bar"
  612. }
  613. ]
  614. }
  615. },
  616. "links": {
  617. "self": [
  618. {
  619. "href": "https://bitbucket/users/bar"
  620. }
  621. ]
  622. }
  623. },
  624. "public": false,
  625. "links": {
  626. "clone": [
  627. {
  628. "href": "https://bitbucket/scm/foo/bar.git",
  629. "name": "http"
  630. },
  631. {
  632. "href": "ssh://git@bitbucket:7999/foo/bar.git",
  633. "name": "ssh"
  634. }
  635. ],
  636. "self": [
  637. {
  638. "href": "https://bitbucket/users/foo/repos/bar/browse"
  639. }
  640. ]
  641. }
  642. }
  643. },
  644. "toRef": {
  645. "id": "refs/heads/dest_branch",
  646. "displayId": "dest_branch",
  647. "latestCommit": "654321654321",
  648. "repository": {
  649. "slug": "repo",
  650. "id": 11444,
  651. "name": "bar",
  652. "scmId": "git",
  653. "state": "AVAILABLE",
  654. "statusMessage": "Available",
  655. "forkable": true,
  656. "project": {
  657. "key": "my",
  658. "id": 112,
  659. "name": "my",
  660. "type": "PERSONAL",
  661. "owner": {
  662. "name": "foo",
  663. "emailAddress": "foo@bar",
  664. "id": 1363,
  665. "displayName": "foo",
  666. "active": true,
  667. "slug": "foo",
  668. "type": "NORMAL",
  669. "links": {
  670. "self": [
  671. {
  672. "href": "https://bitbucket/users/bar"
  673. }
  674. ]
  675. }
  676. },
  677. "links": {
  678. "self": [
  679. {
  680. "href": "https://bitbucket/users/bar"
  681. }
  682. ]
  683. }
  684. },
  685. "public": false,
  686. "links": {
  687. "clone": [
  688. {
  689. "href": "https://bitbucket/scm/bar/foo.git",
  690. "name": "http"
  691. },
  692. {
  693. "href": "ssh://git@bitbucket:7999/bar/foo.git",
  694. "name": "ssh"
  695. }
  696. ],
  697. "self": [
  698. {
  699. "href": "https://bitbucket/users/steven.guiheux/repos/ascoderepo/browse"
  700. }
  701. ]
  702. }
  703. }
  704. },
  705. "locked": false,
  706. "author": {
  707. "user": {
  708. "name": "cds",
  709. "emailAddress": "foo@bar.fr",
  710. "id": 7898,
  711. "displayName": "cds",
  712. "active": true,
  713. "slug": "cds",
  714. "type": "NORMAL",
  715. "links": {
  716. "self": [
  717. {
  718. "href": "http//foo/bar"
  719. }
  720. ]
  721. }
  722. },
  723. "role": "AUTHOR",
  724. "approved": false,
  725. "status": "UNAPPROVED"
  726. },
  727. "reviewers": [],
  728. "participants": [],
  729. "links": {
  730. "self": [
  731. {
  732. "href": "fff"
  733. }
  734. ]
  735. }
  736. },
  737. "addedReviewers": [
  738. {
  739. "name": "francois.samin",
  740. "emailAddress": "francois.samin@foo.bar",
  741. "id": 2427,
  742. "displayName": "François Samin",
  743. "active": true,
  744. "slug": "francois.samin",
  745. "type": "NORMAL"
  746. }
  747. ],
  748. "removedReviewers": []
  749. }`
  750. var bitbucketPrReviewerApproved = `
  751. {
  752. "eventKey": "pr:reviewer:approved",
  753. "date": "2019-10-15T09:33:38+0200",
  754. "actor": {
  755. "name": "john.doe",
  756. "emailAddress": "john.doe@targate.fr",
  757. "id": 1363,
  758. "displayName": "john doe",
  759. "active": true,
  760. "slug": "foo",
  761. "type": "NORMAL",
  762. "links": {
  763. "self": [
  764. {
  765. "href": "https://bitbucket/users/bar"
  766. }
  767. ]
  768. }
  769. },
  770. "pullRequest": {
  771. "id": 666,
  772. "version": 0,
  773. "title": "My First PR",
  774. "state": "OPEN",
  775. "open": true,
  776. "closed": false,
  777. "createdDate": 1569939813210,
  778. "updatedDate": 1569939813210,
  779. "fromRef": {
  780. "id": "refs/heads/workflowUpdate1",
  781. "displayId": "src_branch",
  782. "latestCommit": "12345671234567",
  783. "repository": {
  784. "slug": "repo",
  785. "id": 11444,
  786. "name": "FOO",
  787. "scmId": "git",
  788. "state": "AVAILABLE",
  789. "statusMessage": "Available",
  790. "forkable": true,
  791. "project": {
  792. "key": "fork",
  793. "id": 112,
  794. "name": "foo",
  795. "type": "PERSONAL",
  796. "owner": {
  797. "name": "foo",
  798. "emailAddress": "foo@bar",
  799. "id": 1363,
  800. "displayName": "foo",
  801. "active": true,
  802. "slug": "foo",
  803. "type": "NORMAL",
  804. "links": {
  805. "self": [
  806. {
  807. "href": "https://bitbucket/users/bar"
  808. }
  809. ]
  810. }
  811. },
  812. "links": {
  813. "self": [
  814. {
  815. "href": "https://bitbucket/users/bar"
  816. }
  817. ]
  818. }
  819. },
  820. "public": false,
  821. "links": {
  822. "clone": [
  823. {
  824. "href": "https://bitbucket/scm/foo/bar.git",
  825. "name": "http"
  826. },
  827. {
  828. "href": "ssh://git@bitbucket:7999/foo/bar.git",
  829. "name": "ssh"
  830. }
  831. ],
  832. "self": [
  833. {
  834. "href": "https://bitbucket/users/foo/repos/bar/browse"
  835. }
  836. ]
  837. }
  838. }
  839. },
  840. "toRef": {
  841. "id": "refs/heads/dest_branch",
  842. "displayId": "dest_branch",
  843. "latestCommit": "654321654321",
  844. "repository": {
  845. "slug": "repo",
  846. "id": 11444,
  847. "name": "bar",
  848. "scmId": "git",
  849. "state": "AVAILABLE",
  850. "statusMessage": "Available",
  851. "forkable": true,
  852. "project": {
  853. "key": "my",
  854. "id": 112,
  855. "name": "my",
  856. "type": "PERSONAL",
  857. "owner": {
  858. "name": "foo",
  859. "emailAddress": "foo@bar",
  860. "id": 1363,
  861. "displayName": "foo",
  862. "active": true,
  863. "slug": "foo",
  864. "type": "NORMAL",
  865. "links": {
  866. "self": [
  867. {
  868. "href": "https://bitbucket/users/bar"
  869. }
  870. ]
  871. }
  872. },
  873. "links": {
  874. "self": [
  875. {
  876. "href": "https://bitbucket/users/bar"
  877. }
  878. ]
  879. }
  880. },
  881. "public": false,
  882. "links": {
  883. "clone": [
  884. {
  885. "href": "https://bitbucket/scm/bar/foo.git",
  886. "name": "http"
  887. },
  888. {
  889. "href": "ssh://git@bitbucket:7999/bar/foo.git",
  890. "name": "ssh"
  891. }
  892. ],
  893. "self": [
  894. {
  895. "href": "https://bitbucket/users/steven.guiheux/repos/ascoderepo/browse"
  896. }
  897. ]
  898. }
  899. }
  900. },
  901. "locked": false,
  902. "author": {
  903. "user": {
  904. "name": "cds",
  905. "emailAddress": "foo@bar.fr",
  906. "id": 7898,
  907. "displayName": "cds",
  908. "active": true,
  909. "slug": "cds",
  910. "type": "NORMAL",
  911. "links": {
  912. "self": [
  913. {
  914. "href": "http//foo/bar"
  915. }
  916. ]
  917. }
  918. },
  919. "role": "AUTHOR",
  920. "approved": false,
  921. "status": "UNAPPROVED"
  922. },
  923. "reviewers": [],
  924. "participants": [],
  925. "links": {
  926. "self": [
  927. {
  928. "href": "fff"
  929. }
  930. ]
  931. }
  932. },
  933. "participant": {
  934. "user": {
  935. "name": "francois.samin",
  936. "emailAddress": "francois.samin@foo",
  937. "id": 2427,
  938. "displayName": "François Samin",
  939. "active": true,
  940. "slug": "francois.samin",
  941. "type": "NORMAL"
  942. },
  943. "lastReviewedCommit": "80f3f7e9b9da3cb3d7f11145709323d8a65d2922",
  944. "role": "REVIEWER",
  945. "approved": false,
  946. "status": "APPROVED"
  947. },
  948. "previousStatus": "UNAPPROVED"
  949. }`
  950. var bitbucketPrReviewerUnapproved = `
  951. {
  952. "eventKey": "pr:reviewer:unapproved",
  953. "date": "2019-10-15T09:33:38+0200",
  954. "actor": {
  955. "name": "john.doe",
  956. "emailAddress": "john.doe@targate.fr",
  957. "id": 1363,
  958. "displayName": "john doe",
  959. "active": true,
  960. "slug": "foo",
  961. "type": "NORMAL",
  962. "links": {
  963. "self": [
  964. {
  965. "href": "https://bitbucket/users/bar"
  966. }
  967. ]
  968. }
  969. },
  970. "pullRequest": {
  971. "id": 666,
  972. "version": 0,
  973. "title": "My First PR",
  974. "state": "OPEN",
  975. "open": true,
  976. "closed": false,
  977. "createdDate": 1569939813210,
  978. "updatedDate": 1569939813210,
  979. "fromRef": {
  980. "id": "refs/heads/workflowUpdate1",
  981. "displayId": "src_branch",
  982. "latestCommit": "12345671234567",
  983. "repository": {
  984. "slug": "repo",
  985. "id": 11444,
  986. "name": "FOO",
  987. "scmId": "git",
  988. "state": "AVAILABLE",
  989. "statusMessage": "Available",
  990. "forkable": true,
  991. "project": {
  992. "key": "fork",
  993. "id": 112,
  994. "name": "foo",
  995. "type": "PERSONAL",
  996. "owner": {
  997. "name": "foo",
  998. "emailAddress": "foo@bar",
  999. "id": 1363,
  1000. "displayName": "foo",
  1001. "active": true,
  1002. "slug": "foo",
  1003. "type": "NORMAL",
  1004. "links": {
  1005. "self": [
  1006. {
  1007. "href": "https://bitbucket/users/bar"
  1008. }
  1009. ]
  1010. }
  1011. },
  1012. "links": {
  1013. "self": [
  1014. {
  1015. "href": "https://bitbucket/users/bar"
  1016. }
  1017. ]
  1018. }
  1019. },
  1020. "public": false,
  1021. "links": {
  1022. "clone": [
  1023. {
  1024. "href": "https://bitbucket/scm/foo/bar.git",
  1025. "name": "http"
  1026. },
  1027. {
  1028. "href": "ssh://git@bitbucket:7999/foo/bar.git",
  1029. "name": "ssh"
  1030. }
  1031. ],
  1032. "self": [
  1033. {
  1034. "href": "https://bitbucket/users/foo/repos/bar/browse"
  1035. }
  1036. ]
  1037. }
  1038. }
  1039. },
  1040. "toRef": {
  1041. "id": "refs/heads/dest_branch",
  1042. "displayId": "dest_branch",
  1043. "latestCommit": "654321654321",
  1044. "repository": {
  1045. "slug": "repo",
  1046. "id": 11444,
  1047. "name": "bar",
  1048. "scmId": "git",
  1049. "state": "AVAILABLE",
  1050. "statusMessage": "Available",
  1051. "forkable": true,
  1052. "project": {
  1053. "key": "my",
  1054. "id": 112,
  1055. "name": "my",
  1056. "type": "PERSONAL",
  1057. "owner": {
  1058. "name": "foo",
  1059. "emailAddress": "foo@bar",
  1060. "id": 1363,
  1061. "displayName": "foo",
  1062. "active": true,
  1063. "slug": "foo",
  1064. "type": "NORMAL",
  1065. "links": {
  1066. "self": [
  1067. {
  1068. "href": "https://bitbucket/users/bar"
  1069. }
  1070. ]
  1071. }
  1072. },
  1073. "links": {
  1074. "self": [
  1075. {
  1076. "href": "https://bitbucket/users/bar"
  1077. }
  1078. ]
  1079. }
  1080. },
  1081. "public": false,
  1082. "links": {
  1083. "clone": [
  1084. {
  1085. "href": "https://bitbucket/scm/bar/foo.git",
  1086. "name": "http"
  1087. },
  1088. {
  1089. "href": "ssh://git@bitbucket:7999/bar/foo.git",
  1090. "name": "ssh"
  1091. }
  1092. ],
  1093. "self": [
  1094. {
  1095. "href": "https://bitbucket/users/steven.guiheux/repos/ascoderepo/browse"
  1096. }
  1097. ]
  1098. }
  1099. }
  1100. },
  1101. "locked": false,
  1102. "author": {
  1103. "user": {
  1104. "name": "cds",
  1105. "emailAddress": "foo@bar.fr",
  1106. "id": 7898,
  1107. "displayName": "cds",
  1108. "active": true,
  1109. "slug": "cds",
  1110. "type": "NORMAL",
  1111. "links": {
  1112. "self": [
  1113. {
  1114. "href": "http//foo/bar"
  1115. }
  1116. ]
  1117. }
  1118. },
  1119. "role": "AUTHOR",
  1120. "approved": false,
  1121. "status": "UNAPPROVED"
  1122. },
  1123. "reviewers": [],
  1124. "participants": [],
  1125. "links": {
  1126. "self": [
  1127. {
  1128. "href": "fff"
  1129. }
  1130. ]
  1131. }
  1132. },
  1133. "participant": {
  1134. "user": {
  1135. "name": "francois.samin",
  1136. "emailAddress": "francois.samin@foo",
  1137. "id": 2427,
  1138. "displayName": "François Samin",
  1139. "active": true,
  1140. "slug": "francois.samin",
  1141. "type": "NORMAL"
  1142. },
  1143. "lastReviewedCommit": "80f3f7e9b9da3cb3d7f11145709323d8a65d2922",
  1144. "role": "REVIEWER",
  1145. "approved": false,
  1146. "status": "UNAPPROVED"
  1147. },
  1148. "previousStatus": "APPROVED"
  1149. }`
  1150. var bitbucketPrReviewerNeedsWorks = `
  1151. {
  1152. "eventKey": "pr:reviewer:needs_work",
  1153. "date": "2019-10-15T09:33:38+0200",
  1154. "actor": {
  1155. "name": "john.doe",
  1156. "emailAddress": "john.doe@targate.fr",
  1157. "id": 1363,
  1158. "displayName": "john doe",
  1159. "active": true,
  1160. "slug": "foo",
  1161. "type": "NORMAL",
  1162. "links": {
  1163. "self": [
  1164. {
  1165. "href": "https://bitbucket/users/bar"
  1166. }
  1167. ]
  1168. }
  1169. },
  1170. "pullRequest": {
  1171. "id": 666,
  1172. "version": 0,
  1173. "title": "My First PR",
  1174. "state": "OPEN",
  1175. "open": true,
  1176. "closed": false,
  1177. "createdDate": 1569939813210,
  1178. "updatedDate": 1569939813210,
  1179. "fromRef": {
  1180. "id": "refs/heads/workflowUpdate1",
  1181. "displayId": "src_branch",
  1182. "latestCommit": "12345671234567",
  1183. "repository": {
  1184. "slug": "repo",
  1185. "id": 11444,
  1186. "name": "FOO",
  1187. "scmId": "git",
  1188. "state": "AVAILABLE",
  1189. "statusMessage": "Available",
  1190. "forkable": true,
  1191. "project": {
  1192. "key": "fork",
  1193. "id": 112,
  1194. "name": "foo",
  1195. "type": "PERSONAL",
  1196. "owner": {
  1197. "name": "foo",
  1198. "emailAddress": "foo@bar",
  1199. "id": 1363,
  1200. "displayName": "foo",
  1201. "active": true,
  1202. "slug": "foo",
  1203. "type": "NORMAL",
  1204. "links": {
  1205. "self": [
  1206. {
  1207. "href": "https://bitbucket/users/bar"
  1208. }
  1209. ]
  1210. }
  1211. },
  1212. "links": {
  1213. "self": [
  1214. {
  1215. "href": "https://bitbucket/users/bar"
  1216. }
  1217. ]
  1218. }
  1219. },
  1220. "public": false,
  1221. "links": {
  1222. "clone": [
  1223. {
  1224. "href": "https://bitbucket/scm/foo/bar.git",
  1225. "name": "http"
  1226. },
  1227. {
  1228. "href": "ssh://git@bitbucket:7999/foo/bar.git",
  1229. "name": "ssh"
  1230. }
  1231. ],
  1232. "self": [
  1233. {
  1234. "href": "https://bitbucket/users/foo/repos/bar/browse"
  1235. }
  1236. ]
  1237. }
  1238. }
  1239. },
  1240. "toRef": {
  1241. "id": "refs/heads/dest_branch",
  1242. "displayId": "dest_branch",
  1243. "latestCommit": "654321654321",
  1244. "repository": {
  1245. "slug": "repo",
  1246. "id": 11444,
  1247. "name": "bar",
  1248. "scmId": "git",
  1249. "state": "AVAILABLE",
  1250. "statusMessage": "Available",
  1251. "forkable": true,
  1252. "project": {
  1253. "key": "my",
  1254. "id": 112,
  1255. "name": "my",
  1256. "type": "PERSONAL",
  1257. "owner": {
  1258. "name": "foo",
  1259. "emailAddress": "foo@bar",
  1260. "id": 1363,
  1261. "displayName": "foo",
  1262. "active": true,
  1263. "slug": "foo",
  1264. "type": "NORMAL",
  1265. "links": {
  1266. "self": [
  1267. {
  1268. "href": "https://bitbucket/users/bar"
  1269. }
  1270. ]
  1271. }
  1272. },
  1273. "links": {
  1274. "self": [
  1275. {
  1276. "href": "https://bitbucket/users/bar"
  1277. }
  1278. ]
  1279. }
  1280. },
  1281. "public": false,
  1282. "links": {
  1283. "clone": [
  1284. {
  1285. "href": "https://bitbucket/scm/bar/foo.git",
  1286. "name": "http"
  1287. },
  1288. {
  1289. "href": "ssh://git@bitbucket:7999/bar/foo.git",
  1290. "name": "ssh"
  1291. }
  1292. ],
  1293. "self": [
  1294. {
  1295. "href": "https://bitbucket/users/steven.guiheux/repos/ascoderepo/browse"
  1296. }
  1297. ]
  1298. }
  1299. }
  1300. },
  1301. "locked": false,
  1302. "author": {
  1303. "user": {
  1304. "name": "cds",
  1305. "emailAddress": "foo@bar.fr",
  1306. "id": 7898,
  1307. "displayName": "cds",
  1308. "active": true,
  1309. "slug": "cds",
  1310. "type": "NORMAL",
  1311. "links": {
  1312. "self": [
  1313. {
  1314. "href": "http//foo/bar"
  1315. }
  1316. ]
  1317. }
  1318. },
  1319. "role": "AUTHOR",
  1320. "approved": false,
  1321. "status": "UNAPPROVED"
  1322. },
  1323. "reviewers": [],
  1324. "participants": [],
  1325. "links": {
  1326. "self": [
  1327. {
  1328. "href": "fff"
  1329. }
  1330. ]
  1331. }
  1332. },
  1333. "participant": {
  1334. "user": {
  1335. "name": "francois.samin",
  1336. "emailAddress": "francois.samin@foo",
  1337. "id": 2427,
  1338. "displayName": "François Samin",
  1339. "active": true,
  1340. "slug": "francois.samin",
  1341. "type": "NORMAL"
  1342. },
  1343. "lastReviewedCommit": "80f3f7e9b9da3cb3d7f11145709323d8a65d2922",
  1344. "role": "REVIEWER",
  1345. "approved": false,
  1346. "status": "NEEDS_WORK"
  1347. },
  1348. "previousStatus": "UNAPPROVED"
  1349. }`
  1350. var bitbucketPrCommentAdded = `
  1351. {
  1352. "eventKey": "pr:comment:added",
  1353. "date": "2019-10-15T09:33:38+0200",
  1354. "actor": {
  1355. "name": "john.doe",
  1356. "emailAddress": "john.doe@targate.fr",
  1357. "id": 1363,
  1358. "displayName": "john doe",
  1359. "active": true,
  1360. "slug": "foo",
  1361. "type": "NORMAL",
  1362. "links": {
  1363. "self": [
  1364. {
  1365. "href": "https://bitbucket/users/bar"
  1366. }
  1367. ]
  1368. }
  1369. },
  1370. "pullRequest": {
  1371. "id": 666,
  1372. "version": 0,
  1373. "title": "My First PR",
  1374. "state": "OPEN",
  1375. "open": true,
  1376. "closed": false,
  1377. "createdDate": 1569939813210,
  1378. "updatedDate": 1569939813210,
  1379. "fromRef": {
  1380. "id": "refs/heads/workflowUpdate1",
  1381. "displayId": "src_branch",
  1382. "latestCommit": "12345671234567",
  1383. "repository": {
  1384. "slug": "repo",
  1385. "id": 11444,
  1386. "name": "FOO",
  1387. "scmId": "git",
  1388. "state": "AVAILABLE",
  1389. "statusMessage": "Available",
  1390. "forkable": true,
  1391. "project": {
  1392. "key": "fork",
  1393. "id": 112,
  1394. "name": "foo",
  1395. "type": "PERSONAL",
  1396. "owner": {
  1397. "name": "foo",
  1398. "emailAddress": "foo@bar",
  1399. "id": 1363,
  1400. "displayName": "foo",
  1401. "active": true,
  1402. "slug": "foo",
  1403. "type": "NORMAL",
  1404. "links": {
  1405. "self": [
  1406. {
  1407. "href": "https://bitbucket/users/bar"
  1408. }
  1409. ]
  1410. }
  1411. },
  1412. "links": {
  1413. "self": [
  1414. {
  1415. "href": "https://bitbucket/users/bar"
  1416. }
  1417. ]
  1418. }
  1419. },
  1420. "public": false,
  1421. "links": {
  1422. "clone": [
  1423. {
  1424. "href": "https://bitbucket/scm/foo/bar.git",
  1425. "name": "http"
  1426. },
  1427. {
  1428. "href": "ssh://git@bitbucket:7999/foo/bar.git",
  1429. "name": "ssh"
  1430. }
  1431. ],
  1432. "self": [
  1433. {
  1434. "href": "https://bitbucket/users/foo/repos/bar/browse"
  1435. }
  1436. ]
  1437. }
  1438. }
  1439. },
  1440. "toRef": {
  1441. "id": "refs/heads/dest_branch",
  1442. "displayId": "dest_branch",
  1443. "latestCommit": "654321654321",
  1444. "repository": {
  1445. "slug": "repo",
  1446. "id": 11444,
  1447. "name": "bar",
  1448. "scmId": "git",
  1449. "state": "AVAILABLE",
  1450. "statusMessage": "Available",
  1451. "forkable": true,
  1452. "project": {
  1453. "key": "my",
  1454. "id": 112,
  1455. "name": "my",
  1456. "type": "PERSONAL",
  1457. "owner": {
  1458. "name": "foo",
  1459. "emailAddress": "foo@bar",
  1460. "id": 1363,
  1461. "displayName": "foo",
  1462. "active": true,
  1463. "slug": "foo",
  1464. "type": "NORMAL",
  1465. "links": {
  1466. "self": [
  1467. {
  1468. "href": "https://bitbucket/users/bar"
  1469. }
  1470. ]
  1471. }
  1472. },
  1473. "links": {
  1474. "self": [
  1475. {
  1476. "href": "https://bitbucket/users/bar"
  1477. }
  1478. ]
  1479. }
  1480. },
  1481. "public": false,
  1482. "links": {
  1483. "clone": [
  1484. {
  1485. "href": "https://bitbucket/scm/bar/foo.git",
  1486. "name": "http"
  1487. },
  1488. {
  1489. "href": "ssh://git@bitbucket:7999/bar/foo.git",
  1490. "name": "ssh"
  1491. }
  1492. ],
  1493. "self": [
  1494. {
  1495. "href": "https://bitbucket/users/steven.guiheux/repos/ascoderepo/browse"
  1496. }
  1497. ]
  1498. }
  1499. }
  1500. },
  1501. "locked": false,
  1502. "author": {
  1503. "user": {
  1504. "name": "cds",
  1505. "emailAddress": "foo@bar.fr",
  1506. "id": 7898,
  1507. "displayName": "cds",
  1508. "active": true,
  1509. "slug": "cds",
  1510. "type": "NORMAL",
  1511. "links": {
  1512. "self": [
  1513. {
  1514. "href": "http//foo/bar"
  1515. }
  1516. ]
  1517. }
  1518. },
  1519. "role": "AUTHOR",
  1520. "approved": false,
  1521. "status": "UNAPPROVED"
  1522. },
  1523. "reviewers": [],
  1524. "participants": [],
  1525. "links": {
  1526. "self": [
  1527. {
  1528. "href": "fff"
  1529. }
  1530. ]
  1531. }
  1532. },
  1533. "comment": {
  1534. "properties": {
  1535. "repositoryId": 7716
  1536. },
  1537. "id": 252969,
  1538. "version": 1,
  1539. "text": "my comment added",
  1540. "author": {
  1541. "name": "steven.guiheux",
  1542. "emailAddress": "steven.guiheux@foo",
  1543. "id": 1363,
  1544. "displayName": "Steven Guiheux",
  1545. "active": true,
  1546. "slug": "steven.guiheux",
  1547. "type": "NORMAL"
  1548. },
  1549. "createdDate": 1571042924878,
  1550. "updatedDate": 1571044442062,
  1551. "comments": [],
  1552. "tasks": []
  1553. }
  1554. }`
  1555. var bitbucketPrCommentDeleted = `
  1556. {
  1557. "eventKey": "pr:comment:deleted",
  1558. "date": "2019-10-15T09:33:38+0200",
  1559. "actor": {
  1560. "name": "john.doe",
  1561. "emailAddress": "john.doe@targate.fr",
  1562. "id": 1363,
  1563. "displayName": "john doe",
  1564. "active": true,
  1565. "slug": "foo",
  1566. "type": "NORMAL",
  1567. "links": {
  1568. "self": [
  1569. {
  1570. "href": "https://bitbucket/users/bar"
  1571. }
  1572. ]
  1573. }
  1574. },
  1575. "pullRequest": {
  1576. "id": 666,
  1577. "version": 0,
  1578. "title": "My First PR",
  1579. "state": "OPEN",
  1580. "open": true,
  1581. "closed": false,
  1582. "createdDate": 1569939813210,
  1583. "updatedDate": 1569939813210,
  1584. "fromRef": {
  1585. "id": "refs/heads/workflowUpdate1",
  1586. "displayId": "src_branch",
  1587. "latestCommit": "12345671234567",
  1588. "repository": {
  1589. "slug": "repo",
  1590. "id": 11444,
  1591. "name": "FOO",
  1592. "scmId": "git",
  1593. "state": "AVAILABLE",
  1594. "statusMessage": "Available",
  1595. "forkable": true,
  1596. "project": {
  1597. "key": "fork",
  1598. "id": 112,
  1599. "name": "foo",
  1600. "type": "PERSONAL",
  1601. "owner": {
  1602. "name": "foo",
  1603. "emailAddress": "foo@bar",
  1604. "id": 1363,
  1605. "displayName": "foo",
  1606. "active": true,
  1607. "slug": "foo",
  1608. "type": "NORMAL",
  1609. "links": {
  1610. "self": [
  1611. {
  1612. "href": "https://bitbucket/users/bar"
  1613. }
  1614. ]
  1615. }
  1616. },
  1617. "links": {
  1618. "self": [
  1619. {
  1620. "href": "https://bitbucket/users/bar"
  1621. }
  1622. ]
  1623. }
  1624. },
  1625. "public": false,
  1626. "links": {
  1627. "clone": [
  1628. {
  1629. "href": "https://bitbucket/scm/foo/bar.git",
  1630. "name": "http"
  1631. },
  1632. {
  1633. "href": "ssh://git@bitbucket:7999/foo/bar.git",
  1634. "name": "ssh"
  1635. }
  1636. ],
  1637. "self": [
  1638. {
  1639. "href": "https://bitbucket/users/foo/repos/bar/browse"
  1640. }
  1641. ]
  1642. }
  1643. }
  1644. },
  1645. "toRef": {
  1646. "id": "refs/heads/dest_branch",
  1647. "displayId": "dest_branch",
  1648. "latestCommit": "654321654321",
  1649. "repository": {
  1650. "slug": "repo",
  1651. "id": 11444,
  1652. "name": "bar",
  1653. "scmId": "git",
  1654. "state": "AVAILABLE",
  1655. "statusMessage": "Available",
  1656. "forkable": true,
  1657. "project": {
  1658. "key": "my",
  1659. "id": 112,
  1660. "name": "my",
  1661. "type": "PERSONAL",
  1662. "owner": {
  1663. "name": "foo",
  1664. "emailAddress": "foo@bar",
  1665. "id": 1363,
  1666. "displayName": "foo",
  1667. "active": true,
  1668. "slug": "foo",
  1669. "type": "NORMAL",
  1670. "links": {
  1671. "self": [
  1672. {
  1673. "href": "https://bitbucket/users/bar"
  1674. }
  1675. ]
  1676. }
  1677. },
  1678. "links": {
  1679. "self": [
  1680. {
  1681. "href": "https://bitbucket/users/bar"
  1682. }
  1683. ]
  1684. }
  1685. },
  1686. "public": false,
  1687. "links": {
  1688. "clone": [
  1689. {
  1690. "href": "https://bitbucket/scm/bar/foo.git",
  1691. "name": "http"
  1692. },
  1693. {
  1694. "href": "ssh://git@bitbucket:7999/bar/foo.git",
  1695. "name": "ssh"
  1696. }
  1697. ],
  1698. "self": [
  1699. {
  1700. "href": "https://bitbucket/users/steven.guiheux/repos/ascoderepo/browse"
  1701. }
  1702. ]
  1703. }
  1704. }
  1705. },
  1706. "locked": false,
  1707. "author": {
  1708. "user": {
  1709. "name": "cds",
  1710. "emailAddress": "foo@bar.fr",
  1711. "id": 7898,
  1712. "displayName": "cds",
  1713. "active": true,
  1714. "slug": "cds",
  1715. "type": "NORMAL",
  1716. "links": {
  1717. "self": [
  1718. {
  1719. "href": "http//foo/bar"
  1720. }
  1721. ]
  1722. }
  1723. },
  1724. "role": "AUTHOR",
  1725. "approved": false,
  1726. "status": "UNAPPROVED"
  1727. },
  1728. "reviewers": [],
  1729. "participants": [],
  1730. "links": {
  1731. "self": [
  1732. {
  1733. "href": "fff"
  1734. }
  1735. ]
  1736. }
  1737. },
  1738. "comment": {
  1739. "properties": {
  1740. "repositoryId": 7716
  1741. },
  1742. "id": 252969,
  1743. "version": 1,
  1744. "text": "my comment deleted",
  1745. "author": {
  1746. "name": "steven.guiheux",
  1747. "emailAddress": "steven.guiheux@foo",
  1748. "id": 1363,
  1749. "displayName": "Steven Guiheux",
  1750. "active": true,
  1751. "slug": "steven.guiheux",
  1752. "type": "NORMAL"
  1753. },
  1754. "createdDate": 1571042924878,
  1755. "updatedDate": 1571044442062,
  1756. "comments": [],
  1757. "tasks": []
  1758. }
  1759. }`
  1760. var bitbucketPrCommentModified = `
  1761. {
  1762. "eventKey": "pr:comment:edited",
  1763. "date": "2019-10-15T09:33:38+0200",
  1764. "actor": {
  1765. "name": "john.doe",
  1766. "emailAddress": "john.doe@targate.fr",
  1767. "id": 1363,
  1768. "displayName": "john doe",
  1769. "active": true,
  1770. "slug": "foo",
  1771. "type": "NORMAL",
  1772. "links": {
  1773. "self": [
  1774. {
  1775. "href": "https://bitbucket/users/bar"
  1776. }
  1777. ]
  1778. }
  1779. },
  1780. "pullRequest": {
  1781. "id": 666,
  1782. "version": 0,
  1783. "title": "My First PR",
  1784. "state": "OPEN",
  1785. "open": true,
  1786. "closed": false,
  1787. "createdDate": 1569939813210,
  1788. "updatedDate": 1569939813210,
  1789. "fromRef": {
  1790. "id": "refs/heads/workflowUpdate1",
  1791. "displayId": "src_branch",
  1792. "latestCommit": "12345671234567",
  1793. "repository": {
  1794. "slug": "repo",
  1795. "id": 11444,
  1796. "name": "FOO",
  1797. "scmId": "git",
  1798. "state": "AVAILABLE",
  1799. "statusMessage": "Available",
  1800. "forkable": true,
  1801. "project": {
  1802. "key": "fork",
  1803. "id": 112,
  1804. "name": "foo",
  1805. "type": "PERSONAL",
  1806. "owner": {
  1807. "name": "foo",
  1808. "emailAddress": "foo@bar",
  1809. "id": 1363,
  1810. "displayName": "foo",
  1811. "active": true,
  1812. "slug": "foo",
  1813. "type": "NORMAL",
  1814. "links": {
  1815. "self": [
  1816. {
  1817. "href": "https://bitbucket/users/bar"
  1818. }
  1819. ]
  1820. }
  1821. },
  1822. "links": {
  1823. "self": [
  1824. {
  1825. "href": "https://bitbucket/users/bar"
  1826. }
  1827. ]
  1828. }
  1829. },
  1830. "public": false,
  1831. "links": {
  1832. "clone": [
  1833. {
  1834. "href": "https://bitbucket/scm/foo/bar.git",
  1835. "name": "http"
  1836. },
  1837. {
  1838. "href": "ssh://git@bitbucket:7999/foo/bar.git",
  1839. "name": "ssh"
  1840. }
  1841. ],
  1842. "self": [
  1843. {
  1844. "href": "https://bitbucket/users/foo/repos/bar/browse"
  1845. }
  1846. ]
  1847. }
  1848. }
  1849. },
  1850. "toRef": {
  1851. "id": "refs/heads/dest_branch",
  1852. "displayId": "dest_branch",
  1853. "latestCommit": "654321654321",
  1854. "repository": {
  1855. "slug": "repo",
  1856. "id": 11444,
  1857. "name": "bar",
  1858. "scmId": "git",
  1859. "state": "AVAILABLE",
  1860. "statusMessage": "Available",
  1861. "forkable": true,
  1862. "project": {
  1863. "key": "my",
  1864. "id": 112,
  1865. "name": "my",
  1866. "type": "PERSONAL",
  1867. "owner": {
  1868. "name": "foo",
  1869. "emailAddress": "foo@bar",
  1870. "id": 1363,
  1871. "displayName": "foo",
  1872. "active": true,
  1873. "slug": "foo",
  1874. "type": "NORMAL",
  1875. "links": {
  1876. "self": [
  1877. {
  1878. "href": "https://bitbucket/users/bar"
  1879. }
  1880. ]
  1881. }
  1882. },
  1883. "links": {
  1884. "self": [
  1885. {
  1886. "href": "https://bitbucket/users/bar"
  1887. }
  1888. ]
  1889. }
  1890. },
  1891. "public": false,
  1892. "links": {
  1893. "clone": [
  1894. {
  1895. "href": "https://bitbucket/scm/bar/foo.git",
  1896. "name": "http"
  1897. },
  1898. {
  1899. "href": "ssh://git@bitbucket:7999/bar/foo.git",
  1900. "name": "ssh"
  1901. }
  1902. ],
  1903. "self": [
  1904. {
  1905. "href": "https://bitbucket/users/steven.guiheux/repos/ascoderepo/browse"
  1906. }
  1907. ]
  1908. }
  1909. }
  1910. },
  1911. "locked": false,
  1912. "author": {
  1913. "user": {
  1914. "name": "cds",
  1915. "emailAddress": "foo@bar.fr",
  1916. "id": 7898,
  1917. "displayName": "cds",
  1918. "active": true,
  1919. "slug": "cds",
  1920. "type": "NORMAL",
  1921. "links": {
  1922. "self": [
  1923. {
  1924. "href": "http//foo/bar"
  1925. }
  1926. ]
  1927. }
  1928. },
  1929. "role": "AUTHOR",
  1930. "approved": false,
  1931. "status": "UNAPPROVED"
  1932. },
  1933. "reviewers": [],
  1934. "participants": [],
  1935. "links": {
  1936. "self": [
  1937. {
  1938. "href": "fff"
  1939. }
  1940. ]
  1941. }
  1942. },
  1943. "comment": {
  1944. "properties": {
  1945. "repositoryId": 7716
  1946. },
  1947. "id": 252969,
  1948. "version": 1,
  1949. "text": "my comment edited",
  1950. "author": {
  1951. "name": "steven.guiheux",
  1952. "emailAddress": "steven.guiheux@foo",
  1953. "id": 1363,
  1954. "displayName": "Steven Guiheux",
  1955. "active": true,
  1956. "slug": "steven.guiheux",
  1957. "type": "NORMAL"
  1958. },
  1959. "createdDate": 1571042924878,
  1960. "updatedDate": 1571044442062,
  1961. "comments": [],
  1962. "tasks": []
  1963. },
  1964. "previousComment": "moi aussi"
  1965. }`
  1966. var bitbucketPrModified = `
  1967. {
  1968. "eventKey": "pr:modified",
  1969. "date": "2019-10-15T09:33:38+0200",
  1970. "actor": {
  1971. "name": "john.doe",
  1972. "emailAddress": "john.doe@targate.fr",
  1973. "id": 1363,
  1974. "displayName": "john doe",
  1975. "active": true,
  1976. "slug": "foo",
  1977. "type": "NORMAL",
  1978. "links": {
  1979. "self": [
  1980. {
  1981. "href": "https://bitbucket/users/bar"
  1982. }
  1983. ]
  1984. }
  1985. },
  1986. "pullRequest": {
  1987. "id": 666,
  1988. "version": 0,
  1989. "title": "My First PR",
  1990. "state": "OPEN",
  1991. "open": true,
  1992. "closed": false,
  1993. "createdDate": 1569939813210,
  1994. "updatedDate": 1569939813210,
  1995. "fromRef": {
  1996. "id": "refs/heads/workflowUpdate1",
  1997. "displayId": "src_branch",
  1998. "latestCommit": "12345671234567",
  1999. "repository": {
  2000. "slug": "repo",
  2001. "id": 11444,
  2002. "name": "FOO",
  2003. "scmId": "git",
  2004. "state": "AVAILABLE",
  2005. "statusMessage": "Available",
  2006. "forkable": true,
  2007. "project": {
  2008. "key": "fork",
  2009. "id": 112,
  2010. "name": "foo",
  2011. "type": "PERSONAL",
  2012. "owner": {
  2013. "name": "foo",
  2014. "emailAddress": "foo@bar",
  2015. "id": 1363,
  2016. "displayName": "foo",
  2017. "active": true,
  2018. "slug": "foo",
  2019. "type": "NORMAL",
  2020. "links": {
  2021. "self": [
  2022. {
  2023. "href": "https://bitbucket/users/bar"
  2024. }
  2025. ]
  2026. }
  2027. },
  2028. "links": {
  2029. "self": [
  2030. {
  2031. "href": "https://bitbucket/users/bar"
  2032. }
  2033. ]
  2034. }
  2035. },
  2036. "public": false,
  2037. "links": {
  2038. "clone": [
  2039. {
  2040. "href": "https://bitbucket/scm/foo/bar.git",
  2041. "name": "http"
  2042. },
  2043. {
  2044. "href": "ssh://git@bitbucket:7999/foo/bar.git",
  2045. "name": "ssh"
  2046. }
  2047. ],
  2048. "self": [
  2049. {
  2050. "href": "https://bitbucket/users/foo/repos/bar/browse"
  2051. }
  2052. ]
  2053. }
  2054. }
  2055. },
  2056. "toRef": {
  2057. "id": "refs/heads/dest_branch",
  2058. "displayId": "dest_branch",
  2059. "latestCommit": "654321654321",
  2060. "repository": {
  2061. "slug": "repo",
  2062. "id": 11444,
  2063. "name": "bar",
  2064. "scmId": "git",
  2065. "state": "AVAILABLE",
  2066. "statusMessage": "Available",
  2067. "forkable": true,
  2068. "project": {
  2069. "key": "my",
  2070. "id": 112,
  2071. "name": "my",
  2072. "type": "PERSONAL",
  2073. "owner": {
  2074. "name": "foo",
  2075. "emailAddress": "foo@bar",
  2076. "id": 1363,
  2077. "displayName": "foo",
  2078. "active": true,
  2079. "slug": "foo",
  2080. "type": "NORMAL",
  2081. "links": {
  2082. "self": [
  2083. {
  2084. "href": "https://bitbucket/users/bar"
  2085. }
  2086. ]
  2087. }
  2088. },
  2089. "links": {
  2090. "self": [
  2091. {
  2092. "href": "https://bitbucket/users/bar"
  2093. }
  2094. ]
  2095. }
  2096. },
  2097. "public": false,
  2098. "links": {
  2099. "clone": [
  2100. {
  2101. "href": "https://bitbucket/scm/bar/foo.git",
  2102. "name": "http"
  2103. },
  2104. {
  2105. "href": "ssh://git@bitbucket:7999/bar/foo.git",
  2106. "name": "ssh"
  2107. }
  2108. ],
  2109. "self": [
  2110. {
  2111. "href": "https://bitbucket/users/steven.guiheux/repos/ascoderepo/browse"
  2112. }
  2113. ]
  2114. }
  2115. }
  2116. },
  2117. "locked": false,
  2118. "author": {
  2119. "user": {
  2120. "name": "cds",
  2121. "emailAddress": "foo@bar.fr",
  2122. "id": 7898,
  2123. "displayName": "cds",
  2124. "active": true,
  2125. "slug": "cds",
  2126. "type": "NORMAL",
  2127. "links": {
  2128. "self": [
  2129. {
  2130. "href": "http//foo/bar"
  2131. }
  2132. ]
  2133. }
  2134. },
  2135. "role": "AUTHOR",
  2136. "approved": false,
  2137. "status": "UNAPPROVED"
  2138. },
  2139. "reviewers": [],
  2140. "participants": [],
  2141. "links": {
  2142. "self": [
  2143. {
  2144. "href": "fff"
  2145. }
  2146. ]
  2147. }
  2148. },
  2149. "previousTitle": "Update README.md",
  2150. "previousDescription": null,
  2151. "previousTarget": {
  2152. "id": "refs/heads/master",
  2153. "displayId": "prev_branch",
  2154. "type": "BRANCH",
  2155. "latestCommit": "0987654321",
  2156. "latestChangeset": "0987654321"
  2157. }
  2158. }`
  2159. var bitbucketPrMerged = `
  2160. {
  2161. "eventKey": "pr:opened",
  2162. "date": "2019-10-15T09:33:38+0200",
  2163. "actor": {
  2164. "name": "john.doe",
  2165. "emailAddress": "john.doe@targate.fr",
  2166. "id": 1363,
  2167. "displayName": "john doe",
  2168. "active": true,
  2169. "slug": "foo",
  2170. "type": "NORMAL",
  2171. "links": {
  2172. "self": [
  2173. {
  2174. "href": "https://bitbucket/users/bar"
  2175. }
  2176. ]
  2177. }
  2178. },
  2179. "pullRequest": {
  2180. "id": 666,
  2181. "version": 0,
  2182. "title": "My First PR",
  2183. "state": "MERGED",
  2184. "open": true,
  2185. "closed": false,
  2186. "createdDate": 1569939813210,
  2187. "updatedDate": 1569939813210,
  2188. "fromRef": {
  2189. "id": "refs/heads/workflowUpdate1",
  2190. "displayId": "src_branch",
  2191. "latestCommit": "12345671234567",
  2192. "repository": {
  2193. "slug": "repo",
  2194. "id": 11444,
  2195. "name": "FOO",
  2196. "scmId": "git",
  2197. "state": "AVAILABLE",
  2198. "statusMessage": "Available",
  2199. "forkable": true,
  2200. "project": {
  2201. "key": "fork",
  2202. "id": 112,
  2203. "name": "foo",
  2204. "type": "PERSONAL",
  2205. "owner": {
  2206. "name": "foo",
  2207. "emailAddress": "foo@bar",
  2208. "id": 1363,
  2209. "displayName": "foo",
  2210. "active": true,
  2211. "slug": "foo",
  2212. "type": "NORMAL",
  2213. "links": {
  2214. "self": [
  2215. {
  2216. "href": "https://bitbucket/users/bar"
  2217. }
  2218. ]
  2219. }
  2220. },
  2221. "links": {
  2222. "self": [
  2223. {
  2224. "href": "https://bitbucket/users/bar"
  2225. }
  2226. ]
  2227. }
  2228. },
  2229. "public": false,
  2230. "links": {
  2231. "clone": [
  2232. {
  2233. "href": "https://bitbucket/scm/foo/bar.git",
  2234. "name": "http"
  2235. },
  2236. {
  2237. "href": "ssh://git@bitbucket:7999/foo/bar.git",
  2238. "name": "ssh"
  2239. }
  2240. ],
  2241. "self": [
  2242. {
  2243. "href": "https://bitbucket/users/foo/repos/bar/browse"
  2244. }
  2245. ]
  2246. }
  2247. }
  2248. },
  2249. "toRef": {
  2250. "id": "refs/heads/dest_branch",
  2251. "displayId": "dest_branch",
  2252. "latestCommit": "654321654321",
  2253. "repository": {
  2254. "slug": "repo",
  2255. "id": 11444,
  2256. "name": "bar",
  2257. "scmId": "git",
  2258. "state": "AVAILABLE",
  2259. "statusMessage": "Available",
  2260. "forkable": true,
  2261. "project": {
  2262. "key": "my",
  2263. "id": 112,
  2264. "name": "my",
  2265. "type": "PERSONAL",
  2266. "owner": {
  2267. "name": "foo",
  2268. "emailAddress": "foo@bar",
  2269. "id": 1363,
  2270. "displayName": "foo",
  2271. "active": true,
  2272. "slug": "foo",
  2273. "type": "NORMAL",
  2274. "links": {
  2275. "self": [
  2276. {
  2277. "href": "https://bitbucket/users/bar"
  2278. }
  2279. ]
  2280. }
  2281. },
  2282. "links": {
  2283. "self": [
  2284. {
  2285. "href": "https://bitbucket/users/bar"
  2286. }
  2287. ]
  2288. }
  2289. },
  2290. "public": false,
  2291. "links": {
  2292. "clone": [
  2293. {
  2294. "href": "https://bitbucket/scm/bar/foo.git",
  2295. "name": "http"
  2296. },
  2297. {
  2298. "href": "ssh://git@bitbucket:7999/bar/foo.git",
  2299. "name": "ssh"
  2300. }
  2301. ],
  2302. "self": [
  2303. {
  2304. "href": "https://bitbucket/users/steven.guiheux/repos/ascoderepo/browse"
  2305. }
  2306. ]
  2307. }
  2308. }
  2309. },
  2310. "locked": false,
  2311. "author": {
  2312. "user": {
  2313. "name": "cds",
  2314. "emailAddress": "foo@bar.fr",
  2315. "id": 7898,
  2316. "displayName": "cds",
  2317. "active": true,
  2318. "slug": "cds",
  2319. "type": "NORMAL",
  2320. "links": {
  2321. "self": [
  2322. {
  2323. "href": "http//foo/bar"
  2324. }
  2325. ]
  2326. }
  2327. },
  2328. "role": "AUTHOR",
  2329. "approved": false,
  2330. "status": "UNAPPROVED"
  2331. },
  2332. "reviewers": [],
  2333. "participants": [],
  2334. "links": {
  2335. "self": [
  2336. {
  2337. "href": "fff"
  2338. }
  2339. ]
  2340. }
  2341. }
  2342. }`
  2343. var bitbucketPrOpened = `
  2344. {
  2345. "eventKey": "pr:opened",
  2346. "date": "2019-10-15T09:33:38+0200",
  2347. "actor": {
  2348. "name": "john.doe",
  2349. "emailAddress": "john.doe@targate.fr",
  2350. "id": 1363,
  2351. "displayName": "john doe",
  2352. "active": true,
  2353. "slug": "foo",
  2354. "type": "NORMAL",
  2355. "links": {
  2356. "self": [
  2357. {
  2358. "href": "https://bitbucket/users/bar"
  2359. }
  2360. ]
  2361. }
  2362. },
  2363. "pullRequest": {
  2364. "id": 666,
  2365. "version": 0,
  2366. "title": "My First PR",
  2367. "state": "OPEN",
  2368. "open": true,
  2369. "closed": false,
  2370. "createdDate": 1569939813210,
  2371. "updatedDate": 1569939813210,
  2372. "fromRef": {
  2373. "id": "refs/heads/workflowUpdate1",
  2374. "displayId": "src_branch",
  2375. "latestCommit": "12345671234567",
  2376. "repository": {
  2377. "slug": "repo",
  2378. "id": 11444,
  2379. "name": "FOO",
  2380. "scmId": "git",
  2381. "state": "AVAILABLE",
  2382. "statusMessage": "Available",
  2383. "forkable": true,
  2384. "project": {
  2385. "key": "fork",
  2386. "id": 112,
  2387. "name": "foo",
  2388. "type": "PERSONAL",
  2389. "owner": {
  2390. "name": "foo",
  2391. "emailAddress": "foo@bar",
  2392. "id": 1363,
  2393. "displayName": "foo",
  2394. "active": true,
  2395. "slug": "foo",
  2396. "type": "NORMAL",
  2397. "links": {
  2398. "self": [
  2399. {
  2400. "href": "https://bitbucket/users/bar"
  2401. }
  2402. ]
  2403. }
  2404. },
  2405. "links": {
  2406. "self": [
  2407. {
  2408. "href": "https://bitbucket/users/bar"
  2409. }
  2410. ]
  2411. }
  2412. },
  2413. "public": false,
  2414. "links": {
  2415. "clone": [
  2416. {
  2417. "href": "https://bitbucket/scm/foo/bar.git",
  2418. "name": "http"
  2419. },
  2420. {
  2421. "href": "ssh://git@bitbucket:7999/foo/bar.git",
  2422. "name": "ssh"
  2423. }
  2424. ],
  2425. "self": [
  2426. {
  2427. "href": "https://bitbucket/users/foo/repos/bar/browse"
  2428. }
  2429. ]
  2430. }
  2431. }
  2432. },
  2433. "toRef": {
  2434. "id": "refs/heads/dest_branch",
  2435. "displayId": "dest_branch",
  2436. "latestCommit": "654321654321",
  2437. "repository": {
  2438. "slug": "repo",
  2439. "id": 11444,
  2440. "name": "bar",
  2441. "scmId": "git",
  2442. "state": "AVAILABLE",
  2443. "statusMessage": "Available",
  2444. "forkable": true,
  2445. "project": {
  2446. "key": "my",
  2447. "id": 112,
  2448. "name": "my",
  2449. "type": "PERSONAL",
  2450. "owner": {
  2451. "name": "foo",
  2452. "emailAddress": "foo@bar",
  2453. "id": 1363,
  2454. "displayName": "foo",
  2455. "active": true,
  2456. "slug": "foo",
  2457. "type": "NORMAL",
  2458. "links": {
  2459. "self": [
  2460. {
  2461. "href": "https://bitbucket/users/bar"
  2462. }
  2463. ]
  2464. }
  2465. },
  2466. "links": {
  2467. "self": [
  2468. {
  2469. "href": "https://bitbucket/users/bar"
  2470. }
  2471. ]
  2472. }
  2473. },
  2474. "public": false,
  2475. "links": {
  2476. "clone": [
  2477. {
  2478. "href": "https://bitbucket/scm/bar/foo.git",
  2479. "name": "http"
  2480. },
  2481. {
  2482. "href": "ssh://git@bitbucket:7999/bar/foo.git",
  2483. "name": "ssh"
  2484. }
  2485. ],
  2486. "self": [
  2487. {
  2488. "href": "https://bitbucket/users/steven.guiheux/repos/ascoderepo/browse"
  2489. }
  2490. ]
  2491. }
  2492. }
  2493. },
  2494. "locked": false,
  2495. "author": {
  2496. "user": {
  2497. "name": "cds",
  2498. "emailAddress": "foo@bar.fr",
  2499. "id": 7898,
  2500. "displayName": "cds",
  2501. "active": true,
  2502. "slug": "cds",
  2503. "type": "NORMAL",
  2504. "links": {
  2505. "self": [
  2506. {
  2507. "href": "http//foo/bar"
  2508. }
  2509. ]
  2510. }
  2511. },
  2512. "role": "AUTHOR",
  2513. "approved": false,
  2514. "status": "UNAPPROVED"
  2515. },
  2516. "reviewers": [],
  2517. "participants": [],
  2518. "links": {
  2519. "self": [
  2520. {
  2521. "href": "fff"
  2522. }
  2523. ]
  2524. }
  2525. }
  2526. }`
  2527. var bitbucketPrDeleted = `
  2528. {
  2529. "eventKey": "pr:deleted",
  2530. "date": "2019-10-15T09:33:38+0200",
  2531. "actor": {
  2532. "name": "john.doe",
  2533. "emailAddress": "john.doe@targate.fr",
  2534. "id": 1363,
  2535. "displayName": "john doe",
  2536. "active": true,
  2537. "slug": "foo",
  2538. "type": "NORMAL",
  2539. "links": {
  2540. "self": [
  2541. {
  2542. "href": "https://bitbucket/users/bar"
  2543. }
  2544. ]
  2545. }
  2546. },
  2547. "pullRequest": {
  2548. "id": 666,
  2549. "version": 0,
  2550. "title": "My First PR",
  2551. "state": "DELETED",
  2552. "open": true,
  2553. "closed": false,
  2554. "createdDate": 1569939813210,
  2555. "updatedDate": 1569939813210,
  2556. "fromRef": {
  2557. "id": "refs/heads/workflowUpdate1",
  2558. "displayId": "src_branch",
  2559. "latestCommit": "12345671234567",
  2560. "repository": {
  2561. "slug": "repo",
  2562. "id": 11444,
  2563. "name": "FOO",
  2564. "scmId": "git",
  2565. "state": "AVAILABLE",
  2566. "statusMessage": "Available",
  2567. "forkable": true,
  2568. "project": {
  2569. "key": "fork",
  2570. "id": 112,
  2571. "name": "foo",
  2572. "type": "PERSONAL",
  2573. "owner": {
  2574. "name": "foo",
  2575. "emailAddress": "foo@bar",
  2576. "id": 1363,
  2577. "displayName": "foo",
  2578. "active": true,
  2579. "slug": "foo",
  2580. "type": "NORMAL",
  2581. "links": {
  2582. "self": [
  2583. {
  2584. "href": "https://bitbucket/users/bar"
  2585. }
  2586. ]
  2587. }
  2588. },
  2589. "links": {
  2590. "self": [
  2591. {
  2592. "href": "https://bitbucket/users/bar"
  2593. }
  2594. ]
  2595. }
  2596. },
  2597. "public": false,
  2598. "links": {
  2599. "clone": [
  2600. {
  2601. "href": "https://bitbucket/scm/foo/bar.git",
  2602. "name": "http"
  2603. },
  2604. {
  2605. "href": "ssh://git@bitbucket:7999/foo/bar.git",
  2606. "name": "ssh"
  2607. }
  2608. ],
  2609. "self": [
  2610. {
  2611. "href": "https://bitbucket/users/foo/repos/bar/browse"
  2612. }
  2613. ]
  2614. }
  2615. }
  2616. },
  2617. "toRef": {
  2618. "id": "refs/heads/dest_branch",
  2619. "displayId": "dest_branch",
  2620. "latestCommit": "654321654321",
  2621. "repository": {
  2622. "slug": "repo",
  2623. "id": 11444,
  2624. "name": "bar",
  2625. "scmId": "git",
  2626. "state": "AVAILABLE",
  2627. "statusMessage": "Available",
  2628. "forkable": true,
  2629. "project": {
  2630. "key": "my",
  2631. "id": 112,
  2632. "name": "my",
  2633. "type": "PERSONAL",
  2634. "owner": {
  2635. "name": "foo",
  2636. "emailAddress": "foo@bar",
  2637. "id": 1363,
  2638. "displayName": "foo",
  2639. "active": true,
  2640. "slug": "foo",
  2641. "type": "NORMAL",
  2642. "links": {
  2643. "self": [
  2644. {
  2645. "href": "https://bitbucket/users/bar"
  2646. }
  2647. ]
  2648. }
  2649. },
  2650. "links": {
  2651. "self": [
  2652. {
  2653. "href": "https://bitbucket/users/bar"
  2654. }
  2655. ]
  2656. }
  2657. },
  2658. "public": false,
  2659. "links": {
  2660. "clone": [
  2661. {
  2662. "href": "https://bitbucket/scm/bar/foo.git",
  2663. "name": "http"
  2664. },
  2665. {
  2666. "href": "ssh://git@bitbucket:7999/bar/foo.git",
  2667. "name": "ssh"
  2668. }
  2669. ],
  2670. "self": [
  2671. {
  2672. "href": "https://bitbucket/users/steven.guiheux/repos/ascoderepo/browse"
  2673. }
  2674. ]
  2675. }
  2676. }
  2677. },
  2678. "locked": false,
  2679. "author": {
  2680. "user": {
  2681. "name": "cds",
  2682. "emailAddress": "foo@bar.fr",
  2683. "id": 7898,
  2684. "displayName": "cds",
  2685. "active": true,
  2686. "slug": "cds",
  2687. "type": "NORMAL",
  2688. "links": {
  2689. "self": [
  2690. {
  2691. "href": "http//foo/bar"
  2692. }
  2693. ]
  2694. }
  2695. },
  2696. "role": "AUTHOR",
  2697. "approved": false,
  2698. "status": "UNAPPROVED"
  2699. },
  2700. "reviewers": [],
  2701. "participants": [],
  2702. "links": {
  2703. "self": [
  2704. {
  2705. "href": "fff"
  2706. }
  2707. ]
  2708. }
  2709. }
  2710. }`
  2711. var bitbucketPushEvent = `
  2712. {
  2713. "eventKey": "repo:refs_changed",
  2714. "date": "2017-11-30T15:24:01+0100",
  2715. "actor": {
  2716. "name": "steven.guiheux",
  2717. "emailAddress": "steven.guiheux@foo.bar",
  2718. "id": 1363,
  2719. "displayName": "Steven Guiheux",
  2720. "active": true,
  2721. "slug": "steven.guiheux",
  2722. "type": "NORMAL"
  2723. },
  2724. "repository": {
  2725. "slug": "sseclient",
  2726. "id": 6096,
  2727. "name": "sseclient",
  2728. "scmId": "git",
  2729. "state": "AVAILABLE",
  2730. "statusMessage": "Available",
  2731. "forkable": true,
  2732. "project": {
  2733. "key": "~STEVEN.GUIHEUX",
  2734. "id": 112,
  2735. "name": "Steven Guiheux",
  2736. "type": "PERSONAL",
  2737. "owner": {
  2738. "name": "steven.guiheux",
  2739. "emailAddress": "steven.guiheux@foo.bar",
  2740. "id": 1363,
  2741. "displayName": "Steven Guiheux",
  2742. "active": true,
  2743. "slug": "steven.guiheux",
  2744. "type": "NORMAL"
  2745. }
  2746. },
  2747. "public": true
  2748. },
  2749. "changes": [
  2750. {
  2751. "ref": {
  2752. "id": "refs/heads/name-of-branch",
  2753. "displayId": "name-of-branch",
  2754. "type": "BRANCH"
  2755. },
  2756. "refId": "refs/heads/name-of-branch",
  2757. "fromHash": "0000000000000000000000000000000000000000",
  2758. "toHash": "9f4fac7ec5642099982a86f584f2c4a362adb670",
  2759. "type": "ADD"
  2760. }
  2761. ]
  2762. }
  2763. `
  2764. var bitbucketMultiplePushEvent = `
  2765. {
  2766. "eventKey": "repo:refs_changed",
  2767. "date": "2017-11-30T15:24:01+0100",
  2768. "actor": {
  2769. "name": "steven.guiheux",
  2770. "emailAddress": "steven.guiheux@foo.bar",
  2771. "id": 1363,
  2772. "displayName": "Steven Guiheux",
  2773. "active": true,
  2774. "slug": "steven.guiheux",
  2775. "type": "NORMAL"
  2776. },
  2777. "repository": {
  2778. "slug": "sseclient",
  2779. "id": 6096,
  2780. "name": "sseclient",
  2781. "scmId": "git",
  2782. "state": "AVAILABLE",
  2783. "statusMessage": "Available",
  2784. "forkable": true,
  2785. "project": {
  2786. "key": "~STEVEN.GUIHEUX",
  2787. "id": 112,
  2788. "name": "Steven Guiheux",
  2789. "type": "PERSONAL",
  2790. "owner": {
  2791. "name": "steven.guiheux",
  2792. "emailAddress": "steven.guiheux@foo.bar",
  2793. "id": 1363,
  2794. "displayName": "Steven Guiheux",
  2795. "active": true,
  2796. "slug": "steven.guiheux",
  2797. "type": "NORMAL"
  2798. }
  2799. },
  2800. "public": true
  2801. },
  2802. "changes": [
  2803. {
  2804. "ref": {
  2805. "id": "refs/heads/name-of-branch",
  2806. "displayId": "name-of-branch",
  2807. "type": "BRANCH"
  2808. },
  2809. "refId": "refs/heads/name-of-branch",
  2810. "fromHash": "0000000000000000000000000000000000000000",
  2811. "toHash": "9f4fac7ec5642099982a86f584f2c4a362adb670",
  2812. "type": "ADD"
  2813. },
  2814. {
  2815. "ref": {
  2816. "id": "refs/heads/name-of-branch-bis",
  2817. "displayId": "name-of-branch-bis",
  2818. "type": "BRANCH"
  2819. },
  2820. "refId": "refs/heads/name-of-branch-bis",
  2821. "fromHash": "0000000000000000000000000000000000000000",
  2822. "toHash": "9f4fac7ec5642099982a86f584f2c4a362adb670",
  2823. "type": "ADD"
  2824. }
  2825. ]
  2826. }
  2827. `
  2828. var bitbucketPrDeclined = `
  2829. {
  2830. "eventKey": "pr:declined",
  2831. "date": "2019-10-15T09:33:38+0200",
  2832. "actor": {
  2833. "name": "john.doe",
  2834. "emailAddress": "john.doe@targate.fr",
  2835. "id": 1363,
  2836. "displayName": "john doe",
  2837. "active": true,
  2838. "slug": "foo",
  2839. "type": "NORMAL",
  2840. "links": {
  2841. "self": [
  2842. {
  2843. "href": "https://bitbucket/users/bar"
  2844. }
  2845. ]
  2846. }
  2847. },
  2848. "pullRequest": {
  2849. "id": 666,
  2850. "version": 0,
  2851. "title": "My First PR",
  2852. "state": "DECLINED",
  2853. "open": true,
  2854. "closed": false,
  2855. "createdDate": 1569939813210,
  2856. "updatedDate": 1569939813210,
  2857. "fromRef": {
  2858. "id": "refs/heads/workflowUpdate1",
  2859. "displayId": "src_branch",
  2860. "latestCommit": "12345671234567",
  2861. "repository": {
  2862. "slug": "repo",
  2863. "id": 11444,
  2864. "name": "FOO",
  2865. "scmId": "git",
  2866. "state": "AVAILABLE",
  2867. "statusMessage": "Available",
  2868. "forkable": true,
  2869. "project": {
  2870. "key": "fork",
  2871. "id": 112,
  2872. "name": "foo",
  2873. "type": "PERSONAL",
  2874. "owner": {
  2875. "name": "foo",
  2876. "emailAddress": "foo@bar",
  2877. "id": 1363,
  2878. "displayName": "foo",
  2879. "active": true,
  2880. "slug": "foo",
  2881. "type": "NORMAL",
  2882. "links": {
  2883. "self": [
  2884. {
  2885. "href": "https://bitbucket/users/bar"
  2886. }
  2887. ]
  2888. }
  2889. },
  2890. "links": {
  2891. "self": [
  2892. {
  2893. "href": "https://bitbucket/users/bar"
  2894. }
  2895. ]
  2896. }
  2897. },
  2898. "public": false,
  2899. "links": {
  2900. "clone": [
  2901. {
  2902. "href": "https://bitbucket/scm/foo/bar.git",
  2903. "name": "http"
  2904. },
  2905. {
  2906. "href": "ssh://git@bitbucket:7999/foo/bar.git",
  2907. "name": "ssh"
  2908. }
  2909. ],
  2910. "self": [
  2911. {
  2912. "href": "https://bitbucket/users/foo/repos/bar/browse"
  2913. }
  2914. ]
  2915. }
  2916. }
  2917. },
  2918. "toRef": {
  2919. "id": "refs/heads/dest_branch",
  2920. "displayId": "dest_branch",
  2921. "latestCommit": "654321654321",
  2922. "repository": {
  2923. "slug": "repo",
  2924. "id": 11444,
  2925. "name": "bar",
  2926. "scmId": "git",
  2927. "state": "AVAILABLE",
  2928. "statusMessage": "Available",
  2929. "forkable": true,
  2930. "project": {
  2931. "key": "my",
  2932. "id": 112,
  2933. "name": "my",
  2934. "type": "PERSONAL",
  2935. "owner": {
  2936. "name": "foo",
  2937. "emailAddress": "foo@bar",
  2938. "id": 1363,
  2939. "displayName": "foo",
  2940. "active": true,
  2941. "slug": "foo",
  2942. "type": "NORMAL",
  2943. "links": {
  2944. "self": [
  2945. {
  2946. "href": "https://bitbucket/users/bar"
  2947. }
  2948. ]
  2949. }
  2950. },
  2951. "links": {
  2952. "self": [
  2953. {
  2954. "href": "https://bitbucket/users/bar"
  2955. }
  2956. ]
  2957. }
  2958. },
  2959. "public": false,
  2960. "links": {
  2961. "clone": [
  2962. {
  2963. "href": "https://bitbucket/scm/bar/foo.git",
  2964. "name": "http"
  2965. },
  2966. {
  2967. "href": "ssh://git@bitbucket:7999/bar/foo.git",
  2968. "name": "ssh"
  2969. }
  2970. ],
  2971. "self": [
  2972. {
  2973. "href": "https://bitbucket/users/steven.guiheux/repos/ascoderepo/browse"
  2974. }
  2975. ]
  2976. }
  2977. }
  2978. },
  2979. "locked": false,
  2980. "author": {
  2981. "user": {
  2982. "name": "cds",
  2983. "emailAddress": "foo@bar.fr",
  2984. "id": 7898,
  2985. "displayName": "cds",
  2986. "active": true,
  2987. "slug": "cds",
  2988. "type": "NORMAL",
  2989. "links": {
  2990. "self": [
  2991. {
  2992. "href": "http//foo/bar"
  2993. }
  2994. ]
  2995. }
  2996. },
  2997. "role": "AUTHOR",
  2998. "approved": false,
  2999. "status": "UNAPPROVED"
  3000. },
  3001. "reviewers": [],
  3002. "participants": [],
  3003. "links": {
  3004. "self": [
  3005. {
  3006. "href": "fff"
  3007. }
  3008. ]
  3009. }
  3010. }
  3011. }`