Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
a99f32d0
Commit
a99f32d0
authored
Feb 28, 2022
by
Timo Furrer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Validate System Hook responses against schema
parent
83556144
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
1 deletion
+37
-1
spec/fixtures/api/schemas/public_api/v4/system_hook.json
spec/fixtures/api/schemas/public_api/v4/system_hook.json
+24
-0
spec/fixtures/api/schemas/public_api/v4/system_hooks.json
spec/fixtures/api/schemas/public_api/v4/system_hooks.json
+9
-0
spec/requests/api/system_hooks_spec.rb
spec/requests/api/system_hooks_spec.rb
+4
-1
No files found.
spec/fixtures/api/schemas/public_api/v4/system_hook.json
0 → 100644
View file @
a99f32d0
{
"type"
:
"object"
,
"required"
:
[
"id"
,
"url"
,
"created_at"
,
"push_events"
,
"tag_push_events"
,
"merge_requests_events"
,
"repository_update_events"
,
"enable_ssl_verification"
],
"properties"
:
{
"id"
:
{
"type"
:
"integer"
},
"url"
:
{
"type"
:
"string"
},
"created_at"
:
{
"type"
:
"string"
},
"push_events"
:
{
"type"
:
"boolean"
},
"tag_push_events"
:
{
"type"
:
"boolean"
},
"merge_requests_events"
:
{
"type"
:
"boolean"
},
"repository_update_events"
:
{
"type"
:
"boolean"
},
"enable_ssl_verification"
:
{
"type"
:
"boolean"
}
},
"additionalProperties"
:
false
}
spec/fixtures/api/schemas/public_api/v4/system_hooks.json
0 → 100644
View file @
a99f32d0
{
"type"
:
"array"
,
"items"
:
{
"type"
:
"object"
,
"properties"
:
{
"$ref"
:
"./system_hook.json"
}
}
}
spec/requests/api/system_hooks_spec.rb
View file @
a99f32d0
...
...
@@ -36,7 +36,7 @@ RSpec.describe API::SystemHooks do
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
response
).
to
match_response_schema
(
'public_api/v4/system_hooks'
)
expect
(
json_response
.
first
).
not_to
have_key
(
"token"
)
expect
(
json_response
.
first
[
'url'
]).
to
eq
(
hook
.
url
)
expect
(
json_response
.
first
[
'push_events'
]).
to
be
false
...
...
@@ -70,6 +70,7 @@ RSpec.describe API::SystemHooks do
get
api
(
"/hooks/
#{
hook
.
id
}
"
,
admin
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/system_hook'
)
expect
(
json_response
).
to
match
(
'id'
=>
be
(
hook
.
id
),
'url'
=>
eq
(
hook
.
url
),
...
...
@@ -121,6 +122,7 @@ RSpec.describe API::SystemHooks do
post
api
(
'/hooks'
,
admin
),
params:
{
url:
'http://mep.mep'
}
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/system_hook'
)
expect
(
json_response
[
'enable_ssl_verification'
]).
to
be
true
expect
(
json_response
[
'push_events'
]).
to
be
false
expect
(
json_response
[
'tag_push_events'
]).
to
be
false
...
...
@@ -142,6 +144,7 @@ RSpec.describe API::SystemHooks do
}
expect
(
response
).
to
have_gitlab_http_status
(
:created
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/system_hook'
)
expect
(
json_response
[
'enable_ssl_verification'
]).
to
be
false
expect
(
json_response
[
'push_events'
]).
to
be
true
expect
(
json_response
[
'tag_push_events'
]).
to
be
true
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment