Skip to content

Commit 745ea0a

Browse files
committed
Merge pull request #54 from code-check/webhook
Mod webhook
2 parents c7eb8e3 + 953babe commit 745ea0a

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

src/main/scala/codecheck/github/models/Webhook.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class Webhook(value: JValue) extends AbstractJson(value) {
1010
def name = get("name")
1111
def events = seq("events")
1212
def active = boolean("active")
13-
def config = new WebhookConfig(get("config.url"), get("config.content_type"), get("config.secret"), get("config.insecure_ssl"));
13+
def config = new WebhookConfig(get("config.url"), get("config.content_type"), opt("config.secret"), opt("config.insecure_ssl").contains("1"));
1414
def last_response = new WebhookResponse(value \ "last_response")
1515
def updated_at = getDate("updated_at")
1616
def created_at = getDate("created_at")
@@ -19,9 +19,9 @@ class Webhook(value: JValue) extends AbstractJson(value) {
1919
case class WebhookConfig(
2020
url: String,
2121
content_type: String = "json",
22-
secret: String = "",
23-
insecure_ssl: String = "0"
24-
) extends AbstractInput
22+
secret: Option[String] = None,
23+
insecure_ssl: Boolean = false
24+
) extends AbstractInput
2525

2626
case class WebhookCreateInput(
2727
name: String,

src/test/scala/WebhookOpSpec.scala

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ class WebhookOpSpec extends FunSpec with Constants with BeforeAndAfter {
3636
assert(res.active == true)
3737
assert(res.config.url == targetURL)
3838
assert(res.config.content_type == "json")
39-
assert(res.config.secret == "")
40-
assert(res.config.insecure_ssl == "0")
39+
assert(res.config.secret == None)
40+
assert(res.config.insecure_ssl == false)
4141
}
42-
}
42+
}
4343

4444
describe("getWebhook(owner, repo, id)") {
4545
it("should succeed with valid organization, repo and id.") {
@@ -48,7 +48,7 @@ class WebhookOpSpec extends FunSpec with Constants with BeforeAndAfter {
4848
}
4949
}
5050
}
51-
51+
5252
describe("updateWebhook(owner, repo, id, input)") {
5353
it("should succeed updating by rewriting events.") {
5454
val input = new WebhookUpdateInput(events=Some(Seq("create", "pull_request")))
@@ -76,26 +76,26 @@ class WebhookOpSpec extends FunSpec with Constants with BeforeAndAfter {
7676
val res = Await.result(api.updateWebhook(organization, repo, nID, input), TIMEOUT)
7777
assert(res.config.url == targetURL)
7878
}
79-
}
79+
}
8080

8181
describe("testWebhook(owner, repo, id)") {
8282
it("should succeed with valid inputs.") {
8383
val result = Await.result(api.testWebhook(organization, repo, nID), TIMEOUT)
8484
assert(result == true)
8585
}
86-
}
86+
}
8787

8888
describe("pingWebhook(owner, repo, id)") {
8989
it("should succeed with valid inputs.") {
9090
val result = Await.result(api.pingWebhook(organization, repo, nID), TIMEOUT)
9191
assert(result == true)
9292
}
93-
}
93+
}
9494

9595
describe("removeWebhook(owner, repo, id)") {
9696
it("should succeed with valid inputs.") {
9797
val result = Await.result(api.removeWebhook(organization, repo, nID), TIMEOUT)
9898
assert(result == true)
9999
}
100-
}
101-
}
100+
}
101+
}

0 commit comments

Comments
 (0)