Открыть боковую панель
GitLab.org
Gitlab
Коммиты
56a7ef41
Коммит
56a7ef41
создал
Мар 27, 2023
по автору
Sanad Liaquat (Personal)
Просмотр файлов
Add a case for when auto_disabling_web_hooks ff is not on
владелец
ee101a3e
Изменения
1
Скрыть пробелы
Построчно
Рядом
qa/qa/specs/features/api/1_manage/integrations/webhook_events_spec.rb
Просмотр файла @
56a7ef41
...
...
@@ -63,7 +63,7 @@ module QA
end
expect
{
smocker
.
events
(
session
).
size
}.
to
eventually_eq
(
2
)
.
within
(
max_duration:
30
,
sleep_interval:
2
),
.
within
(
max_duration:
30
,
sleep_interval:
2
),
->
{
"Should have 2 events, got:
#{
smocker
.
stringified_history
(
session
)
}
"
}
events
=
smocker
.
events
(
session
)
...
...
@@ -111,29 +111,45 @@ module QA
let
(
:hook_trigger_times
)
{
5
}
let
(
:disabled_after
)
{
4
}
before
do
Runtime
::
Feature
.
enable
(
:auto_disabling_web_hooks
)
end
context
'when auto_disabling_web_hooks feature flag is disabled'
do
before
do
Runtime
::
Feature
.
disable
(
:auto_disabling_web_hooks
)
end
it
'webhook is not auto-disabled'
,
testcase:
'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/389595'
do
Resource
::
ProjectWebHook
.
setup
(
fail_mock
,
session:
session
,
issues:
true
)
do
|
webhook
,
smocker
|
create_multiple_issues
(
hook_trigger_times
,
webhook
.
project
)
expect
{
smocker
.
events
(
session
).
size
}.
to
eventually_eq
(
hook_trigger_times
)
.
within
(
max_duration:
30
,
sleep_interval:
2
),
->
{
"Should have
#{
hook_trigger_times
}
events, got:
#{
smocker
.
events
(
session
).
size
}
"
}
it
'hook is auto-disabled'
,
testcase:
'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/389595'
do
Resource
::
ProjectWebHook
.
setup
(
fail_mock
,
session:
session
,
issues:
true
)
do
|
webhook
,
smocker
|
hook_trigger_times
.
times
do
Resource
::
Issue
.
fabricate_via_api!
do
|
issue_init
|
issue_init
.
project
=
webhook
.
project
end
webhook
.
reload!
# using sleep to give rate limiter a chance to activate.
sleep
0.5
expect
(
webhook
.
alert_status
).
to
eql
(
'executable'
)
end
end
end
context
'and auto_disabling_web_hooks feature flag is enabled'
do
before
do
Runtime
::
Feature
.
enable
(
:auto_disabling_web_hooks
)
end
expect
{
smocker
.
events
(
session
).
size
}.
to
eventually_eq
(
disabled_after
)
.
within
(
max_duration:
30
,
sleep_interval:
2
),
->
{
"Should have
#{
disabled_after
}
events, got:
#{
smocker
.
events
(
session
).
size
}
"
}
it
'webhook is auto-disabled'
,
testcase:
'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/389595'
do
Resource
::
ProjectWebHook
.
setup
(
fail_mock
,
session:
session
,
issues:
true
)
do
|
webhook
,
smocker
|
create_multiple_issues
(
hook_trigger_times
,
webhook
.
project
)
webhook
.
reload!
expect
{
smocker
.
events
(
session
).
size
}.
to
eventually_eq
(
disabled_after
)
.
within
(
max_duration:
30
,
sleep_interval:
2
),
->
{
"Should have
#{
disabled_after
}
events, got:
#{
smocker
.
events
(
session
).
size
}
"
}
expect
(
webhook
.
alert_status
).
to
eql
(
'disabled'
)
webhook
.
reload!
expect
(
webhook
.
alert_status
).
to
eql
(
'disabled'
)
end
end
end
end
...
...
@@ -141,9 +157,20 @@ module QA
private
def
create_multiple_issues
(
no_of_issues
,
project
)
no_of_issues
.
times
do
Resource
::
Issue
.
fabricate_via_api!
do
|
issue_init
|
issue_init
.
project
=
project
end
# using sleep to give rate limiter a chance to activate.
sleep
0.5
end
end
def
expect_web_hook_single_event_success
(
webhook
,
smocker
,
type
:)
expect
{
smocker
.
events
(
session
).
size
}.
to
eventually_eq
(
1
)
.
within
(
max_duration:
30
,
sleep_interval:
2
),
.
within
(
max_duration:
30
,
sleep_interval:
2
),
->
{
"Should have 1 events, got:
#{
smocker
.
stringified_history
(
session
)
}
"
}
event
=
smocker
.
events
(
session
).
first
...
...
Редактирование
Предварительный просмотр
Поддерживает Markdown
0%
Попробовать снова
или
прикрепить новый файл
.
Отмена
You are about to add
0
people
to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Отмена
Пожалуйста,
зарегистрируйтесь
или
войдите
чтобы прокомментировать