Skip to content

Commit 0bab9c4

Browse files
committed
test: complete integration test for valid and invalid emails with deliverability
Signed-off-by: Carl Flottmann <carl.flottmann@oracle.com>
1 parent 83963cb commit 0bab9c4

File tree

4 files changed

+42
-18
lines changed

4 files changed

+42
-18
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
# Copyright (c) 2024 - 2025, Oracle and/or its affiliates. All rights reserved.
3+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/.
4+
if sqlite3 --json output/macaron.db "SELECT detect_malicious_metadata_check.detail_information
5+
FROM detect_malicious_metadata_check JOIN check_facts on detect_malicious_metadata_check.id = check_facts.id
6+
JOIN check_result on check_facts.check_result_id = check_result.id JOIN component
7+
ON component.id = check_result.component_id WHERE check_result.check_id = 'mcn_detect_malicious_metadata_1'
8+
AND component.name = 'smooth-operator'" | jq -r ".[0].detail_information | fromjson | .invalid_emails | length > 0"; then
9+
exit 0
10+
else
11+
echo "ERROR: the invalid_emails report for smooth-operator is empty" >&2
12+
exit 1
13+
fi
14+
15+
if sqlite3 --json output/macaron.db "SELECT detect_malicious_metadata_check.detail_information
16+
FROM detect_malicious_metadata_check JOIN check_facts on detect_malicious_metadata_check.id = check_facts.id
17+
JOIN check_result on check_facts.check_result_id = check_result.id JOIN component
18+
ON component.id = check_result.component_id WHERE check_result.check_id = 'mcn_detect_malicious_metadata_1'
19+
AND component.name = 'email-validator'" | jq -r ".[0].detail_information | fromjson | .valid_emails | length > 0"; then
20+
exit 0
21+
else
22+
echo "ERROR: the valid_emails report for email-validator is empty" >&2
23+
exit 1
24+
fi

tests/integration/cases/email_checking_pypi_malware_analyzer/check_smooth_operator_email.sh

Lines changed: 0 additions & 13 deletions
This file was deleted.

tests/integration/cases/email_checking_pypi_malware_analyzer/policy.dl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,16 @@
33

44
#include "prelude.dl"
55

6-
Policy("check-smooth-operator", component_id, "Check clodd artifacts") :-
6+
Policy("check-smooth-operator", component_id, "Check smooth-operator artifacts") :-
77
check_passed(component_id, "mcn_detect_malicious_metadata_1").
88

99
apply_policy_to("check-smooth-operator", component_id) :-
1010
is_component(component_id, purl),
1111
match("pkg:pypi/smooth-operator", purl).
12+
13+
Policy("check-email-validator", component_id, "Check email-validator artifacts") :-
14+
check_passed(component_id, "mcn_detect_malicious_metadata_1").
15+
16+
apply_policy_to("check-email-validator", component_id) :-
17+
is_component(component_id, purl),
18+
match("pkg:pypi/email-validator", purl).

tests/integration/cases/email_checking_pypi_malware_analyzer/test.yaml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
description: |
55
Analyzing two python packages to check if the email address is deliverable and valid. The package smooth-operator is known
6-
to use an invalid email address with an example.com domain.
6+
to use an invalid email address with an example.com domain. email-validator is known to have a valid, deliverable, email address.
77
88
tags:
99
- macaron-python-package
@@ -15,11 +15,17 @@ steps:
1515
command_args:
1616
- -purl
1717
- pkg:pypi/smooth-operator
18-
- name: Query the output database to verify the smooth-operator email was invalid.
18+
- name: Run macaron analyze against email-validator
19+
kind: analyze
20+
options:
21+
command_args:
22+
- -purl
23+
- pkg:pypi/email-validator
24+
- name: Query the output database to verify the emails were detected as invalid and valid respectively.
1925
kind: shell
2026
options:
21-
cmd: ./check_smooth_operator_email.sh
22-
- name: Run macaron verify-policy to check the results of the packages
27+
cmd: ./check_emails.sh
28+
- name: Run macaron verify-policy to check the results of the packages still passed.
2329
kind: verify
2430
options:
2531
policy: policy.dl

0 commit comments

Comments
 (0)