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
59cb9301
Commit
59cb9301
authored
Mar 02, 2021
by
Vitali Tatarintev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't process payload_attribute_mapping when it's blank
Fixes
https://gitlab.com/gitlab-org/gitlab/-/issues/321101
parent
4fc571e0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
73 additions
and
17 deletions
+73
-17
ee/app/graphql/ee/mutations/alert_management/http_integration/http_integration_base.rb
...lert_management/http_integration/http_integration_base.rb
+17
-9
ee/spec/requests/api/graphql/mutations/alert_management/http_integration/update_spec.rb
...utations/alert_management/http_integration/update_spec.rb
+56
-8
No files found.
ee/app/graphql/ee/mutations/alert_management/http_integration/http_integration_base.rb
View file @
59cb9301
...
...
@@ -10,12 +10,6 @@ module EE
private
def
payload_attribute_mapping
(
mappings
)
Array
(
mappings
).
each_with_object
({})
do
|
m
,
h
|
h
[
m
.
field_name
]
=
{
path:
m
.
path
,
type:
m
.
type
,
label:
m
.
label
}
end
end
def
validate_payload_example!
(
payload_example
)
return
if
::
Gitlab
::
Utils
::
DeepSize
.
new
(
payload_example
).
valid?
...
...
@@ -30,9 +24,23 @@ module EE
validate_payload_example!
(
args
[
:payload_example
])
args
.
slice
(
*
base_args
.
keys
,
:payload_example
).
merge
(
payload_attribute_mapping:
payload_attribute_mapping
(
args
[
:payload_attribute_mappings
])
)
args
.
slice
(
*
base_args
.
keys
,
:payload_example
)
.
merge
(
payload_attribute_mapping_params
(
args
))
end
def
payload_attribute_mapping_params
(
args
)
# Don't process payload_attribute_mapping when it's not part of a mutation params.
# Otherwise, it's going to reset already persisted value.
return
{}
unless
args
.
key?
(
:payload_attribute_mappings
)
{
payload_attribute_mapping:
payload_attribute_mapping
(
args
[
:payload_attribute_mappings
])
}
end
def
payload_attribute_mapping
(
mappings
)
Array
(
mappings
).
each_with_object
({})
do
|
m
,
h
|
h
[
m
.
field_name
]
=
{
path:
m
.
path
,
type:
m
.
type
,
label:
m
.
label
}
end
end
end
end
...
...
ee/spec/requests/api/graphql/mutations/alert_management/http_integration/update_spec.rb
View file @
59cb9301
...
...
@@ -33,14 +33,14 @@ RSpec.describe 'Updating an existing HTTP Integration' do
}
graphql_mutation
(
:http_integration_update
,
variables
)
do
<<~
QL
clientMutationId
errors
integration {
id
name
active
url
}
clientMutationId
errors
integration {
id
name
active
url
}
QL
end
end
...
...
@@ -67,6 +67,54 @@ RSpec.describe 'Updating an existing HTTP Integration' do
it_behaves_like
'validating the payload_example'
it_behaves_like
'validating the payload_attribute_mappings'
context
'when the custom mappings attributes are not part of the mutation variables'
do
let_it_be
(
:payload_example
)
do
{
'alert'
=>
{
'name'
=>
'Test alert'
,
'desc'
=>
'Description'
}
}
end
let_it_be
(
:mapping
)
do
{
'title'
=>
{
'path'
=>
%w(alert name)
,
'type'
=>
'string'
,
'label'
=>
'Title'
},
'description'
=>
{
'path'
=>
%w(alert desc)
,
'type'
=>
'string'
}
}
end
let_it_be
(
:integration
)
do
create
(
:alert_management_http_integration
,
project:
project
,
payload_example:
payload_example
,
payload_attribute_mapping:
mapping
)
end
let
(
:mutation
)
do
variables
=
{
id:
GitlabSchema
.
id_from_object
(
integration
).
to_s
,
name:
'Modified Name'
}
graphql_mutation
(
:http_integration_update
,
variables
)
do
<<~
QL
clientMutationId
errors
integration {
id
name
}
QL
end
end
it
'does not resets the custom mapping attributes'
,
:aggregate_failures
do
post_graphql_mutation
(
mutation
,
current_user:
current_user
)
integration_response
=
mutation_response
[
'integration'
]
expect
(
response
).
to
have_gitlab_http_status
(
:success
)
expect
(
integration_response
[
'id'
]).
to
eq
(
GitlabSchema
.
id_from_object
(
integration
).
to_s
)
expect
(
integration_response
[
'name'
]).
to
eq
(
'Modified Name'
)
integration
.
reload
expect
(
integration
.
payload_example
).
to
eq
(
payload_example
)
expect
(
integration
.
payload_attribute_mapping
).
to
eq
(
mapping
)
end
end
context
'with the custom mappings feature unavailable'
do
before
do
stub_licensed_features
(
multiple_alert_http_integrations:
false
)
...
...
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