Skip to content

Commit

Permalink
Add 25 seconds wait time (at most) for clamd.ctl + Update EICAR signa…
Browse files Browse the repository at this point in the history
…ture name
  • Loading branch information
GreatBahram committed Aug 3, 2021
1 parent 3b09674 commit c1c6112
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,15 @@ jobs:
sudo freshclam --verbose
sudo systemctl restart clamav-daemon.service
- name: Wait for 25 seconds until clamd socket becomes available
run: |
secs=25
while [[ $secs -gt 0 ]] && ! [[ -f "/var/run/clamav/clamd.ctl" ]];
do
echo -ne "$secs\033[0K\r"
sleep 1
: $((secs--))
done
- name: Run unit tests
run: pytest
11 changes: 6 additions & 5 deletions src/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
mine = (stat.S_IREAD | stat.S_IWRITE)
other = stat.S_IROTH
execute = (stat.S_IEXEC | stat.S_IXOTH)
EICAR_SIG_NAME = "Win.Test.EICAR_HDB-1"


@contextmanager
Expand Down Expand Up @@ -42,7 +43,7 @@ def test_scan(self):
f.write(clamd.EICAR)
f.flush()
os.fchmod(f.fileno(), (mine | other))
expected = {f.name: ('FOUND', 'Eicar-Test-Signature')}
expected = {f.name: ('FOUND', EICAR_SIG_NAME)}

assert self.cd.scan(f.name) == expected

Expand All @@ -51,7 +52,7 @@ def test_unicode_scan(self):
f.write(clamd.EICAR)
f.flush()
os.fchmod(f.fileno(), (mine | other))
expected = {f.name: ('FOUND', 'Eicar-Test-Signature')}
expected = {f.name: ('FOUND', EICAR_SIG_NAME)}

assert self.cd.scan(f.name) == expected

Expand All @@ -62,13 +63,13 @@ def test_multiscan(self):
with open(os.path.join(d, "file" + str(i)), 'wb') as f:
f.write(clamd.EICAR)
os.fchmod(f.fileno(), (mine | other))
expected[f.name] = ('FOUND', 'Eicar-Test-Signature')
expected[f.name] = ('FOUND', EICAR_SIG_NAME)
os.chmod(d, (mine | other | execute))

assert self.cd.multiscan(d) == expected

def test_instream(self):
expected = {'stream': ('FOUND', 'Eicar-Test-Signature')}
expected = {'stream': ('FOUND', EICAR_SIG_NAME)}
assert self.cd.instream(BytesIO(clamd.EICAR)) == expected

def test_insteam_success(self):
Expand All @@ -79,7 +80,7 @@ def test_fdscan(self):
f.write(clamd.EICAR)
f.flush()
os.fchmod(f.fileno(), (mine | other))
expected = {f.name: ('FOUND', 'Eicar-Test-Signature')}
expected = {f.name: ('FOUND', EICAR_SIG_NAME)}

assert self.cd.fdscan(f.name) == expected

Expand Down

0 comments on commit c1c6112

Please sign in to comment.