Skip to content

Commit 903279e

Browse files
author
Dean Karn
committed
add test for confidential issues gitlab
1 parent 5462959 commit 903279e

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed

gitlab/gitlab_test.go

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ func TestMain(m *testing.M) {
4343
PushEvents,
4444
TagEvents,
4545
IssuesEvents,
46+
ConfidentialIssuesEvents,
4647
CommentEvents,
4748
MergeRequestEvents,
4849
WikiPageEvents,
@@ -349,6 +350,78 @@ func TestIssueEvent(t *testing.T) {
349350
Equal(t, resp.StatusCode, http.StatusOK)
350351
}
351352

353+
func TestConfidentialIssueEvent(t *testing.T) {
354+
355+
payload := `{
356+
"object_kind": "issue",
357+
"user": {
358+
"name": "Administrator",
359+
"username": "root",
360+
"avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=40\u0026d=identicon"
361+
},
362+
"project":{
363+
"name":"Gitlab Test",
364+
"description":"Aut reprehenderit ut est.",
365+
"web_url":"http://example.com/gitlabhq/gitlab-test",
366+
"avatar_url":null,
367+
"git_ssh_url":"[email protected]:gitlabhq/gitlab-test.git",
368+
"git_http_url":"http://example.com/gitlabhq/gitlab-test.git",
369+
"namespace":"GitlabHQ",
370+
"visibility_level":20,
371+
"path_with_namespace":"gitlabhq/gitlab-test",
372+
"default_branch":"master",
373+
"homepage":"http://example.com/gitlabhq/gitlab-test",
374+
"url":"http://example.com/gitlabhq/gitlab-test.git",
375+
"ssh_url":"[email protected]:gitlabhq/gitlab-test.git",
376+
"http_url":"http://example.com/gitlabhq/gitlab-test.git"
377+
},
378+
"repository":{
379+
"name": "Gitlab Test",
380+
"url": "http://example.com/gitlabhq/gitlab-test.git",
381+
"description": "Aut reprehenderit ut est.",
382+
"homepage": "http://example.com/gitlabhq/gitlab-test"
383+
},
384+
"object_attributes": {
385+
"id": 301,
386+
"title": "New API: create/update/delete file",
387+
"assignee_id": 51,
388+
"author_id": 51,
389+
"project_id": 14,
390+
"created_at": "2013-12-03T17:15:43Z",
391+
"updated_at": "2013-12-03T17:15:43Z",
392+
"position": 0,
393+
"branch_name": null,
394+
"description": "Create new API for manipulations with repository",
395+
"milestone_id": null,
396+
"state": "opened",
397+
"iid": 23,
398+
"url": "http://example.com/diaspora/issues/23",
399+
"action": "open"
400+
},
401+
"assignee": {
402+
"name": "User1",
403+
"username": "user1",
404+
"avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=40\u0026d=identicon"
405+
}
406+
}
407+
`
408+
409+
req, err := http.NewRequest("POST", "http://127.0.0.1:3011/webhooks", bytes.NewBuffer([]byte(payload)))
410+
req.Header.Set("Content-Type", "application/json")
411+
req.Header.Set("X-Gitlab-Event", "Confidential Issue Hook")
412+
req.Header.Set("X-Gitlab-Token", "sampleToken!")
413+
414+
Equal(t, err, nil)
415+
416+
client := &http.Client{}
417+
resp, err := client.Do(req)
418+
Equal(t, err, nil)
419+
420+
defer resp.Body.Close()
421+
422+
Equal(t, resp.StatusCode, http.StatusOK)
423+
}
424+
352425
func TestCommentCommitEvent(t *testing.T) {
353426

354427
payload := `{

0 commit comments

Comments
 (0)