Skip to content

Mod webhook #54

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 11, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/main/scala/codecheck/github/models/Webhook.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Webhook(value: JValue) extends AbstractJson(value) {
def name = get("name")
def events = seq("events")
def active = boolean("active")
def config = new WebhookConfig(get("config.url"), get("config.content_type"), get("config.secret"), get("config.insecure_ssl"));
def config = new WebhookConfig(get("config.url"), get("config.content_type"), opt("config.secret"), opt("config.insecure_ssl").contains("1"));
def last_response = new WebhookResponse(value \ "last_response")
def updated_at = getDate("updated_at")
def created_at = getDate("created_at")
Expand All @@ -19,9 +19,9 @@ class Webhook(value: JValue) extends AbstractJson(value) {
case class WebhookConfig(
url: String,
content_type: String = "json",
secret: String = "",
insecure_ssl: String = "0"
) extends AbstractInput
secret: Option[String] = None,
insecure_ssl: Boolean = false
) extends AbstractInput

case class WebhookCreateInput(
name: String,
Expand Down
18 changes: 9 additions & 9 deletions src/test/scala/WebhookOpSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ class WebhookOpSpec extends FunSpec with Constants with BeforeAndAfter {
assert(res.active == true)
assert(res.config.url == targetURL)
assert(res.config.content_type == "json")
assert(res.config.secret == "")
assert(res.config.insecure_ssl == "0")
assert(res.config.secret == None)
assert(res.config.insecure_ssl == false)
}
}
}

describe("getWebhook(owner, repo, id)") {
it("should succeed with valid organization, repo and id.") {
Expand All @@ -48,7 +48,7 @@ class WebhookOpSpec extends FunSpec with Constants with BeforeAndAfter {
}
}
}

describe("updateWebhook(owner, repo, id, input)") {
it("should succeed updating by rewriting events.") {
val input = new WebhookUpdateInput(events=Some(Seq("create", "pull_request")))
Expand Down Expand Up @@ -76,26 +76,26 @@ class WebhookOpSpec extends FunSpec with Constants with BeforeAndAfter {
val res = Await.result(api.updateWebhook(organization, repo, nID, input), TIMEOUT)
assert(res.config.url == targetURL)
}
}
}

describe("testWebhook(owner, repo, id)") {
it("should succeed with valid inputs.") {
val result = Await.result(api.testWebhook(organization, repo, nID), TIMEOUT)
assert(result == true)
}
}
}

describe("pingWebhook(owner, repo, id)") {
it("should succeed with valid inputs.") {
val result = Await.result(api.pingWebhook(organization, repo, nID), TIMEOUT)
assert(result == true)
}
}
}

describe("removeWebhook(owner, repo, id)") {
it("should succeed with valid inputs.") {
val result = Await.result(api.removeWebhook(organization, repo, nID), TIMEOUT)
assert(result == true)
}
}
}
}
}