Skip to content

Commit 46bfa35

Browse files
authored
Fix #578: remove mention of 'allow_private' (#580)
* Fix #578: remove mention of 'allow_private' * Remove private bug support in list of changes * Ignore private bugs from runner
1 parent fb3635c commit 46bfa35

File tree

9 files changed

+36
-94
lines changed

9 files changed

+36
-94
lines changed

config/config.nonprod.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
labels_brackets: both
99

1010
- whiteboard_tag: flowstate
11-
allow_private: true
1211
bugzilla_user_id: 91159
1312
description: Flowstate whiteboard tag
1413
parameters:

docs/actions.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ The system reads the actions configuration from a YAML file, one per environment
66
Below is a full example of an action configuration:
77
```yaml
88
- whiteboard_tag: example
9-
allow_private: false
109
bugzilla_user_id: 514230
1110
description: example configuration
1211
module: jbi.actions.default
@@ -18,11 +17,6 @@ A bit more about the different fields...
1817
- `whiteboard_tag`
1918
- string
2019
- The tag to be matched in the Bugzilla `whiteboard` field
21-
- `allow_private` (optional)
22-
- bool [true, false]
23-
- default: false
24-
- If `false`, bugs will not be synchronized if they are not public. Note that in order to synchronize private bugs,
25-
the bugzilla user that JBI runs as must be in the security groups that are making the bug private.
2620
- `bugzilla_user_id`
2721
- a bugzilla user id, a list of user ids, or a literal "tbd" to signify that no bugzilla user id is available
2822
- If an issue arises with the workflow, communication will be established with these users

docs/troubleshooting.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ If you have access to the configured Bugzilla account:
1212
- Open https://bugzilla.mozilla.org/userprefs.cgi?tab=webhooks
1313
- Check that Webhook is still **enabled**
1414
- Check that WebHook is setup to be executed for your product
15-
- (*if applies*) Check that account can read the private bugs
1615

1716
## Log Explorer Queries Examples
1817

jbi/models.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ class Action(YamlModel):
3232
bugzilla_user_id: int | list[int] | Literal["tbd"]
3333
description: str
3434
enabled: bool = True
35-
allow_private: bool = False
3635
parameters: dict = {}
3736
_caller: Optional[Callable] = PrivateAttr(default=None)
3837
_required_jira_permissions: set[str] = PrivateAttr(default=None)
@@ -172,15 +171,7 @@ class BugzillaWebhookEvent(BaseModel):
172171

173172
def changed_fields(self) -> list[str]:
174173
"""Returns the names of changed fields in a bug"""
175-
if self.changes:
176-
return [c.field for c in self.changes]
177-
178-
# Private bugs don't include the changes field in the event, but the
179-
# field names are in the routing key.
180-
if self.routing_key is not None and self.routing_key[0:11] == "bug.modify:":
181-
return self.routing_key[11:].split(",")
182-
183-
return []
174+
return [c.field for c in self.changes] if self.changes else []
184175

185176

186177
class BugzillaWebhookAttachment(BaseModel):

jbi/runner.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ def execute_action(
4444
operation=Operation.HANDLE,
4545
)
4646
try:
47+
if bug.is_private:
48+
raise IgnoreInvalidRequestError("private bugs are not supported")
49+
4750
logger.debug(
4851
"Handling incoming request",
4952
extra=runner_context.dict(),
@@ -68,11 +71,6 @@ def execute_action(
6871
) from err
6972
runner_context = runner_context.update(action=action)
7073

71-
if bug.is_private and not action.allow_private:
72-
raise IgnoreInvalidRequestError(
73-
f"private bugs are not valid for action {action.whiteboard_tag!r}"
74-
)
75-
7674
linked_issue_key: Optional[str] = bug.extract_from_see_also()
7775

7876
action_context = ActionContext(

tests/conftest.py

Lines changed: 12 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,12 @@ def context_update_resolution_example() -> ActionContext:
146146
see_also=["https://mozilla.atlassian.net/browse/JBI-234"]
147147
)
148148
event = factories.webhook_event_factory(
149-
action="modify", routing_key="bug.modify:resolution"
149+
action="modify",
150+
changes=[
151+
factories.webhook_event_change_factory(
152+
field="resolution", removed="OPEN", added="FIXED"
153+
),
154+
],
150155
)
151156
context = factories.action_context_factory(
152157
operation=Operation.UPDATE,
@@ -190,44 +195,21 @@ def webhook_private_comment_example() -> BugzillaWebhookRequest:
190195
return webhook_payload
191196

192197

193-
@pytest.fixture
194-
def webhook_create_private_example() -> BugzillaWebhookRequest:
195-
return factories.webhook_factory(
196-
event=factories.webhook_event_factory(),
197-
bug={"id": 654321, "is_private": True},
198-
)
199-
200-
201198
@pytest.fixture
202199
def webhook_change_status_assignee():
203200
changes = [
204-
{
205-
"field": "status",
206-
"removed": "OPEN",
207-
"added": "FIXED",
208-
},
209-
{
210-
"field": "assignee",
211-
"removed": "[email protected]",
212-
"added": "[email protected]",
213-
},
201+
factories.webhook_event_change_factory(
202+
field="status", removed="OPEN", added="FIXED"
203+
),
204+
factories.webhook_event_change_factory(
205+
field="assignee", removed="[email protected]", added="[email protected]"
206+
),
214207
]
215208
event = factories.webhook_event_factory(routing_key="bug.modify", changes=changes)
216209
webhook_payload = factories.webhook_factory(event=event)
217210
return webhook_payload
218211

219212

220-
@pytest.fixture
221-
def webhook_modify_private_example() -> BugzillaWebhookRequest:
222-
event = factories.webhook_event_factory(
223-
action="modify", routing_key="bug.modify:status"
224-
)
225-
webhook_payload = factories.webhook_factory(
226-
bug={"id": 654321, "is_private": True}, event=event
227-
)
228-
return webhook_payload
229-
230-
231213
@pytest.fixture
232214
def action_factory():
233215
return factories.action_factory

tests/unit/actions/test_steps.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,9 @@ def test_create_with_assignee(
260260

261261
def test_clear_assignee(context_update_example: ActionContext, mocked_jira):
262262
context_update_example.event.action = "modify"
263-
context_update_example.event.routing_key = "bug.modify:assigned_to"
263+
context_update_example.event.changes = [
264+
webhook_event_change_factory(field="assigned_to", removed="user", added="")
265+
]
264266

265267
callable_object = default.init(
266268
jira_project_key=context_update_example.jira.project, steps=ALL_STEPS
@@ -279,7 +281,11 @@ def test_clear_assignee(context_update_example: ActionContext, mocked_jira):
279281
def test_set_assignee(context_update_example: ActionContext, mocked_jira):
280282
context_update_example.bug.assigned_to = "[email protected]"
281283
context_update_example.event.action = "modify"
282-
context_update_example.event.routing_key = "bug.modify:assigned_to"
284+
context_update_example.event.changes = [
285+
webhook_event_change_factory(
286+
field="assigned_to", removed="", added="[email protected]"
287+
)
288+
]
283289

284290
mocked_jira.user_find_by_user_string.return_value = [{"accountId": "6254"}]
285291

@@ -393,7 +399,9 @@ def test_change_to_known_status(context_update_example: ActionContext, mocked_ji
393399
context_update_example.bug.status = "ASSIGNED"
394400
context_update_example.bug.resolution = ""
395401
context_update_example.event.action = "modify"
396-
context_update_example.event.routing_key = "bug.modify:status"
402+
context_update_example.event.changes = [
403+
webhook_event_change_factory(field="status", removed="NEW", added="ASSIGNED")
404+
]
397405

398406
callable_object = default.init(
399407
jira_project_key=context_update_example.jira.project,
@@ -414,7 +422,9 @@ def test_change_to_known_resolution(context_update_example: ActionContext, mocke
414422
context_update_example.bug.status = "RESOLVED"
415423
context_update_example.bug.resolution = "FIXED"
416424
context_update_example.event.action = "modify"
417-
context_update_example.event.routing_key = "bug.modify:resolution"
425+
context_update_example.event.changes = [
426+
webhook_event_change_factory(field="resolution", removed="FIXED", added="OPEN")
427+
]
418428

419429
callable_object = default.init(
420430
jira_project_key=context_update_example.jira.project,

tests/unit/test_bugzilla.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,3 @@ def test_payload_changes_list(webhook_change_status_assignee):
8484
"status",
8585
"assignee",
8686
]
87-
88-
89-
def test_payload_changes_list_in_routing_key(webhook_change_status_assignee):
90-
webhook_change_status_assignee.event.changes = None
91-
webhook_change_status_assignee.event.routing_key = "bug.modify:assigned_to,status"
92-
93-
assert webhook_change_status_assignee.event.changed_fields() == [
94-
"assigned_to",
95-
"status",
96-
]

tests/unit/test_runner.py

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -29,33 +29,33 @@ def test_bugzilla_object_is_always_fetched(
2929
)
3030
mocked_bugzilla.get_bug.return_value = fetched_bug
3131

32-
# when the runner executes a private bug
3332
execute_action(
3433
request=webhook_create_example,
3534
actions=actions_example,
3635
settings=settings,
3736
)
3837

39-
# then
4038
mocked_bugzilla.get_bug.assert_called_once_with(webhook_create_example.bug.id)
4139

4240

4341
def test_request_is_ignored_because_private(
44-
webhook_create_private_example: BugzillaWebhookRequest,
42+
webhook_create_example: BugzillaWebhookRequest,
4543
actions_example: Actions,
4644
settings: Settings,
4745
mocked_bugzilla,
4846
):
49-
bug = bug_factory(id=webhook_create_private_example.bug.id, is_private=True)
47+
bug = bug_factory(id=webhook_create_example.bug.id, is_private=True)
48+
webhook_create_example.bug = bug
5049
mocked_bugzilla.get_bug.return_value = bug
50+
5151
with pytest.raises(IgnoreInvalidRequestError) as exc_info:
5252
execute_action(
53-
request=webhook_create_private_example,
53+
request=webhook_create_example,
5454
actions=actions_example,
5555
settings=settings,
5656
)
5757

58-
assert str(exc_info.value) == "private bugs are not valid for action 'devtest'"
58+
assert str(exc_info.value) == "private bugs are not supported"
5959

6060

6161
def test_request_matched_whiteboard_with_dash(
@@ -83,27 +83,6 @@ def test_request_matched_whiteboard_with_dash(
8383
assert result_bug.id == bug.id
8484

8585

86-
def test_private_request_is_allowed(
87-
webhook_create_private_example: BugzillaWebhookRequest,
88-
settings: Settings,
89-
actions_example,
90-
mocked_bugzilla,
91-
):
92-
bug = bug_factory(id=webhook_create_private_example.bug.id, is_private=True)
93-
mocked_bugzilla.get_bug.return_value = bug
94-
95-
actions_example["devtest"].allow_private = True
96-
97-
result = execute_action(
98-
request=webhook_create_private_example,
99-
actions=actions_example,
100-
settings=settings,
101-
)
102-
103-
bug = BugzillaBug.parse_raw(result["bug"])
104-
assert bug.id == 654321
105-
106-
10786
def test_added_comment_without_linked_issue_is_ignored(
10887
webhook_comment_example: BugzillaWebhookRequest,
10988
actions_example: Actions,

0 commit comments

Comments
 (0)