Skip to content

Commit

Permalink
Fixed deprecated pending_slug issue, fixed typo in alerts documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
bamhm182 committed Oct 18, 2022
1 parent 4753049 commit c97c09b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 26 deletions.
2 changes: 1 addition & 1 deletion docs/src/usage/plugins/alerts.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ The functions within this plugin don't follow the standard naming convention.
>
>> Examples
>> ```python3
>> >>> h.db.synack_url = 'https://hooks.slack.com/services/x/y/z'
>> >>> h.db.slack_url = 'https://hooks.slack.com/services/x/y/z'
>> >>> h.alerts.slack('Something important happened!')
>> ```
9 changes: 3 additions & 6 deletions src/synack/plugins/targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,12 @@ def get_connected(self):
res = self.api.request('GET', 'launchpoint')
if res.status_code == 200:
j = res.json()
if j['pending_slug'] != '-1':
slug = j['pending_slug']
status = "Connecting"
else:
slug = j['slug']
status = "Connected"
slug = j.get('slug')

if slug == '':
status = 'Not Connected'
else:
status = "Connected"

ret = {
"slug": slug,
Expand Down
19 changes: 0 additions & 19 deletions test/test_targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@ def test_get_connected(self):
"""Should make a request to get the currently selected target"""
self.targets.api.request.return_value.status_code = 200
self.targets.api.request.return_value.json.return_value = {
"pending_slug": "-1",
"slug": "qwfars",
"status": "connected"
}
Expand All @@ -244,7 +243,6 @@ def test_get_connected_disconnected(self):
"""Should report Not Connected when not connected to a target"""
self.targets.api.request.return_value.status_code = 200
self.targets.api.request.return_value.json.return_value = {
"pending_slug": "-1",
"slug": "",
"status": "connected"
}
Expand All @@ -257,23 +255,6 @@ def test_get_connected_disconnected(self):
}
self.assertEqual(out, self.targets.get_connected())

def test_get_connected_pending(self):
"""Should return the pending target if one is pending"""
self.targets.api.request.return_value.status_code = 200
self.targets.api.request.return_value.json.return_value = {
"pending_slug": "qwfars",
"slug": "",
"status": ""
}
self.targets.build_codename_from_slug = MagicMock()
self.targets.build_codename_from_slug.return_value = "SLOPPYSLUG"
out = {
"slug": "qwfars",
"codename": "SLOPPYSLUG",
"status": "Connecting"
}
self.assertEqual(out, self.targets.get_connected())

def test_get_credentials(self):
"""Should get credentials for a given target"""
target = Target(organization="qwewqe", slug="asdasd")
Expand Down

0 comments on commit c97c09b

Please sign in to comment.