|
11 | 11 | with before.all:
|
12 | 12 | self.client = SdScanningClient(sdc_url=os.getenv("SDC_SECURE_URL", "https://secure.sysdig.com"),
|
13 | 13 | token=os.getenv("SDC_SECURE_TOKEN"))
|
| 14 | + self.image_name = "quay.io/sysdig/agent:latest" |
14 | 15 |
|
15 | 16 | with it("is able to retrieve the results for all the policies"):
|
16 |
| - image_name = "alpine:latest" |
17 |
| - ok, res = self.client.get_image_scanning_results(image_name) |
| 17 | + ok, res = self.client.get_image_scanning_results(self.image_name) |
18 | 18 |
|
19 | 19 | expect((ok, res)).to(be_successful_api_call)
|
20 | 20 | expect(res).to(
|
21 | 21 | have_keys("image_digest", "image_id", "stop_results",
|
22 | 22 | total_warn=be_above_or_equal(0), total_stop=be_above_or_equal(0),
|
23 | 23 | last_evaluation=be_an(datetime),
|
24 |
| - status="pass", image_tag="docker.io/alpine:latest", |
| 24 | + status="pass", image_tag=self.image_name, |
25 | 25 | policy_id="*", policy_name="All policies",
|
26 | 26 | warn_results=not_(be_empty))
|
27 | 27 | )
|
28 | 28 |
|
29 | 29 | with it("is able to retrieve the results for the default policy"):
|
30 |
| - image_name = "alpine:latest" |
31 | 30 | policy_id = "default"
|
32 |
| - ok, res = self.client.get_image_scanning_results(image_name, policy_id) |
| 31 | + ok, res = self.client.get_image_scanning_results(self.image_name, policy_id) |
33 | 32 |
|
34 | 33 | expect((ok, res)).to(be_successful_api_call)
|
35 | 34 | expect(res).to(
|
36 | 35 | have_keys("image_digest", "image_id", "stop_results",
|
37 | 36 | total_warn=be_above_or_equal(0), total_stop=be_above_or_equal(0),
|
38 | 37 | last_evaluation=be_an(datetime),
|
39 |
| - status="pass", image_tag="docker.io/alpine:latest", |
| 38 | + status="pass", image_tag=self.image_name, |
40 | 39 | policy_id="default", policy_name="DefaultPolicy",
|
41 | 40 | warn_results=not_(be_empty))
|
42 | 41 | )
|
43 | 42 |
|
44 | 43 | with context("but the image has not been scanned yet"):
|
45 | 44 | with it("returns an error saying that the image has not been found"):
|
46 |
| - image_name = "unknown_image" |
47 |
| - ok, res = self.client.get_image_scanning_results(image_name) |
| 45 | + ok, res = self.client.get_image_scanning_results("unknown_image") |
48 | 46 |
|
49 | 47 | expect((ok, res)).to_not(be_successful_api_call)
|
50 | 48 | expect(res).to(equal("could not retrieve image digest for the given image name, "
|
51 | 49 | "ensure that the image has been scanned"))
|
52 | 50 |
|
53 | 51 | with context("but the provided policy id does not exist"):
|
54 | 52 | with it("returns an error saying that the policy id is not found"):
|
55 |
| - image_name = "alpine" |
56 | 53 | policy_id = "unknown_policy_id"
|
57 |
| - ok, res = self.client.get_image_scanning_results(image_name, policy_id) |
| 54 | + ok, res = self.client.get_image_scanning_results(self.image_name, policy_id) |
58 | 55 |
|
59 | 56 | expect((ok, res)).to_not(be_successful_api_call)
|
60 | 57 | expect(res).to(equal("the specified policy ID doesn't exist"))
|
0 commit comments