|
1 | 1 | import os
|
| 2 | +import uuid |
2 | 3 |
|
3 |
| -from expects import be_empty, be_false, be_true, contain, contain_exactly, expect, have_keys |
| 4 | +from expects import be_empty, be_false, be_true, contain, contain_exactly, expect, have_keys, equal |
4 | 5 | from mamba import after, before, context, description, it
|
5 | 6 |
|
6 | 7 | from sdcclient import SdScanningClient
|
7 | 8 | from specs import be_successful_api_call
|
8 | 9 |
|
9 |
| -with description("Scanning Alerts") as self: |
| 10 | +with description("Scanning Alerts", "integration") as self: |
10 | 11 | with before.all:
|
11 | 12 | self.client = SdScanningClient(sdc_url=os.getenv("SDC_SECURE_URL", "https://secure.sysdig.com"),
|
12 | 13 | token=os.getenv("SDC_SECURE_TOKEN"))
|
|
18 | 19 | for alert in res["alerts"]:
|
19 | 20 | self.client.delete_alert(alert["alertId"])
|
20 | 21 |
|
| 22 | + with it("add alert object"): |
| 23 | + alert = { |
| 24 | + "enabled": True, |
| 25 | + "type": "runtime", |
| 26 | + "name": f"runtime-scanning-alert-{uuid.uuid4()}", |
| 27 | + "triggers": { |
| 28 | + "unscanned": True, |
| 29 | + "analysis_update": False, |
| 30 | + "vuln_update": False, |
| 31 | + "policy_eval": False, |
| 32 | + "failed": False |
| 33 | + }, |
| 34 | + "autoscan": False, |
| 35 | + "onlyPassFail": False, |
| 36 | + "skipEventSend": False, |
| 37 | + "notificationChannelIds": [] |
| 38 | + } |
| 39 | + ok, res = self.client.add_alert_object(alert) |
| 40 | + expect((ok, res)).to(be_successful_api_call) |
| 41 | + expect(res['enabled']).to(equal(alert['enabled'])) |
| 42 | + expect(res['type']).to(equal(alert['type'])) |
| 43 | + expect(res['name']).to(equal(alert['name'])) |
| 44 | + expect(res['triggers']).to(equal(alert['triggers'])) |
| 45 | + expect(res['autoscan']).to(equal(alert['autoscan'])) |
| 46 | + expect(res['onlyPassFail']).to(equal(alert['onlyPassFail'])) |
| 47 | + expect(res['skipEventSend']).to(equal(alert['skipEventSend'])) |
| 48 | + expect(res['notificationChannelIds']).to(equal(alert['notificationChannelIds'])) |
| 49 | + |
21 | 50 | with it("lists all the scanning alerts"):
|
22 | 51 | ok, res = self.client.add_runtime_alert(
|
23 | 52 | name="A name",
|
|
0 commit comments