mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-06 21:45:50 +01:00
Improve API compatibility for SourceTree and Drone.io (#2286)
This commit is contained in:
committed by
Naoki Takezoe
parent
f7defffeab
commit
841e6d110c
@@ -182,7 +182,8 @@ object ApiSpecModels {
|
||||
repository = repository,
|
||||
owner = apiUser,
|
||||
forkedCount = repositoryInfo.forkedCount,
|
||||
watchers = 0
|
||||
watchers = 0,
|
||||
permission = None
|
||||
)
|
||||
|
||||
val apiLabel = ApiLabel(
|
||||
@@ -409,6 +410,8 @@ object ApiSpecModels {
|
||||
assets = Seq(apiReleaseAsset)
|
||||
)
|
||||
|
||||
val apiEmail = ApiEmail("root@localhost", true)
|
||||
|
||||
// JSON String for APIs
|
||||
|
||||
val jsonUser = """{
|
||||
@@ -427,12 +430,15 @@ object ApiSpecModels {
|
||||
|"name":"Hello-World",
|
||||
|"full_name":"octocat/Hello-World",
|
||||
|"description":"This your first repo!",
|
||||
|"id":0,
|
||||
|"watchers":0,
|
||||
|"forks":1,
|
||||
|"private":false,
|
||||
|"fork":true,
|
||||
|"default_branch":"master",
|
||||
|"owner":$jsonUser,
|
||||
|"id":0,
|
||||
|"created_at":"2011-04-14T16:00:49Z",
|
||||
|"updated_at":"2011-04-14T16:00:49Z",
|
||||
|"forks_count":1,
|
||||
|"watchers_count":0,
|
||||
|"url":"http://gitbucket.exmple.com/api/v3/repos/octocat/Hello-World",
|
||||
@@ -687,4 +693,12 @@ object ApiSpecModels {
|
||||
|"author":${jsonUser},
|
||||
|"assets":[${jsonReleaseAsset}]
|
||||
|}""".stripMargin
|
||||
|
||||
val jsonEmail =
|
||||
s"""{
|
||||
|"email":"root@localhost",
|
||||
|"primary":true,
|
||||
|"verified":true,
|
||||
|"visibility":"public"
|
||||
|}""".stripMargin
|
||||
}
|
||||
|
||||
@@ -79,4 +79,7 @@ class JsonFormatSpec extends FunSuite {
|
||||
test("apiRelease") {
|
||||
assert(JsonFormat(apiRelease) == expected(jsonRelease))
|
||||
}
|
||||
test("apiEmail") {
|
||||
assert(JsonFormat(apiEmail) == expected(jsonEmail))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,19 +52,27 @@ class WebHookServiceSpec extends FunSuite with ServiceSpecBase {
|
||||
val formType = WebHookContentType.FORM
|
||||
val jsonType = WebHookContentType.JSON
|
||||
service.addWebHook("user1", "repo1", "http://example.com", Set(WebHook.PullRequest), formType, Some("key"))
|
||||
val hookId = 1
|
||||
|
||||
assert(
|
||||
service.getWebHooks("user1", "repo1") == List(
|
||||
(RepositoryWebHook("user1", "repo1", "http://example.com", formType, Some("key")), Set(WebHook.PullRequest))
|
||||
(
|
||||
RepositoryWebHook("user1", "repo1", "http://example.com", formType, Some("key"), hookId),
|
||||
Set(WebHook.PullRequest)
|
||||
)
|
||||
)
|
||||
)
|
||||
assert(
|
||||
service.getWebHook("user1", "repo1", "http://example.com") == Some(
|
||||
(RepositoryWebHook("user1", "repo1", "http://example.com", formType, Some("key")), Set(WebHook.PullRequest))
|
||||
(
|
||||
RepositoryWebHook("user1", "repo1", "http://example.com", formType, Some("key"), hookId),
|
||||
Set(WebHook.PullRequest)
|
||||
)
|
||||
)
|
||||
)
|
||||
assert(
|
||||
service.getWebHooksByEvent("user1", "repo1", WebHook.PullRequest) == List(
|
||||
(RepositoryWebHook("user1", "repo1", "http://example.com", formType, Some("key")))
|
||||
(RepositoryWebHook("user1", "repo1", "http://example.com", formType, Some("key"), hookId))
|
||||
)
|
||||
)
|
||||
assert(service.getWebHooksByEvent("user1", "repo1", WebHook.Push) == Nil)
|
||||
@@ -82,7 +90,7 @@ class WebHookServiceSpec extends FunSuite with ServiceSpecBase {
|
||||
assert(
|
||||
service.getWebHook("user1", "repo1", "http://example.com") == Some(
|
||||
(
|
||||
RepositoryWebHook("user1", "repo1", "http://example.com", jsonType, Some("key")),
|
||||
RepositoryWebHook("user1", "repo1", "http://example.com", jsonType, Some("key"), hookId),
|
||||
Set(WebHook.Push, WebHook.Issues)
|
||||
)
|
||||
)
|
||||
@@ -90,7 +98,7 @@ class WebHookServiceSpec extends FunSuite with ServiceSpecBase {
|
||||
assert(service.getWebHooksByEvent("user1", "repo1", WebHook.PullRequest) == Nil)
|
||||
assert(
|
||||
service.getWebHooksByEvent("user1", "repo1", WebHook.Push) == List(
|
||||
(RepositoryWebHook("user1", "repo1", "http://example.com", jsonType, Some("key")))
|
||||
(RepositoryWebHook("user1", "repo1", "http://example.com", jsonType, Some("key"), hookId))
|
||||
)
|
||||
)
|
||||
service.deleteWebHook("user1", "repo1", "http://example.com")
|
||||
@@ -114,9 +122,11 @@ class WebHookServiceSpec extends FunSuite with ServiceSpecBase {
|
||||
)
|
||||
assert(
|
||||
service.getWebHooks("user1", "repo1") == List(
|
||||
RepositoryWebHook("user1", "repo1", "http://example.com/1", ctype, Some("key")) -> Set(WebHook.PullRequest),
|
||||
RepositoryWebHook("user1", "repo1", "http://example.com/2", ctype, Some("key")) -> Set(WebHook.Push),
|
||||
RepositoryWebHook("user1", "repo1", "http://example.com/3", ctype, Some("key")) -> Set(
|
||||
RepositoryWebHook("user1", "repo1", "http://example.com/1", ctype, Some("key"), 1) -> Set(
|
||||
WebHook.PullRequest
|
||||
),
|
||||
RepositoryWebHook("user1", "repo1", "http://example.com/2", ctype, Some("key"), 2) -> Set(WebHook.Push),
|
||||
RepositoryWebHook("user1", "repo1", "http://example.com/3", ctype, Some("key"), 3) -> Set(
|
||||
WebHook.PullRequest,
|
||||
WebHook.Push
|
||||
)
|
||||
@@ -124,8 +134,8 @@ class WebHookServiceSpec extends FunSuite with ServiceSpecBase {
|
||||
)
|
||||
assert(
|
||||
service.getWebHooksByEvent("user1", "repo1", WebHook.PullRequest) == List(
|
||||
RepositoryWebHook("user1", "repo1", "http://example.com/1", ctype, Some("key")),
|
||||
RepositoryWebHook("user1", "repo1", "http://example.com/3", ctype, Some("key"))
|
||||
RepositoryWebHook("user1", "repo1", "http://example.com/1", ctype, Some("key"), 1),
|
||||
RepositoryWebHook("user1", "repo1", "http://example.com/3", ctype, Some("key"), 3)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user