bitbucket_server.py 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. from collections import OrderedDict
  2. EXAMPLE_PRIVATE_KEY = """-----BEGIN RSA PRIVATE KEY-----
  3. MIICWwIBAAKBgQC1cd9t8sA03awggLiX2gjZxyvOVUPJksLly1E662tttTeR3Wm9
  4. eo6onNeI8HRD+O4wubUp4h4Chc7DtLDmFEPhUZ8Qkwztiifm99Xo3s0nUq4Pygp5
  5. AU09KXTEPbzHLh1dnXLcxVLmGDE4drh0NWmYsd/Zp7XNIZq2TRQQ3NTdVQIDAQAB
  6. AoGAFwMyS0eWiR30TssEnn3Q0Y4pSCoYRuCOR4bZ7pcdMPTi72UdnCKHJWt/Cqc0
  7. l8piq1tiVsWO+NLvvnKUXRoE4cAyrGrpf1F0uP5zYW71SQALc9wwsjDzuj7BZEuK
  8. fg35JSceLHWE1WtzPDX5Xg20YPnMrA/xe/RwuPjuBH0wSqECQQDizzmKdKCq0ejy
  9. 3OxEto5knqpSEgRcOk0HDsdgjwkwiZJOj5ECV2FKpNHuu2thGy/aDJyLlmUso8j0
  10. OpvLAzOvAkEAzMwAgGexTxKm8hy3ilvVn9EvhSKjaIakqY4ONK9LZ4zMiDHI0H6C
  11. FXlwWX7CJM0YVFMubj8SB8rnIuvFDEBMOwJABHtRyMGbNyTktH/XD1iIIcbc2LhQ
  12. a74fLYeGOws4hEQDpxfBJsmxO3dcSppbedS+slFTepKjNymZW/IYh/9tMwJAEL5E
  13. 9DqGBn7x4y1x2//yESTbC7lvPqZzY+FXS/tg4NBkEGZxkoolPHg3NTnlyXhzGsHK
  14. M/04DicKipJYA85l7QJAJ3u67qZXecM/oWTtJToBDuyKGHfdY1564+RbyDEjJJRb
  15. vz4O/8FQQ1sGjdEBMMrRBCHEG8o3/XDTrB97t45TeA==
  16. -----END RSA PRIVATE KEY-----"""
  17. COMPARE_COMMITS_EXAMPLE = {
  18. "values": [
  19. {
  20. "id": "e18e4e72de0d824edfbe0d73efe34cbd0d01d301",
  21. "displayId": "e18e4e72de0",
  22. "author": {
  23. "name": "SentryU",
  24. "displayName": "Sentry User",
  25. "emailAddress": "sentryuser@getsentry.com",
  26. "type": "NORMAL",
  27. },
  28. "message": "README.md edited online with Bitbucket",
  29. "authorTimestamp": 1576763816000,
  30. }
  31. ]
  32. }
  33. COMMIT_CHANGELIST_EXAMPLE = {
  34. "values": [
  35. {
  36. "path": {
  37. "components": ["a.txt"],
  38. "parent": "",
  39. "name": "a.txt",
  40. "extension": "txt",
  41. "toString": "a.txt",
  42. },
  43. "executable": False,
  44. "percentUnchanged": -1,
  45. "type": "MODIFY",
  46. "nodeType": "FILE",
  47. "srcExecutable": False,
  48. "properties": {"gitChangeType": "MODIFY"},
  49. },
  50. {
  51. "path": {
  52. "components": ["b.txt"],
  53. "parent": "",
  54. "name": "b.txt",
  55. "extension": "txt",
  56. "toString": "b.txt",
  57. },
  58. "executable": False,
  59. "percentUnchanged": -1,
  60. "type": "ADD",
  61. "nodeType": "FILE",
  62. "srcExecutable": False,
  63. "properties": {"gitChangeType": "ADD"},
  64. },
  65. {
  66. "path": {
  67. "components": ["c.txt"],
  68. "parent": "",
  69. "name": "c.txt",
  70. "extension": "txt",
  71. "toString": "c.txt",
  72. },
  73. "executable": False,
  74. "percentUnchanged": -1,
  75. "type": "DELETE",
  76. "nodeType": "FILE",
  77. "srcExecutable": False,
  78. "properties": {"gitChangeType": "DELETE"},
  79. },
  80. {
  81. "path": {
  82. "components": ["e.txt"],
  83. "parent": "",
  84. "name": "d.txt",
  85. "extension": "txt",
  86. "toString": "d.txt",
  87. },
  88. "srcPath": {
  89. "components": ["d.txt"],
  90. "parent": "",
  91. "name": "e.txt",
  92. "extension": "txt",
  93. "toString": "e.txt",
  94. },
  95. "executable": False,
  96. "percentUnchanged": -1,
  97. "type": "MOVE",
  98. "nodeType": "FILE",
  99. "srcExecutable": False,
  100. "properties": {"gitChangeType": "MOVE"},
  101. },
  102. ]
  103. }
  104. REPO = {
  105. "slug": "helloworld",
  106. "id": 72,
  107. "name": "helloworld",
  108. "scmId": "git",
  109. "state": "AVAILABLE",
  110. "statusMessage": "Available",
  111. "forkable": True,
  112. "project": OrderedDict(
  113. [
  114. ("key", "laurynsentry"),
  115. ("id", 75),
  116. ("name", "laurynsentry"),
  117. ("description", ""),
  118. ("public", False),
  119. ("type", "Normal"),
  120. (
  121. "links",
  122. OrderedDict(
  123. [
  124. (
  125. "self",
  126. OrderedDict(
  127. [("href", "https://bitbucket.example.org/projects/laurynsentry")]
  128. ),
  129. )
  130. ]
  131. ),
  132. ),
  133. ]
  134. ),
  135. "public": False,
  136. "links": OrderedDict(
  137. [
  138. (
  139. "clone",
  140. OrderedDict(
  141. [
  142. OrderedDict(
  143. [
  144. (
  145. "href",
  146. "https://bitbucket.example.org/scm/laurynsentry/helloworld.git",
  147. ),
  148. ("name", "http"),
  149. ]
  150. ),
  151. OrderedDict(
  152. [
  153. (
  154. "href",
  155. "ssh://git@bitbucket.example.org:7999/laurynsentry/helloworld.git",
  156. ),
  157. ("name", "ssh"),
  158. ]
  159. ),
  160. ]
  161. ),
  162. ),
  163. (
  164. "self",
  165. OrderedDict(
  166. [
  167. (
  168. "href",
  169. "https://bitbucket.example.org/projects/laurynsentry/repos/helloworld/browse",
  170. )
  171. ]
  172. ),
  173. ),
  174. ]
  175. ),
  176. }
  177. COMPARE_COMMITS_WITH_PAGES_1_2_EXAMPLE = {
  178. "values": [
  179. {
  180. "id": "d0352305beb41afb3a4ea79e3a97bf6a97520339",
  181. "displayId": "d0352305beb",
  182. "author": {
  183. "name": "SentryU",
  184. "displayName": "Sentry User",
  185. "emailAddress": "sentryuser@getsentry.com",
  186. "type": "NORMAL",
  187. },
  188. "message": "Fist commit",
  189. "authorTimestamp": 1576763816000,
  190. }
  191. ],
  192. "size": 1,
  193. "isLastPage": False,
  194. "start": 0,
  195. "limit": 1,
  196. "nextPageStart": 1,
  197. }
  198. COMPARE_COMMITS_WITH_PAGES_2_2_EXAMPLE = {
  199. "values": [
  200. {
  201. "id": "042bc8434e0c178d8745c7d9f90bddab9c927887",
  202. "displayId": "042bc8434e0",
  203. "author": {
  204. "name": "SentryU",
  205. "displayName": "Sentry User",
  206. "emailAddress": "sentryuser@getsentry.com",
  207. "type": "NORMAL",
  208. },
  209. "message": "Second commit",
  210. "authorTimestamp": 1576763816000,
  211. }
  212. ],
  213. "size": 1,
  214. "isLastPage": True,
  215. "start": 1,
  216. "limit": 1,
  217. "nextPageStart": None,
  218. }
  219. COMMIT_CHANGELIST_WITH_PAGES_FIRST_COMMIT_EXAMPLE = {
  220. "values": [
  221. {
  222. "path": {
  223. "components": ["a.txt"],
  224. "parent": "",
  225. "name": "a.txt",
  226. "extension": "txt",
  227. "toString": "a.txt",
  228. },
  229. "executable": False,
  230. "percentUnchanged": -1,
  231. "type": "MODIFY",
  232. "nodeType": "FILE",
  233. "srcExecutable": False,
  234. "properties": {"gitChangeType": "MODIFY"},
  235. },
  236. {
  237. "path": {
  238. "components": ["b.txt"],
  239. "parent": "",
  240. "name": "b.txt",
  241. "extension": "txt",
  242. "toString": "b.txt",
  243. },
  244. "executable": False,
  245. "percentUnchanged": -1,
  246. "type": "ADD",
  247. "nodeType": "FILE",
  248. "srcExecutable": False,
  249. "properties": {"gitChangeType": "ADD"},
  250. },
  251. ]
  252. }
  253. COMMIT_CHANGELIST_WITH_PAGES_SECOND_COMMIT_EXAMPLE_1_2 = {
  254. "values": [
  255. {
  256. "path": {
  257. "components": ["c.txt"],
  258. "parent": "",
  259. "name": "c.txt",
  260. "extension": "txt",
  261. "toString": "c.txt",
  262. },
  263. "executable": False,
  264. "percentUnchanged": -1,
  265. "type": "DELETE",
  266. "nodeType": "FILE",
  267. "srcExecutable": False,
  268. "properties": {"gitChangeType": "DELETE"},
  269. }
  270. ],
  271. "size": 1,
  272. "isLastPage": False,
  273. "start": 0,
  274. "limit": 1,
  275. "nextPageStart": 1,
  276. }
  277. COMMIT_CHANGELIST_WITH_PAGES_SECOND_COMMIT_EXAMPLE_2_2 = {
  278. "values": [
  279. {
  280. "path": {
  281. "components": ["e.txt"],
  282. "parent": "",
  283. "name": "d.txt",
  284. "extension": "txt",
  285. "toString": "d.txt",
  286. },
  287. "srcPath": {
  288. "components": ["d.txt"],
  289. "parent": "",
  290. "name": "e.txt",
  291. "extension": "txt",
  292. "toString": "e.txt",
  293. },
  294. "executable": False,
  295. "percentUnchanged": -1,
  296. "type": "MOVE",
  297. "nodeType": "FILE",
  298. "srcExecutable": False,
  299. "properties": {"gitChangeType": "MOVE"},
  300. },
  301. ],
  302. "size": 1,
  303. "isLastPage": True,
  304. "start": 1,
  305. "limit": 1,
  306. "nextPageStart": None,
  307. }